Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-04-29 04:59:04 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-04-29 04:59:04 +0400
commit2585d524057da908668bb6d5ff7ec8b344d23093 (patch)
tree2494aaa2281e568e4904fbe419f6a032535c65ad /source/blender/blenkernel
parentd8e12e8710f7c24e046c132e84eff416b8e8d06c (diff)
parent4465d2f419a8515df41a8fc415774eedaef0e6f6 (diff)
Merged changes in the trunk up to revision 46045.
Conflicts resolved: doc/python_api/sphinx_doc_gen.py source/blender/blenkernel/intern/subsurf_ccg.c source/blender/editors/mesh/editmesh_tools.c source/blender/makesdna/DNA_scene_types.h
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_armature.h3
-rw-r--r--source/blender/blenkernel/BKE_blender.h6
-rw-r--r--source/blender/blenkernel/BKE_curve.h135
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_lattice.h2
-rw-r--r--source/blender/blenkernel/BKE_mball.h147
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h6
-rw-r--r--source/blender/blenkernel/BKE_particle.h6
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h2
-rw-r--r--source/blender/blenkernel/BKE_report.h6
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h4
-rw-r--r--source/blender/blenkernel/BKE_tessmesh.h3
-rw-r--r--source/blender/blenkernel/SConscript2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c606
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c21
-rw-r--r--source/blender/blenkernel/intern/action.c2
-rw-r--r--source/blender/blenkernel/intern/anim.c10
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c18
-rw-r--r--source/blender/blenkernel/intern/armature.c10
-rw-r--r--source/blender/blenkernel/intern/boids.c8
-rw-r--r--source/blender/blenkernel/intern/brush.c2
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c6
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c32
-rw-r--r--source/blender/blenkernel/intern/cloth.c186
-rw-r--r--source/blender/blenkernel/intern/collision.c243
-rw-r--r--source/blender/blenkernel/intern/colortools.c15
-rw-r--r--source/blender/blenkernel/intern/constraint.c21
-rw-r--r--source/blender/blenkernel/intern/context.c2
-rw-r--r--source/blender/blenkernel/intern/curve.c184
-rw-r--r--source/blender/blenkernel/intern/customdata.c33
-rw-r--r--source/blender/blenkernel/intern/deform.c4
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c16
-rw-r--r--source/blender/blenkernel/intern/displist.c53
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c202
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c8
-rw-r--r--source/blender/blenkernel/intern/effect.c13
-rw-r--r--source/blender/blenkernel/intern/fcurve.c5
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c3
-rw-r--r--source/blender/blenkernel/intern/font.c30
-rw-r--r--source/blender/blenkernel/intern/idprop.c5
-rw-r--r--source/blender/blenkernel/intern/image.c37
-rw-r--r--source/blender/blenkernel/intern/image_gen.c12
-rw-r--r--source/blender/blenkernel/intern/implicit.c243
-rw-r--r--source/blender/blenkernel/intern/ipo.c26
-rw-r--r--source/blender/blenkernel/intern/key.c8
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/library.c31
-rw-r--r--source/blender/blenkernel/intern/material.c12
-rw-r--r--source/blender/blenkernel/intern/mball.c205
-rw-r--r--source/blender/blenkernel/intern/mesh.c103
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c18
-rw-r--r--source/blender/blenkernel/intern/modifier.c2
-rw-r--r--source/blender/blenkernel/intern/modifiers_bmesh.c4
-rw-r--r--source/blender/blenkernel/intern/movieclip.c12
-rw-r--r--source/blender/blenkernel/intern/multires.c12
-rw-r--r--source/blender/blenkernel/intern/navmesh_conversion.c117
-rw-r--r--source/blender/blenkernel/intern/nla.c4
-rw-r--r--source/blender/blenkernel/intern/object.c55
-rw-r--r--source/blender/blenkernel/intern/ocean.c149
-rw-r--r--source/blender/blenkernel/intern/packedFile.c4
-rw-r--r--source/blender/blenkernel/intern/paint.c8
-rw-r--r--source/blender/blenkernel/intern/particle.c36
-rw-r--r--source/blender/blenkernel/intern/particle_system.c73
-rw-r--r--source/blender/blenkernel/intern/pointcache.c71
-rw-r--r--source/blender/blenkernel/intern/property.c10
-rw-r--r--source/blender/blenkernel/intern/report.c2
-rw-r--r--source/blender/blenkernel/intern/sca.c10
-rw-r--r--source/blender/blenkernel/intern/scene.c1
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c11
-rw-r--r--source/blender/blenkernel/intern/sequencer.c64
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c71
-rw-r--r--source/blender/blenkernel/intern/sketch.c129
-rw-r--r--source/blender/blenkernel/intern/softbody.c65
-rw-r--r--source/blender/blenkernel/intern/sound.c104
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c1149
-rw-r--r--source/blender/blenkernel/intern/text.c98
-rw-r--r--source/blender/blenkernel/intern/texture.c9
-rw-r--r--source/blender/blenkernel/intern/tracking.c33
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c40
-rw-r--r--source/blender/blenkernel/intern/writeframeserver.c3
81 files changed, 2408 insertions, 2699 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index e4802cfa37f..dfe3fde17eb 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -89,7 +89,7 @@ int bone_autoside_name (char name[64], int strip_number, short axis, float head,
struct Bone *get_named_bone (struct bArmature *arm, const char *name);
-float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist);
+float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float r1, float r2, float rdist);
void where_is_armature (struct bArmature *arm);
void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone);
@@ -136,7 +136,6 @@ Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan, int rest);
/* like EBONE_VISIBLE */
#define PBONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
-#define _BONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index e0fac79359d..14f5c27c3df 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -41,8 +41,8 @@ extern "C" {
/* these lines are grep'd, watch out for our not-so-awesome regex
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
-#define BLENDER_VERSION 262
-#define BLENDER_SUBVERSION 4
+#define BLENDER_VERSION 263
+#define BLENDER_SUBVERSION 0
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
@@ -51,7 +51,7 @@ extern "C" {
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR
/* alpha/beta/rc/release, docs use this */
-#define BLENDER_VERSION_CYCLE rc
+#define BLENDER_VERSION_CYCLE alpha
extern char versionstr[]; /* from blender.c */
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index fa3a1a6897a..3b9328ae1aa 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -53,72 +53,83 @@ struct Scene;
#define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1)
#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1!=0.0f || (cu)->ext2!=0.0f) ? 1:0)
+/* ** Curve ** */
+void BKE_curve_unlink(struct Curve *cu);
+void BKE_curve_free(struct Curve *cu);
+void BKE_curve_editfont_free(struct Curve *cu);
+struct Curve *BKE_curve_add(const char *name, int type);
+struct Curve *BKE_curve_copy(struct Curve *cu);
+void BKE_curve_make_local(struct Curve *cu);
+short BKE_curve_type_get(struct Curve *cu);
+void BKE_curve_type_test(struct Object *ob);
+void BKE_curve_curve_dimension_update(struct Curve *cu);
+void BKE_curve_tex_space_calc(struct Curve *cu);
-void unlink_curve(struct Curve *cu);
-void free_curve_editNurb_keyIndex(struct EditNurb *editnurb);
-void free_curve_editNurb(struct Curve *cu);
-void free_curve(struct Curve *cu);
-void BKE_free_editfont(struct Curve *cu);
-struct Curve *add_curve(const char *name, int type);
-struct Curve *copy_curve(struct Curve *cu);
-void make_local_curve(struct Curve *cu);
-struct ListBase *curve_editnurbs(struct Curve *cu);
-short curve_type(struct Curve *cu);
-void test_curve_type(struct Object *ob);
-void update_curve_dimension(struct Curve *cu );
-void tex_space_curve(struct Curve *cu);
-int count_curveverts(struct ListBase *nurb);
-int count_curveverts_without_handles(struct ListBase *nurb);
-void freeNurb(struct Nurb *nu);
-void freeNurblist(struct ListBase *lb);
-struct Nurb *duplicateNurb(struct Nurb *nu);
-void duplicateNurblist(struct ListBase *lb1, struct ListBase *lb2);
-void test2DNurb(struct Nurb *nu);
-void minmaxNurb(struct Nurb *nu, float *min, float *max);
-
-void nurbs_knot_calc_u(struct Nurb *nu);
-void nurbs_knot_calc_v(struct Nurb *nu);
-
-void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
-void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
-void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
-float *make_orco_curve(struct Scene *scene, struct Object *ob);
-float *make_orco_surf(struct Object *ob);
-void makebevelcurve(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender);
-
-void makeBevelList(struct Object *ob);
-
-void calchandleNurb(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, int mode);
-void calchandlesNurb(struct Nurb *nu);
-void testhandlesNurb(struct Nurb *nu);
-void autocalchandlesNurb(struct Nurb *nu, int flag);
-void autocalchandlesNurb_all(ListBase *editnurb, int flag);
-void sethandlesNurb(ListBase *editnurb, short code);
-
-void switchdirectionNurb(struct Nurb *nu);
-
-void addNurbPoints(struct Nurb *nu, int number);
-void addNurbPointsBezier(struct Nurb *nu, int number);
-
-float (*curve_getVertexCos(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
-void curve_applyVertexCos(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
-
-float (*curve_getKeyVertexCos(struct Curve *cu, struct ListBase *lb, float *key))[3];
-void curve_applyKeyVertexTilts(struct Curve *cu, struct ListBase *lb, float *key);
+int BKE_curve_minmax(struct Curve *cu, float min[3], float max[3]);
+int BKE_curve_center_median(struct Curve *cu, float cent[3]);
+int BKE_curve_center_bounds(struct Curve *cu, float cent[3]);
+void BKE_curve_translate(struct Curve *cu, float offset[3], int do_keys);
+void BKE_curve_delete_material_index(struct Curve *cu, int index);
+
+ListBase *BKE_curve_nurbs_get(struct Curve *cu);
+
+float (*BKE_curve_vertexCos_get(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
+void BK_curve_vertexCos_apply(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
+
+float (*BKE_curve_keyVertexCos_get(struct Curve *cu, struct ListBase *lb, float *key))[3];
+void BKE_curve_keyVertexTilts_apply(struct Curve *cu, struct ListBase *lb, float *key);
+
+void BKE_curve_editNurb_keyIndex_free(struct EditNurb *editnurb);
+void BKE_curve_editNurb_free(struct Curve *cu);
+struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
+
+float *BKE_curve_make_orco(struct Scene *scene, struct Object *ob);
+float *BKE_curve_surf_make_orco(struct Object *ob);
+
+void BKE_curve_bevelList_make(struct Object *ob);
+void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender);
+
+void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
+
+/* ** Nurbs ** */
+
+int BKE_nurbList_verts_count(struct ListBase *nurb);
+int BKE_nurbList_verts_count_without_handles(struct ListBase *nurb);
+
+void BKE_nurbList_free(struct ListBase *lb);
+void BKE_nurbList_duplicate(struct ListBase *lb1, struct ListBase *lb2);
+void BKE_nurbList_handles_set(struct ListBase *editnurb, short code);
+
+void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag);
+
+void BKE_nurb_free(struct Nurb *nu);
+struct Nurb *BKE_nurb_duplicate(struct Nurb *nu);
+
+void BKE_nurb_test2D(struct Nurb *nu);
+void BKE_nurb_minmax(struct Nurb *nu, float *min, float *max);
+
+void BKE_nurb_makeFaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
+void BKE_nurb_makeCurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
+
+void BKE_nurb_knot_calc_u(struct Nurb *nu);
+void BKE_nurb_knot_calc_v(struct Nurb *nu);
/* nurb checks if they can be drawn, also clamp order func */
-int check_valid_nurb_u(struct Nurb *nu);
-int check_valid_nurb_v(struct Nurb *nu);
+int BKE_nurb_check_valid_u(struct Nurb *nu);
+int BKE_nurb_check_valid_v(struct Nurb *nu);
-int clamp_nurb_order_u(struct Nurb *nu);
-int clamp_nurb_order_v(struct Nurb *nu);
+int BKE_nurb_order_clamp_u(struct Nurb *nu);
+int BKE_nurb_order_clamp_v(struct Nurb *nu);
-ListBase *BKE_curve_nurbs(struct Curve *cu);
+void BKE_nurb_direction_switch(struct Nurb *nu);
-int minmax_curve(struct Curve *cu, float min[3], float max[3]);
-int curve_center_median(struct Curve *cu, float cent[3]);
-int curve_center_bounds(struct Curve *cu, float cent[3]);
-void curve_translate(struct Curve *cu, float offset[3], int do_keys);
-void curve_delete_material_index(struct Curve *cu, int index);
-#endif
+void BKE_nurb_points_add(struct Nurb *nu, int number);
+void BKE_nurb_bezierPoints_add(struct Nurb *nu, int number);
+
+void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, int mode);
+void BKE_nurb_handles_calc(struct Nurb *nu);
+void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag);
+void BKE_nurb_handles_test(struct Nurb *nu);
+
+#endif
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index f5437645551..c2112d1e169 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -68,6 +68,8 @@ char BKE_imtype_valid_depths(const char imtype);
char BKE_imtype_from_arg(const char *arg);
+void BKE_imformat_defaults(struct ImageFormatData *im_format);
+
struct anim *openanim(const char *name, int flags, int streamindex);
void image_de_interlace(struct Image *ima, int odd);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 29c78510fd8..a0075c4d6be 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -49,7 +49,7 @@ void make_local_lattice(struct Lattice *lt);
void calc_lat_fudu(int flag, int res, float *fu, float *du);
void init_latt_deform(struct Object *oblatt, struct Object *ob);
-void calc_latt_deform(struct Object *, float *co, float weight);
+void calc_latt_deform(struct Object *, float co[3], float weight);
void end_latt_deform(struct Object *);
int object_deform_mball(struct Object *ob, struct ListBase *dispbase);
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index fafd2a3d30e..018ee7f6c94 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -37,147 +37,30 @@ struct Object;
struct Scene;
struct MetaElem;
-typedef struct point { /* a three-dimensional point */
- float x, y, z; /* its coordinates */
-} MB_POINT;
+void BKE_metaball_unlink(struct MetaBall *mb);
+void BKE_metaball_free(struct MetaBall *mb);
+struct MetaBall *BKE_metaball_add(const char *name);
+struct MetaBall *BKE_metaball_copy(struct MetaBall *mb);
-typedef struct vertex { /* surface vertex */
- MB_POINT position, normal; /* position and surface normal */
-} VERTEX;
+void BKE_metaball_make_local(struct MetaBall *mb);
-typedef struct vertices { /* list of vertices in polygonization */
- int count, max; /* # vertices, max # allowed */
- VERTEX *ptr; /* dynamically allocated */
-} VERTICES;
+void BKE_metaball_cubeTable_free(void);
-typedef struct corner { /* corner of a cube */
- int i, j, k; /* (i, j, k) is index within lattice */
- float x, y, z, value; /* location and function value */
- struct corner *next;
-} CORNER;
+void BKE_metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
+int BKE_metaball_is_basis_for(struct Object *ob1, struct Object *ob2);
+int BKE_metaball_is_basis(struct Object *ob);
+struct Object *BKE_metaball_basis_find(struct Scene *scene, struct Object *ob);
-typedef struct cube { /* partitioning cell (cube) */
- int i, j, k; /* lattice location of cube */
- CORNER *corners[8]; /* eight corners */
-} CUBE;
+void BKE_metaball_tex_space_calc(struct Object *ob);
+float *BKE_metaball_make_orco(struct Object *ob, struct ListBase *dispbase);
-typedef struct cubes { /* linked list of cubes acting as stack */
- CUBE cube; /* a single cube */
- struct cubes *next; /* remaining elements */
-} CUBES;
-
-typedef struct centerlist { /* list of cube locations */
- int i, j, k; /* cube location */
- struct centerlist *next; /* remaining elements */
-} CENTERLIST;
-
-typedef struct edgelist { /* list of edges */
- int i1, j1, k1, i2, j2, k2; /* edge corner ids */
- int vid; /* vertex id */
- struct edgelist *next; /* remaining elements */
-} EDGELIST;
-
-typedef struct intlist { /* list of integers */
- int i; /* an integer */
- struct intlist *next; /* remaining elements */
-} INTLIST;
-
-typedef struct intlists { /* list of list of integers */
- INTLIST *list; /* a list of integers */
- struct intlists *next; /* remaining elements */
-} INTLISTS;
-
-typedef struct process { /* parameters, function, storage */
- /* what happens here? floats, I think. */
- /* float (*function)(void); */ /* implicit surface function */
- float (*function)(float, float, float);
- float size, delta; /* cube size, normal delta */
- int bounds; /* cube range within lattice */
- CUBES *cubes; /* active cubes */
- VERTICES vertices; /* surface vertices */
- CENTERLIST **centers; /* cube center hash table */
- CORNER **corners; /* corner value hash table */
- EDGELIST **edges; /* edge and vertex id hash table */
-} PROCESS;
-
-/* dividing scene using octal tree makes polygonisation faster */
-typedef struct ml_pointer {
- struct ml_pointer *next, *prev;
- struct MetaElem *ml;
-} ml_pointer;
-
-typedef struct octal_node {
- struct octal_node *nodes[8]; /* children of current node */
- struct octal_node *parent; /* parent of current node */
- struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */
- float x_min, y_min, z_min; /* 1st border point */
- float x_max, y_max, z_max; /* 7th border point */
- float x,y,z; /* center of node */
- int pos, neg; /* number of positive and negative MetaElements in the node */
- int count; /* number of MetaElems, which belongs to the node */
-} octal_node;
-
-typedef struct octal_tree {
- struct octal_node *first; /* first node */
- int pos, neg; /* number of positive and negative MetaElements in the scene */
- short depth; /* number of scene subdivision */
-} octal_tree;
-
-struct pgn_elements {
- struct pgn_elements *next, *prev;
- char *data;
-};
-
-octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth);
-
-void freepolygonize(PROCESS *p);
-void docube(CUBE *cube, PROCESS *p, struct MetaBall *mb);
-void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p);
-CORNER *setcorner (PROCESS* p, int i, int j, int k);
-int vertid (CORNER *c1, CORNER *c2, PROCESS *p, struct MetaBall *mb);
-int setcenter(CENTERLIST *table[], int i, int j, int k);
-int otherface (int edge, int face);
-void makecubetable (void);
-void setedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2, int vid);
-int getedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2);
-void addtovertices (VERTICES *vertices, VERTEX v);
-void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v);
-void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, float (*function)(float, float, float), MB_POINT *p, struct MetaBall *mb, int f);
-void add_cube(PROCESS *mbproc, int i, int j, int k, int count);
-void find_first_points(PROCESS *mbproc, struct MetaBall *mb, int a);
-
-void fill_metaball_octal_node(octal_node *node, struct MetaElem *ml, short i);
-void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth);
-void free_metaball_octal_node(octal_node *node);
-void init_metaball_octal_tree(int depth);
-void polygonize(PROCESS *mbproc, struct MetaBall *mb);
-float init_meta(struct Scene *scene, struct Object *ob);
-
-void unlink_mball(struct MetaBall *mb);
-void free_mball(struct MetaBall *mb);
-struct MetaBall *add_mball(const char *name);
-struct MetaBall *copy_mball(struct MetaBall *mb);
-void make_local_mball(struct MetaBall *mb);
-struct MetaElem *add_metaball_element(struct MetaBall *mb, const int type);
-void tex_space_mball(struct Object *ob);
-float *make_orco_mball(struct Object *ob, struct ListBase *dispbase);
-void copy_mball_properties(struct Scene *scene, struct Object *active_object);
-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[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);
-void *new_pgn_element(int size);
-int nextcwedge (int edge, int face);
-void BKE_freecubetable(void);
+void BKE_metaball_properties_copy(struct Scene *scene, struct Object *active_object);
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
+struct MetaElem *BKE_metaball_element_add(struct MetaBall *mb, const int type);
+#endif
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 2d0719a78fa..742e6ef0b89 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -112,7 +112,7 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const struct MPoly *poly,
const struct MLoop *mloop, unsigned vert);
/* update the hide flag for edges and polys from the corresponding
- flag in verts */
+ * flag in verts */
void mesh_flush_hidden_from_verts(const struct MVert *mvert,
const struct MLoop *mloop,
struct MEdge *medge, int totedge,
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index d7b2f271a83..29924542494 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -40,10 +40,10 @@ struct MovieClipUser;
struct MovieTrackingTrack;
struct MovieDistortion;
-void free_movieclip(struct MovieClip *clip);
-void unlink_movieclip(struct Main *bmain, struct MovieClip *clip);
+void BKE_movieclip_free(struct MovieClip *clip);
+void BKE_movieclip_unlink(struct Main *bmain, struct MovieClip *clip);
-struct MovieClip *BKE_add_movieclip_file(const char *name);
+struct MovieClip *BKE_movieclip_file_add(const char *name);
void BKE_movieclip_reload(struct MovieClip *clip);
struct ImBuf *BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 3e0180a84aa..67dba6fd7a7 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -85,7 +85,7 @@ typedef struct ParticleSimulationData {
float courant_num;
} ParticleSimulationData;
-typedef struct ParticleTexture{
+typedef struct ParticleTexture {
float ivel; /* used in reset */
float time, life, exist, size; /* used in init */
float damp, gravity, field; /* used in physics */
@@ -93,13 +93,13 @@ typedef struct ParticleTexture{
float rough1, rough2, roughe; /* used in path caching */
} ParticleTexture;
-typedef struct ParticleSeam{
+typedef struct ParticleSeam {
float v0[3], v1[3];
float nor[3], dir[3], tan[3];
float length2;
} ParticleSeam;
-typedef struct ParticleCacheKey{
+typedef struct ParticleCacheKey {
float co[3];
float vel[3];
float rot[4];
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index eba5c117199..d7d7324dd56 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -187,7 +187,7 @@ typedef struct PTCacheBaker {
#define PEK_HIDE 4
#define PEK_USE_WCO 8
-typedef struct PTCacheEditKey{
+typedef struct PTCacheEditKey {
float *co;
float *vel;
float *rot;
diff --git a/source/blender/blenkernel/BKE_report.h b/source/blender/blenkernel/BKE_report.h
index f6307806491..aa625fab3b2 100644
--- a/source/blender/blenkernel/BKE_report.h
+++ b/source/blender/blenkernel/BKE_report.h
@@ -54,7 +54,11 @@ __attribute__ ((format (printf, 3, 4)))
;
void BKE_reports_prepend(ReportList *reports, const char *prepend);
-void BKE_reports_prependf(ReportList *reports, const char *prepend, ...);
+void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)))
+#endif
+;
ReportType BKE_report_print_level(ReportList *reports);
void BKE_report_print_level_set(ReportList *reports, ReportType level);
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 7f9881926a6..8179c688580 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -68,7 +68,7 @@ void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3])
int ccg_gridsize(int level);
/* x/y grid coordinates at 'low_level' can be multiplied by the result
- of this function to convert to grid coordinates at 'high_level' */
+ * of this function to convert to grid coordinates at 'high_level' */
int ccg_factor(int low_level, int high_level);
void subsurf_copy_grid_hidden(struct DerivedMesh *dm,
@@ -78,7 +78,7 @@ void subsurf_copy_grid_hidden(struct DerivedMesh *dm,
typedef enum MultiresModifiedFlags {
/* indicates the grids have been sculpted on, so MDisps
- have to be updated */
+ * have to be updated */
MULTIRES_COORDS_MODIFIED = 1,
/* indicates elements have been hidden or unhidden */
MULTIRES_HIDDEN_MODIFIED = 2
diff --git a/source/blender/blenkernel/BKE_tessmesh.h b/source/blender/blenkernel/BKE_tessmesh.h
index d9d2c21e2b3..3a806651d61 100644
--- a/source/blender/blenkernel/BKE_tessmesh.h
+++ b/source/blender/blenkernel/BKE_tessmesh.h
@@ -23,6 +23,7 @@
#ifndef __BKE_TESSMESH_H__
#define __BKE_TESSMESH_H__
+#include "BKE_customdata.h"
#include "bmesh.h"
struct BMesh;
@@ -58,7 +59,7 @@ typedef struct BMEditMesh {
/*derivedmesh stuff*/
struct DerivedMesh *derivedFinal, *derivedCage;
- int lastDataMask;
+ CustomDataMask lastDataMask;
/* index tables, to map indices to elements via
* EDBM_index_arrays_init and associated functions. don't
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index e5ce210d862..61ef30d5149 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -114,7 +114,7 @@ if env['WITH_BF_FFTW3']:
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')
-if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 9b55785d1a4..53e4a973cd4 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -27,7 +27,7 @@
/***/
-typedef unsigned char byte;
+typedef unsigned char byte;
/***/
@@ -50,10 +50,13 @@ typedef struct _EHash {
CCGAllocatorHDL allocator;
} EHash;
-#define EHASH_alloc(eh, nb) ((eh)->allocatorIFC.alloc((eh)->allocator, nb))
-#define EHASH_free(eh, ptr) ((eh)->allocatorIFC.free((eh)->allocator, ptr))
+#define EHASH_alloc(eh, nb) ((eh)->allocatorIFC.alloc((eh)->allocator, nb))
+#define EHASH_free(eh, ptr) ((eh)->allocatorIFC.free((eh)->allocator, ptr))
-#define EHASH_hash(eh, item) (((uintptr_t) (item))%((unsigned int) (eh)->curSize))
+#define EHASH_hash(eh, item) (((uintptr_t) (item)) % ((unsigned int) (eh)->curSize))
+
+static void ccgSubSurf__sync(CCGSubSurf *ss);
+static int _edge_isBoundary(const CCGEdge *e);
static EHash *_ehash_new(int estimatedNumEntries, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator)
{
@@ -107,7 +110,7 @@ static void _ehash_insert(EHash *eh, EHEntry *entry)
memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets));
while (numBuckets--) {
- for (entry = oldBuckets[numBuckets]; entry;) {
+ for (entry = oldBuckets[numBuckets]; entry; ) {
EHEntry *next = entry->next;
hash = EHASH_hash(eh, entry->key);
@@ -125,12 +128,12 @@ static void _ehash_insert(EHash *eh, EHEntry *entry)
static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r)
{
int hash = EHASH_hash(eh, key);
- void **prevp = (void**) &eh->buckets[hash];
+ void **prevp = (void **) &eh->buckets[hash];
EHEntry *entry;
- for (; (entry = *prevp); prevp = (void**) &entry->next) {
+ for (; (entry = *prevp); prevp = (void **) &entry->next) {
if (entry->key == key) {
- *prevp_r = (void**) prevp;
+ *prevp_r = (void **) prevp;
return entry;
}
}
@@ -279,7 +282,7 @@ static int VertDataEqual(const float *a, const float *b)
#define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; }
#define VertDataAdd(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
#define VertDataSub(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; }
-#define VertDataMulN(av, n) { float *_a = (float *)av; _a[0]*=n; _a[1]*=n; _a[2] *=n; }
+#define VertDataMulN(av, n) { float *_a = (float *)av; float _n = n; _a[0] *= _n; _a[1] *= _n; _a[2] *= _n; }
#define VertDataAvg4(tv, av, bv, cv, dv) \
{ \
float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \
@@ -291,9 +294,6 @@ static int VertDataEqual(const float *a, const float *b)
#define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; }
#define NormAdd(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
-
-static int _edge_isBoundary(const CCGEdge *e);
-
/***/
enum {
@@ -309,8 +309,8 @@ enum {
} /*FaceFlags*/;
struct CCGVert {
- CCGVert *next; /* EHData.next */
- CCGVertHDL vHDL; /* EHData.key */
+ CCGVert *next; /* EHData.next */
+ CCGVertHDL vHDL; /* EHData.key */
short numEdges, numFaces, flags, pad;
@@ -322,17 +322,17 @@ struct CCGVert {
static CCG_INLINE byte *VERT_getLevelData(CCGVert *v)
{
- return (byte*)(&(v)[1]);
+ return (byte *)(&(v)[1]);
}
struct CCGEdge {
- CCGEdge *next; /* EHData.next */
- CCGEdgeHDL eHDL; /* EHData.key */
+ CCGEdge *next; /* EHData.next */
+ CCGEdgeHDL eHDL; /* EHData.key */
short numFaces, flags;
float crease;
- CCGVert *v0,*v1;
+ CCGVert *v0, *v1;
CCGFace **faces;
// byte *levelData;
@@ -341,12 +341,12 @@ struct CCGEdge {
static CCG_INLINE byte *EDGE_getLevelData(CCGEdge *e)
{
- return (byte*)(&(e)[1]);
+ return (byte *)(&(e)[1]);
}
struct CCGFace {
- CCGFace *next; /* EHData.next */
- CCGFaceHDL fHDL; /* EHData.key */
+ CCGFace *next; /* EHData.next */
+ CCGFaceHDL fHDL; /* EHData.key */
short numVerts, flags, pad1, pad2;
@@ -359,17 +359,17 @@ struct CCGFace {
static CCG_INLINE CCGVert **FACE_getVerts(CCGFace *f)
{
- return (CCGVert**)(&f[1]);
+ return (CCGVert **)(&f[1]);
}
static CCG_INLINE CCGEdge **FACE_getEdges(CCGFace *f)
{
- return (CCGEdge**)(&(FACE_getVerts(f)[f->numVerts]));
+ return (CCGEdge **)(&(FACE_getVerts(f)[f->numVerts]));
}
static CCG_INLINE byte *FACE_getCenterData(CCGFace *f)
{
- return (byte*)(&(FACE_getEdges(f)[(f)->numVerts]));
+ return (byte *)(&(FACE_getEdges(f)[(f)->numVerts]));
}
typedef enum {
@@ -381,9 +381,9 @@ typedef enum {
} SyncState;
struct CCGSubSurf {
- EHash *vMap; /* map of CCGVertHDL -> Vert */
- EHash *eMap; /* map of CCGEdgeHDL -> Edge */
- EHash *fMap; /* map of CCGFaceHDL -> Face */
+ EHash *vMap; /* map of CCGVertHDL -> Vert */
+ EHash *eMap; /* map of CCGEdgeHDL -> Edge */
+ EHash *fMap; /* map of CCGFaceHDL -> Face */
CCGMeshIFC meshIFC;
@@ -398,18 +398,18 @@ struct CCGSubSurf {
void *q, *r;
- // data for calc vert normals
+ /* data for calc vert normals */
int calcVertNormals;
int normalDataOffset;
- // data for age'ing (to debug sync)
+ /* data for age'ing (to debug sync) */
int currentAge;
int useAgeCounts;
int vertUserAgeOffset;
int edgeUserAgeOffset;
int faceUserAgeOffset;
- // data used during syncing
+ /* data used during syncing */
SyncState syncState;
EHash *oldVMap, *oldEMap, *oldFMap;
@@ -418,9 +418,9 @@ struct CCGSubSurf {
CCGEdge **tempEdges;
};
-#define CCGSUBSURF_alloc(ss, nb) ((ss)->allocatorIFC.alloc((ss)->allocator, nb))
-#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob))
-#define CCGSUBSURF_free(ss, ptr) ((ss)->allocatorIFC.free((ss)->allocator, ptr))
+#define CCGSUBSURF_alloc(ss, nb) ((ss)->allocatorIFC.alloc((ss)->allocator, nb))
+#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob))
+#define CCGSUBSURF_free(ss, ptr) ((ss)->allocatorIFC.free((ss)->allocator, ptr))
/***/
@@ -428,9 +428,9 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
{
int num_vert_data = ss->subdivLevels + 1;
CCGVert *v = CCGSUBSURF_alloc(ss,
- sizeof(CCGVert) +
- ss->meshIFC.vertDataSize * num_vert_data +
- ss->meshIFC.vertUserSize);
+ sizeof(CCGVert) +
+ ss->meshIFC.vertDataSize * num_vert_data +
+ ss->meshIFC.vertUserSize);
byte *userData;
v->vHDL = vHDL;
@@ -441,7 +441,7 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
userData = ccgSubSurf_getVertUserData(ss, v);
memset(userData, 0, ss->meshIFC.vertUserSize);
- if (ss->useAgeCounts) *((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
+ if (ss->useAgeCounts) *((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
return v;
}
@@ -541,7 +541,7 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas
userData = ccgSubSurf_getEdgeUserData(ss, e);
memset(userData, 0, ss->meshIFC.edgeUserSize);
- if (ss->useAgeCounts) *((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
+ if (ss->useAgeCounts) *((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
return e;
}
@@ -562,7 +562,7 @@ static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss)
}
static int _edge_isBoundary(const CCGEdge *e)
{
- return e->numFaces<2;
+ return e->numFaces < 2;
}
static CCGVert *_edge_getOtherVert(CCGEdge *e, CCGVert *vQ)
@@ -626,11 +626,11 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int
{
int maxGridSize = ccg_gridsize(ss->subdivLevels);
int num_face_data = (numVerts * maxGridSize +
- numVerts * maxGridSize * maxGridSize + 1);
+ numVerts * maxGridSize * maxGridSize + 1);
CCGFace *f = CCGSUBSURF_alloc(ss,
sizeof(CCGFace) +
- sizeof(CCGVert*) * numVerts +
- sizeof(CCGEdge*) * numVerts +
+ sizeof(CCGVert *) * numVerts +
+ sizeof(CCGEdge *) * numVerts +
ss->meshIFC.vertDataSize * num_face_data +
ss->meshIFC.faceUserSize);
byte *userData;
@@ -649,7 +649,7 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int
userData = ccgSubSurf_getFaceUserData(ss, f);
memset(userData, 0, ss->meshIFC.faceUserSize);
- if (ss->useAgeCounts) *((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
+ if (ss->useAgeCounts) *((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
return f;
}
@@ -690,30 +690,36 @@ static int _face_getVertIndex(CCGFace *f, CCGVert *v)
return i;
return -1;
}
-static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize)
+static int _face_getEdgeIndex(CCGFace *f, CCGEdge *e)
+{
+ int i;
+ for (i = 0; i < f->numVerts; i++)
+ if (FACE_getEdges(f)[i] == e)
+ return i;
+ return -1;
+}
+static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int f_ed_idx, int lvl, int eX, int eY, int levels, int dataSize)
{
int maxGridSize = ccg_gridsize(levels);
int spacing = ccg_spacing(levels, lvl);
- int S, x, y, cx, cy;
+ int x, y, cx, cy;
- for (S = 0; S < f->numVerts; S++)
- if (FACE_getEdges(f)[S] == e)
- break;
+ BLI_assert(f_ed_idx == _face_getEdgeIndex(f, e));
eX = eX * spacing;
eY = eY * spacing;
- if (e->v0!=FACE_getVerts(f)[S]) {
+ if (e->v0 != FACE_getVerts(f)[f_ed_idx]) {
eX = (maxGridSize * 2 - 1) - 1 - eX;
}
y = maxGridSize - 1 - eX;
x = maxGridSize - 1 - eY;
- if (x<0) {
- S = (S + f->numVerts - 1) % f->numVerts;
+ if (x < 0) {
+ f_ed_idx = (f_ed_idx + f->numVerts - 1) % f->numVerts;
cx = y;
cy = -x;
}
else if (y < 0) {
- S = (S + 1) % f->numVerts;
+ f_ed_idx = (f_ed_idx + 1) % f->numVerts;
cx = -y;
cy = x;
}
@@ -721,11 +727,11 @@ static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int e
cx = x;
cy = y;
}
- return _face_getIFCo(f, levels, S, cx, cy, levels, dataSize);
+ return _face_getIFCo(f, levels, f_ed_idx, cx, cy, levels, dataSize);
}
-static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset)
+static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int f_ed_idx, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset)
{
- return (float *) ((byte *) _face_getIFCoEdge(f, e, lvl, eX, eY, levels, dataSize) + normalDataOffset);
+ return (float *) ((byte *) _face_getIFCoEdge(f, e, f_ed_idx, lvl, eX, eY, levels, dataSize) + normalDataOffset);
}
static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize)
{
@@ -733,8 +739,8 @@ static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no,
float *b = _face_getIFCo(f, lvl, S, x + 1, y + 0, levels, dataSize);
float *c = _face_getIFCo(f, lvl, S, x + 1, y + 1, levels, dataSize);
float *d = _face_getIFCo(f, lvl, S, x + 0, y + 1, levels, dataSize);
- float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
- float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
+ float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
+ float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
float length;
no[0] = b_dY * a_cZ - b_dZ * a_cY;
@@ -779,7 +785,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
allocator = NULL;
}
- if (subdivLevels<1) {
+ if (subdivLevels < 1) {
return NULL;
}
else {
@@ -881,10 +887,10 @@ void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss, int *allowEdgeCreation_r, f
CCGError ccgSubSurf_setSubdivisionLevels(CCGSubSurf *ss, int subdivisionLevels)
{
- if (subdivisionLevels<=0) {
+ if (subdivisionLevels <= 0) {
return eCCGError_InvalidValue;
}
- else if (subdivisionLevels!=ss->subdivLevels) {
+ else if (subdivisionLevels != ss->subdivLevels) {
ss->numGrids = 0;
ss->subdivLevels = subdivisionLevels;
_ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss);
@@ -934,7 +940,7 @@ CCGError ccgSubSurf_setUseAgeCounts(CCGSubSurf *ss, int useAgeCounts, int vertUs
CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int normalDataOffset)
{
if (useVertNormals) {
- if (normalDataOffset<0 || normalDataOffset + 12>ss->meshIFC.vertDataSize) {
+ if (normalDataOffset < 0 || normalDataOffset + 12 > ss->meshIFC.vertDataSize) {
return eCCGError_InvalidValue;
}
else {
@@ -954,7 +960,7 @@ CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int
CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
{
- if (ss->syncState!=eSyncState_None) {
+ if (ss->syncState != eSyncState_None) {
return eCCGError_InvalidSyncState;
}
@@ -981,7 +987,7 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss)
{
- if (ss->syncState!=eSyncState_None) {
+ if (ss->syncState != eSyncState_None) {
return eCCGError_InvalidSyncState;
}
@@ -994,7 +1000,7 @@ CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss)
CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL)
{
- if (ss->syncState!=eSyncState_Partial) {
+ if (ss->syncState != eSyncState_Partial) {
return eCCGError_InvalidSyncState;
}
else {
@@ -1015,7 +1021,7 @@ CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL)
CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL)
{
- if (ss->syncState!=eSyncState_Partial) {
+ if (ss->syncState != eSyncState_Partial) {
return eCCGError_InvalidSyncState;
}
else {
@@ -1036,7 +1042,7 @@ CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL)
CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL)
{
- if (ss->syncState!=eSyncState_Partial) {
+ if (ss->syncState != eSyncState_Partial) {
return eCCGError_InvalidSyncState;
}
else {
@@ -1059,21 +1065,21 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
{
void **prevp;
CCGVert *v = NULL;
- short seamflag = (seam)? Vert_eSeam: 0;
+ short seamflag = (seam) ? Vert_eSeam : 0;
if (ss->syncState == eSyncState_Partial) {
v = _ehash_lookupWithPrev(ss->vMap, vHDL, &prevp);
if (!v) {
v = _vert_new(vHDL, ss);
- VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
- _ehash_insert(ss->vMap, (EHEntry*) v);
- v->flags = Vert_eEffected|seamflag;
+ VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
+ _ehash_insert(ss->vMap, (EHEntry *) v);
+ v->flags = Vert_eEffected | seamflag;
}
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) {
int i, j;
- VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
- v->flags = Vert_eEffected|seamflag;
+ VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
+ v->flags = Vert_eEffected | seamflag;
for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
@@ -1089,26 +1095,26 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
}
}
else {
- if (ss->syncState!=eSyncState_Vert) {
+ if (ss->syncState != eSyncState_Vert) {
return eCCGError_InvalidSyncState;
}
v = _ehash_lookupWithPrev(ss->oldVMap, vHDL, &prevp);
if (!v) {
v = _vert_new(vHDL, ss);
- VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
- _ehash_insert(ss->vMap, (EHEntry*) v);
- v->flags = Vert_eEffected|seamflag;
+ VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
+ _ehash_insert(ss->vMap, (EHEntry *) v);
+ v->flags = Vert_eEffected | seamflag;
}
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) {
*prevp = v->next;
- _ehash_insert(ss->vMap, (EHEntry*) v);
- VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
- v->flags = Vert_eEffected|Vert_eChanged|seamflag;
+ _ehash_insert(ss->vMap, (EHEntry *) v);
+ VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
+ v->flags = Vert_eEffected | Vert_eChanged | seamflag;
}
else {
*prevp = v->next;
- _ehash_insert(ss->vMap, (EHEntry*) v);
+ _ehash_insert(ss->vMap, (EHEntry *) v);
v->flags = 0;
}
}
@@ -1124,7 +1130,7 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
if (ss->syncState == eSyncState_Partial) {
e = _ehash_lookupWithPrev(ss->eMap, eHDL, &prevp);
- if (!e || e->v0->vHDL!=e_vHDL0 || e->v1->vHDL!=e_vHDL1 || crease!=e->crease) {
+ if (!e || e->v0->vHDL != e_vHDL0 || e->v1->vHDL != e_vHDL1 || crease != e->crease) {
CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0);
CCGVert *v1 = _ehash_lookup(ss->vMap, e_vHDL1);
@@ -1137,7 +1143,7 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
_edge_unlinkMarkAndFree(e, ss);
}
else {
- _ehash_insert(ss->eMap, (EHEntry*) eNew);
+ _ehash_insert(ss->eMap, (EHEntry *) eNew);
}
eNew->v0->flags |= Vert_eEffected;
@@ -1148,24 +1154,24 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
if (ss->syncState == eSyncState_Vert) {
ss->syncState = eSyncState_Edge;
}
- else if (ss->syncState!=eSyncState_Edge) {
+ else if (ss->syncState != eSyncState_Edge) {
return eCCGError_InvalidSyncState;
}
e = _ehash_lookupWithPrev(ss->oldEMap, eHDL, &prevp);
- if (!e || e->v0->vHDL!=e_vHDL0 || e->v1->vHDL!=e_vHDL1|| e->crease!=crease) {
+ if (!e || e->v0->vHDL != e_vHDL0 || e->v1->vHDL != e_vHDL1 || e->crease != crease) {
CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0);
CCGVert *v1 = _ehash_lookup(ss->vMap, e_vHDL1);
e = _edge_new(eHDL, v0, v1, crease, ss);
- _ehash_insert(ss->eMap, (EHEntry*) e);
+ _ehash_insert(ss->eMap, (EHEntry *) e);
e->v0->flags |= Vert_eEffected;
e->v1->flags |= Vert_eEffected;
}
else {
*prevp = e->next;
- _ehash_insert(ss->eMap, (EHEntry*) e);
+ _ehash_insert(ss->eMap, (EHEntry *) e);
e->flags = 0;
- if ((e->v0->flags|e->v1->flags)&Vert_eChanged) {
+ if ((e->v0->flags | e->v1->flags) & Vert_eChanged) {
e->v0->flags |= Vert_eEffected;
e->v1->flags |= Vert_eEffected;
}
@@ -1199,10 +1205,12 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
}
if (f) {
- if ( f->numVerts!=numVerts ||
- memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
- memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
+ if (f->numVerts != numVerts ||
+ memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
+ memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
+ {
topologyChanged = 1;
+ }
}
if (!f || topologyChanged) {
@@ -1218,7 +1226,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
}
else {
ss->numGrids += numVerts;
- _ehash_insert(ss->fMap, (EHEntry*) fNew);
+ _ehash_insert(ss->fMap, (EHEntry *) fNew);
}
for (k = 0; k < numVerts; k++)
@@ -1229,7 +1237,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
if (ss->syncState == eSyncState_Vert || ss->syncState == eSyncState_Edge) {
ss->syncState = eSyncState_Face;
}
- else if (ss->syncState!=eSyncState_Face) {
+ else if (ss->syncState != eSyncState_Face) {
return eCCGError_InvalidSyncState;
}
@@ -1246,8 +1254,8 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
if (!ss->tempEdges[k]) {
if (ss->allowEdgeCreation) {
- CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) -1, ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts], ss->defaultCreaseValue, ss);
- _ehash_insert(ss->eMap, (EHEntry*) e);
+ CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) - 1, ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts], ss->defaultCreaseValue, ss);
+ _ehash_insert(ss->eMap, (EHEntry *) e);
e->v0->flags |= Vert_eEffected;
e->v1->flags |= Vert_eEffected;
if (ss->meshIFC.edgeUserSize) {
@@ -1261,15 +1269,17 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
}
if (f) {
- if ( f->numVerts!=numVerts ||
- memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
- memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
+ if (f->numVerts != numVerts ||
+ memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
+ memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
+ {
topologyChanged = 1;
+ }
}
if (!f || topologyChanged) {
f = _face_new(fHDL, ss->tempVerts, ss->tempEdges, numVerts, ss);
- _ehash_insert(ss->fMap, (EHEntry*) f);
+ _ehash_insert(ss->fMap, (EHEntry *) f);
ss->numGrids += numVerts;
for (k = 0; k < numVerts; k++)
@@ -1277,7 +1287,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
}
else {
*prevp = f->next;
- _ehash_insert(ss->fMap, (EHEntry*) f);
+ _ehash_insert(ss->fMap, (EHEntry *) f);
f->flags = 0;
ss->numGrids += f->numVerts;
@@ -1295,7 +1305,6 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
return eCCGError_None;
}
-static void ccgSubSurf__sync(CCGSubSurf *ss);
CCGError ccgSubSurf_processSync(CCGSubSurf *ss)
{
if (ss->syncState == eSyncState_Partial) {
@@ -1327,15 +1336,17 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss)
return eCCGError_None;
}
-#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset)
-#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
-#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
-#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
-#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
+#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset)
+#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
+#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
+#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
+#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
+
static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
- CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
- int numEffectedV, int numEffectedE, int numEffectedF) {
- int i,ptrIdx;
+ CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
+ int numEffectedV, int numEffectedE, int numEffectedF)
+{
+ int i, ptrIdx;
int subdivLevels = ss->subdivLevels;
int lvl = ss->subdivLevels;
int edgeSize = ccg_edgesize(lvl);
@@ -1345,7 +1356,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
- CCGFace *f = (CCGFace*) effectedF[ptrIdx];
+ CCGFace *f = (CCGFace *) effectedF[ptrIdx];
int S, x, y;
float no[3];
@@ -1354,19 +1365,19 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
for (x = 0; x < gridSize - 1; x++)
NormZero(FACE_getIFNo(f, lvl, S, x, y));
- if (FACE_getEdges(f)[(S - 1+f->numVerts)%f->numVerts]->flags&Edge_eEffected)
+ if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected)
for (x = 0; x < gridSize - 1; x++)
NormZero(FACE_getIFNo(f, lvl, S, x, gridSize - 1));
- if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
+ if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
for (y = 0; y < gridSize - 1; y++)
NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y));
- if (FACE_getVerts(f)[S]->flags&Vert_eEffected)
+ if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, gridSize - 1));
}
for (S = 0; S < f->numVerts; S++) {
int yLimit = !(FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected);
- int xLimit = !(FACE_getEdges(f)[S]->flags&Edge_eEffected);
+ int xLimit = !(FACE_getEdges(f)[S]->flags & Edge_eEffected);
int yLimitNext = xLimit;
int xLimitPrev = yLimit;
@@ -1391,13 +1402,13 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
if (x == 0 && y == 0) {
int K;
- if (!yLimitNext || 1<gridSize - 1)
+ if (!yLimitNext || 1 < gridSize - 1)
NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, 1), no);
- if (!xLimitPrev || 1<gridSize - 1)
+ if (!xLimitPrev || 1 < gridSize - 1)
NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, 1, 0), no);
for (K = 0; K < f->numVerts; K++) {
- if (K!=S) {
+ if (K != S) {
NormAdd(FACE_getIFNo(f, lvl, K, 0, 0), no);
}
}
@@ -1416,22 +1427,22 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
}
}
}
- // XXX can I reduce the number of normalisations here?
+ /* XXX can I reduce the number of normalisations here? */
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
- CCGVert *v = (CCGVert*) effectedV[ptrIdx];
+ CCGVert *v = (CCGVert *) effectedV[ptrIdx];
float length, *no = _vert_getNo(v, lvl, vertDataSize, normalDataOffset);
NormZero(no);
for (i = 0; i < v->numFaces; i++) {
CCGFace *f = v->faces[i];
- NormAdd(no, FACE_getIFNo(f, lvl, _face_getVertIndex(f,v), gridSize - 1, gridSize - 1));
+ NormAdd(no, FACE_getIFNo(f, lvl, _face_getVertIndex(f, v), gridSize - 1, gridSize - 1));
}
length = sqrtf(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
if (length > EPSILON) {
- float invLength = 1.0f/length;
+ float invLength = 1.0f / length;
no[0] *= invLength;
no[1] *= invLength;
no[2] *= invLength;
@@ -1442,11 +1453,11 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
for (i = 0; i < v->numFaces; i++) {
CCGFace *f = v->faces[i];
- NormCopy(FACE_getIFNo(f, lvl, _face_getVertIndex(f,v), gridSize - 1, gridSize - 1), no);
+ NormCopy(FACE_getIFNo(f, lvl, _face_getVertIndex(f, v), gridSize - 1, gridSize - 1), no);
}
}
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
- CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
+ CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
if (e->numFaces) {
CCGFace *fLast = e->faces[e->numFaces - 1];
@@ -1454,19 +1465,23 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
for (i = 0; i < e->numFaces - 1; i++) {
CCGFace *f = e->faces[i];
+ const int f_ed_idx = _face_getEdgeIndex(f, e);
+ const int f_ed_idx_last = _face_getEdgeIndex(fLast, e);
for (x = 1; x < edgeSize - 1; x++) {
- NormAdd(_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
- _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+ NormAdd(_face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
+ _face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
}
}
for (i = 0; i < e->numFaces - 1; i++) {
CCGFace *f = e->faces[i];
+ const int f_ed_idx = _face_getEdgeIndex(f, e);
+ const int f_ed_idx_last = _face_getEdgeIndex(fLast, e);
for (x = 1; x < edgeSize - 1; x++) {
- NormCopy(_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
- _face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+ NormCopy(_face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
+ _face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
}
}
}
@@ -1474,7 +1489,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
- CCGFace *f = (CCGFace*) effectedF[ptrIdx];
+ CCGFace *f = (CCGFace *) effectedF[ptrIdx];
int S, x, y;
for (S = 0; S < f->numVerts; S++) {
@@ -1489,7 +1504,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
float length = sqrtf(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
if (length > EPSILON) {
- float invLength = 1.0f/length;
+ float invLength = 1.0f / length;
no[0] *= invLength;
no[1] *= invLength;
no[2] *= invLength;
@@ -1501,24 +1516,25 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
}
VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset),
- FACE_getIFNo(f, lvl, S, 0, 0));
+ FACE_getIFNo(f, lvl, S, 0, 0));
for (x = 1; x < gridSize - 1; x++)
NormCopy(FACE_getIENo(f, lvl, S, x),
- FACE_getIFNo(f, lvl, S, x, 0));
+ FACE_getIFNo(f, lvl, S, x, 0));
}
}
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
- CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
+ CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
if (e->numFaces) {
CCGFace *f = e->faces[0];
int x;
+ const int f_ed_idx = _face_getEdgeIndex(f, e);
for (x = 0; x < edgeSize; x++)
NormCopy(EDGE_getNo(e, lvl, x),
- _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+ _face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
}
else {
/* set to zero here otherwise the normals are uninitialized memory
@@ -1535,10 +1551,10 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
}
#undef FACE_getIFNo
-#define VERT_getCo(v, lvl) _vert_getCo(v, lvl, vertDataSize)
-#define EDGE_getCo(e, lvl, x) _edge_getCo(e, lvl, x, vertDataSize)
-#define FACE_getIECo(f, lvl, S, x) _face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize)
-#define FACE_getIFCo(f, lvl, S, x, y) _face_getIFCo(f, lvl, S, x, y, subdivLevels, vertDataSize)
+#define VERT_getCo(v, lvl) _vert_getCo(v, lvl, vertDataSize)
+#define EDGE_getCo(e, lvl, x) _edge_getCo(e, lvl, x, vertDataSize)
+#define FACE_getIECo(f, lvl, S, x) _face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize)
+#define FACE_getIFCo(f, lvl, S, x, y) _face_getIFCo(f, lvl, S, x, y, subdivLevels, vertDataSize)
static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
@@ -1554,17 +1570,17 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
- CCGFace *f = (CCGFace*) effectedF[ptrIdx];
+ CCGFace *f = (CCGFace *) effectedF[ptrIdx];
int S, x, y;
- /* interior face midpoints
- * o old interior face points
- */
+ /* interior face midpoints
+ * - old interior face points
+ */
for (S = 0; S < f->numVerts; S++) {
for (y = 0; y < gridSize - 1; y++) {
for (x = 0; x < gridSize - 1; x++) {
- int fx = 1 + 2*x;
- int fy = 1 + 2*y;
+ int fx = 1 + 2 * x;
+ int fy = 1 + 2 * y;
void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0);
void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0);
void *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1);
@@ -1576,10 +1592,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- /* interior edge midpoints
- * o old interior edge points
- * o new interior face midpoints
- */
+ /* interior edge midpoints
+ * - old interior edge points
+ * - new interior face midpoints
+ */
for (S = 0; S < f->numVerts; S++) {
for (x = 0; x < gridSize - 1; x++) {
int fx = x * 2 + 1;
@@ -1592,12 +1608,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataAvg4(co, co0, co1, co2, co3);
}
- /* interior face interior edge midpoints
- * o old interior face points
- * o new interior face midpoints
- */
+ /* interior face interior edge midpoints
+ * - old interior face points
+ * - new interior face midpoints
+ */
- /* vertical */
+ /* vertical */
for (x = 1; x < gridSize - 1; x++) {
for (y = 0; y < gridSize - 1; y++) {
int fx = x * 2;
@@ -1612,7 +1628,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- /* horizontal */
+ /* horizontal */
for (y = 1; y < gridSize - 1; y++) {
for (x = 0; x < gridSize - 1; x++) {
int fx = x * 2 + 1;
@@ -1629,12 +1645,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- /* exterior edge midpoints
- * o old exterior edge points
- * o new interior face midpoints
- */
+ /* exterior edge midpoints
+ * - old exterior edge points
+ * - new interior face midpoints
+ */
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
- CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
+ CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
float sharpness = EDGE_getSharpness(e, curLvl);
int x, j;
@@ -1663,7 +1679,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
for (j = 0; j < e->numFaces; j++) {
CCGFace *f = e->faces[j];
- VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx, 1, subdivLevels, vertDataSize));
+ const int f_ed_idx = _face_getEdgeIndex(f, e);
+ VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx, 1, subdivLevels, vertDataSize));
numFaces++;
}
@@ -1681,13 +1698,13 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- /* exterior vertex shift
- * o old vertex points (shifting)
- * o old exterior edge points
- * o new interior face midpoints
- */
+ /* exterior vertex shift
+ * - old vertex points (shifting)
+ * - old exterior edge points
+ * - new interior face midpoints
+ */
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
- CCGVert *v = (CCGVert*) effectedV[ptrIdx];
+ CCGVert *v = (CCGVert *) effectedV[ptrIdx];
void *co = VERT_getCo(v, curLvl);
void *nCo = VERT_getCo(v, nextLvl);
int sharpCount = 0, allSharp = 1;
@@ -1701,7 +1718,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if (seam && _edge_isBoundary(e))
seamEdges++;
- if (sharpness!=0.0f) {
+ if (sharpness != 0.0f) {
sharpCount++;
avgSharpness += sharpness;
}
@@ -1737,7 +1754,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataCopy(nCo, co);
VertDataMulN(nCo, 0.75f);
- VertDataMulN(r, 0.25f/numBoundary);
+ VertDataMulN(r, 0.25f / numBoundary);
VertDataAdd(nCo, r);
}
else {
@@ -1747,26 +1764,26 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataZero(q);
for (j = 0; j < v->numFaces; j++) {
CCGFace *f = v->faces[j];
- VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f,v), cornerIdx, cornerIdx));
+ VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx));
numFaces++;
}
- VertDataMulN(q, 1.0f/numFaces);
+ VertDataMulN(q, 1.0f / numFaces);
VertDataZero(r);
for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
- VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1,vertDataSize));
+ VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
numEdges++;
}
- VertDataMulN(r, 1.0f/numEdges);
+ VertDataMulN(r, 1.0f / numEdges);
VertDataCopy(nCo, co);
VertDataMulN(nCo, numEdges - 2.0f);
VertDataAdd(nCo, q);
VertDataAdd(nCo, r);
- VertDataMulN(nCo, 1.0f/numEdges);
+ VertDataMulN(nCo, 1.0f / numEdges);
}
- if ((sharpCount>1 && v->numFaces) || seam) {
+ if ((sharpCount > 1 && v->numFaces) || seam) {
VertDataZero(q);
if (seam) {
@@ -1788,42 +1805,42 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- VertDataMulN(q, (float) 1/sharpCount);
+ VertDataMulN(q, (float) 1 / sharpCount);
- if (sharpCount!=2 || allSharp) {
- // q = q + (co-q) * avgSharpness
+ if (sharpCount != 2 || allSharp) {
+ /* q = q + (co - q) * avgSharpness */
VertDataCopy(r, co);
VertDataSub(r, q);
VertDataMulN(r, avgSharpness);
VertDataAdd(q, r);
}
- // r = co*.75 + q*.25
+ /* r = co * 0.75 + q * 0.25 */
VertDataCopy(r, co);
VertDataMulN(r, .75f);
VertDataMulN(q, .25f);
VertDataAdd(r, q);
- // nCo = nCo + (r-nCo) * avgSharpness
+ /* nCo = nCo + (r - nCo) * avgSharpness */
VertDataSub(r, nCo);
VertDataMulN(r, avgSharpness);
VertDataAdd(nCo, r);
}
}
- /* exterior edge interior shift
- * o old exterior edge midpoints (shifting)
- * o old exterior edge midpoints
- * o new interior face midpoints
- */
+ /* exterior edge interior shift
+ * - old exterior edge midpoints (shifting)
+ * - old exterior edge midpoints
+ * - new interior face midpoints
+ */
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
- CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
+ CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
float sharpness = EDGE_getSharpness(e, curLvl);
int sharpCount = 0;
float avgSharpness = 0.0;
int x, j;
- if (sharpness!=0.0f) {
+ if (sharpness != 0.0f) {
sharpCount = 2;
avgSharpness += sharpness;
@@ -1836,7 +1853,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
avgSharpness = 0;
}
- if (_edge_isBoundary(e) && (!e->numFaces || sharpCount<2)) {
+ if (_edge_isBoundary(e) && (!e->numFaces || sharpCount < 2)) {
for (x = 1; x < edgeSize - 1; x++) {
int fx = x * 2;
void *co = EDGE_getCo(e, curLvl, x);
@@ -1863,10 +1880,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1));
for (j = 0; j < e->numFaces; j++) {
CCGFace *f = e->faces[j];
- VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx - 1, 1, subdivLevels, vertDataSize));
- VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx + 1, 1, subdivLevels, vertDataSize));
+ int f_ed_idx = _face_getEdgeIndex(f, e);
+ VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx - 1, 1, subdivLevels, vertDataSize));
+ VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx + 1, 1, subdivLevels, vertDataSize));
- VertDataAdd(r, _face_getIFCoEdge(f, e, curLvl, x, 1, subdivLevels, vertDataSize));
+ VertDataAdd(r, _face_getIFCoEdge(f, e, f_ed_idx, curLvl, x, 1, subdivLevels, vertDataSize));
numFaces++;
}
VertDataMulN(q, 1.0f / (numFaces * 2.0f));
@@ -1883,7 +1901,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataMulN(q, 6.0f);
VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1));
VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1));
- VertDataMulN(q, 1/8.0f);
+ VertDataMulN(q, 1 / 8.0f);
VertDataSub(q, nCo);
VertDataMulN(q, avgSharpness);
@@ -1905,36 +1923,36 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
#pragma omp for schedule(static)
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
- CCGFace *f = (CCGFace*) effectedF[ptrIdx];
+ CCGFace *f = (CCGFace *) effectedF[ptrIdx];
int S, x, y;
- /* interior center point shift
- * o old face center point (shifting)
- * o old interior edge points
- * o new interior face midpoints
- */
+ /* interior center point shift
+ * - old face center point (shifting)
+ * - old interior edge points
+ * - new interior face midpoints
+ */
VertDataZero(q);
for (S = 0; S < f->numVerts; S++) {
VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1));
}
- VertDataMulN(q, 1.0f/f->numVerts);
+ VertDataMulN(q, 1.0f / f->numVerts);
VertDataZero(r);
for (S = 0; S < f->numVerts; S++) {
VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1));
}
- VertDataMulN(r, 1.0f/f->numVerts);
+ VertDataMulN(r, 1.0f / f->numVerts);
VertDataMulN(FACE_getCenterData(f), f->numVerts - 2.0f);
VertDataAdd(FACE_getCenterData(f), q);
VertDataAdd(FACE_getCenterData(f), r);
- VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
+ VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts);
for (S = 0; S < f->numVerts; S++) {
- /* interior face shift
- * o old interior face point (shifting)
- * o new interior edge midpoints
- * o new interior face midpoints
- */
+ /* interior face shift
+ * - old interior face point (shifting)
+ * - new interior edge midpoints
+ * - new interior face midpoints
+ */
for (x = 1; x < gridSize - 1; x++) {
for (y = 1; y < gridSize - 1; y++) {
int fx = x * 2;
@@ -1961,11 +1979,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- /* interior edge interior shift
- * o old interior edge point (shifting)
- * o new interior edge midpoints
- * o new interior face midpoints
- */
+ /* interior edge interior shift
+ * - old interior edge point (shifting)
+ * - new interior edge midpoints
+ * - new interior face midpoints
+ */
for (x = 1; x < gridSize - 1; x++) {
int fx = x * 2;
void *co = FACE_getIECo(f, curLvl, S, x);
@@ -1974,8 +1992,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataAvg4(q,
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1),
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1),
- FACE_getIFCo(f, nextLvl, S, fx + 1, + 1),
- FACE_getIFCo(f, nextLvl, S, fx - 1, + 1));
+ FACE_getIFCo(f, nextLvl, S, fx + 1, +1),
+ FACE_getIFCo(f, nextLvl, S, fx - 1, +1));
VertDataAvg4(r,
FACE_getIECo(f, nextLvl, S, fx - 1),
@@ -1998,7 +2016,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- /* copy down */
+ /* copy down */
edgeSize = ccg_edgesize(nextLvl);
gridSize = ccg_gridsize(nextLvl);
cornerIdx = gridSize - 1;
@@ -2030,8 +2048,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
for (x = 0; x < gridSize - 1; x++) {
int eI = gridSize - 1 - x;
- VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI,vertDataSize));
- VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI,vertDataSize));
+ VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize));
+ VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize));
}
}
}
@@ -2055,14 +2073,14 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
effectedF = MEM_mallocN(sizeof(*effectedF) * ss->fMap->numEntries, "CCGSubsurf effectedF");
numEffectedV = numEffectedE = numEffectedF = 0;
for (i = 0; i < ss->vMap->curSize; i++) {
- CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
+ CCGVert *v = (CCGVert *) ss->vMap->buckets[i];
for (; v; v = v->next) {
- if (v->flags&Vert_eEffected) {
+ if (v->flags & Vert_eEffected) {
effectedV[numEffectedV++] = v;
for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
- if (!(e->flags&Edge_eEffected)) {
+ if (!(e->flags & Edge_eEffected)) {
effectedE[numEffectedE++] = e;
e->flags |= Edge_eEffected;
}
@@ -2070,7 +2088,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
for (j = 0; j < v->numFaces; j++) {
CCGFace *f = v->faces[j];
- if (!(f->flags&Face_eEffected)) {
+ if (!(f->flags & Face_eEffected)) {
effectedF[numEffectedF++] = f;
f->flags |= Face_eEffected;
}
@@ -2089,7 +2107,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
for (i = 0; i < f->numVerts; i++) {
VertDataAdd(co, VERT_getCo(FACE_getVerts(f)[i], curLvl));
}
- VertDataMulN(co, 1.0f/f->numVerts);
+ VertDataMulN(co, 1.0f / f->numVerts);
f->flags = 0;
}
@@ -2141,7 +2159,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
if (seam && _edge_isBoundary(e))
seamEdges++;
- if (sharpness!=0.0f) {
+ if (sharpness != 0.0f) {
sharpCount++;
avgSharpness += sharpness;
}
@@ -2176,7 +2194,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
}
VertDataCopy(nCo, co);
VertDataMulN(nCo, 0.75f);
- VertDataMulN(r, 0.25f/numBoundary);
+ VertDataMulN(r, 0.25f / numBoundary);
VertDataAdd(nCo, r);
}
else {
@@ -2188,23 +2206,23 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
VertDataAdd(q, FACE_getCenterData(f));
numFaces++;
}
- VertDataMulN(q, 1.0f/numFaces);
+ VertDataMulN(q, 1.0f / numFaces);
VertDataZero(r);
for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl));
numEdges++;
}
- VertDataMulN(r, 1.0f/numEdges);
+ VertDataMulN(r, 1.0f / numEdges);
VertDataCopy(nCo, co);
VertDataMulN(nCo, numEdges - 2.0f);
VertDataAdd(nCo, q);
VertDataAdd(nCo, r);
- VertDataMulN(nCo, 1.0f/numEdges);
+ VertDataMulN(nCo, 1.0f / numEdges);
}
- if (sharpCount>1 || seam) {
+ if (sharpCount > 1 || seam) {
VertDataZero(q);
if (seam) {
@@ -2229,23 +2247,23 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
}
}
- VertDataMulN(q, (float) 1/sharpCount);
+ VertDataMulN(q, (float) 1 / sharpCount);
- if (sharpCount!=2 || allSharp) {
- // q = q + (co-q) * avgSharpness
+ if (sharpCount != 2 || allSharp) {
+ /* q = q + (co - q) * avgSharpness */
VertDataCopy(r, co);
VertDataSub(r, q);
VertDataMulN(r, avgSharpness);
VertDataAdd(q, r);
}
- // r = co*.75 + q*.25
+ /* r = co * 0.75 + q * 0.25 */
VertDataCopy(r, co);
VertDataMulN(r, 0.75f);
VertDataMulN(q, 0.25f);
VertDataAdd(r, q);
- // nCo = nCo + (r-nCo) * avgSharpness
+ /* nCo = nCo + (r - nCo) * avgSharpness */
VertDataSub(r, nCo);
VertDataMulN(r, avgSharpness);
VertDataAdd(nCo, r);
@@ -2258,19 +2276,19 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
byte *userData = ccgSubSurf_getVertUserData(ss, v);
- *((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
+ *((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
}
for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
byte *userData = ccgSubSurf_getEdgeUserData(ss, e);
- *((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
+ *((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
}
for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
byte *userData = ccgSubSurf_getFaceUserData(ss, f);
- *((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
+ *((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
}
}
@@ -2297,14 +2315,14 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
for (curLvl = 1; curLvl < subdivLevels; curLvl++) {
ccgSubSurf__calcSubdivLevel(ss,
- effectedV, effectedE, effectedF,
- numEffectedV, numEffectedE, numEffectedF, curLvl);
+ effectedV, effectedE, effectedF,
+ numEffectedV, numEffectedE, numEffectedF, curLvl);
}
if (ss->calcVertNormals)
ccgSubSurf__calcVertNormals(ss,
- effectedV, effectedE, effectedF,
- numEffectedV, numEffectedE, numEffectedF);
+ effectedV, effectedE, effectedF,
+ numEffectedV, numEffectedE, numEffectedF);
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = effectedV[ptrIdx];
@@ -2329,7 +2347,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces
array = MEM_mallocN(sizeof(*array) * ss->fMap->numEntries, "CCGSubsurf allFaces");
num = 0;
for (i = 0; i < ss->fMap->curSize; i++) {
- CCGFace *f = (CCGFace*) ss->fMap->buckets[i];
+ CCGFace *f = (CCGFace *) ss->fMap->buckets[i];
for (; f; f = f->next)
array[num++] = f;
@@ -2360,7 +2378,7 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces,
}
for (i = 0; i < ss->vMap->curSize; i++) {
- CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
+ CCGVert *v = (CCGVert *) ss->vMap->buckets[i];
for (; v; v = v->next) {
for (j = 0; j < v->numFaces; j++)
@@ -2375,7 +2393,7 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces,
}
for (i = 0; i < ss->eMap->curSize; i++) {
- CCGEdge *e = (CCGEdge*) ss->eMap->buckets[i];
+ CCGEdge *e = (CCGEdge *) ss->eMap->buckets[i];
for (; e; e = e->next) {
for (j = 0; j < e->numFaces; j++)
@@ -2402,7 +2420,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
int vertDataSize = ss->meshIFC.vertDataSize, freeF;
subdivLevels = ss->subdivLevels;
- lvl = (lvl)? lvl: subdivLevels;
+ lvl = (lvl) ? lvl : subdivLevels;
gridSize = ccg_gridsize(lvl);
cornerIdx = gridSize - 1;
@@ -2423,8 +2441,8 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
for (x = 0; x < gridSize; x++) {
int eI = gridSize - 1 - x;
- VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
- VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
+ VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
+ VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
}
}
}
@@ -2441,7 +2459,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
int vertDataSize = ss->meshIFC.vertDataSize, freeF;
subdivLevels = ss->subdivLevels;
- lvl = (lvl)? lvl: subdivLevels;
+ lvl = (lvl) ? lvl : subdivLevels;
gridSize = ccg_gridsize(lvl);
cornerIdx = gridSize - 1;
@@ -2457,8 +2475,8 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
for (x = 0; x < gridSize; x++) {
int eI = gridSize - 1 - x;
- VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
- VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
+ VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
+ VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
}
for (x = 1; x < gridSize - 1; x++) {
@@ -2487,14 +2505,14 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
int vertDataSize = ss->meshIFC.vertDataSize;
subdivLevels = ss->subdivLevels;
- lvl = (lvl)? lvl: subdivLevels;
+ lvl = (lvl) ? lvl : subdivLevels;
gridSize = ccg_gridsize(lvl);
edgeSize = ccg_edgesize(lvl);
cornerIdx = gridSize - 1;
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
- &effectedV, &numEffectedV, &effectedE, &numEffectedE);
+ &effectedV, &numEffectedV, &effectedE, &numEffectedE);
/* zero */
for (i = 0; i < numEffectedV; i++) {
@@ -2527,7 +2545,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
CCGEdge *prevE = FACE_getEdges(f)[prevS];
VertDataAdd(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0));
- if (FACE_getVerts(f)[S]->flags&Vert_eEffected)
+ if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
for (x = 1; x < gridSize - 1; x++) {
@@ -2537,11 +2555,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
for (x = 0; x < gridSize - 1; x++) {
int eI = gridSize - 1 - x;
- if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
- VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
- if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected)
+ if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
+ VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
+ if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected)
if (x != 0)
- VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
+ VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
}
}
}
@@ -2550,7 +2568,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
if (v->numFaces)
- VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces);
+ VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces);
}
for (i = 0; i < numEffectedE; i++) {
@@ -2561,14 +2579,14 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
if (e->numFaces)
for (x = 1; x < edgeSize - 1; x++)
- VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces);
+ VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces);
}
/* copy */
for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
- VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
+ VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts);
for (S = 0; S < f->numVerts; S++)
for (x = 1; x < gridSize - 1; x++)
@@ -2589,8 +2607,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
for (x = 0; x < gridSize - 1; x++) {
int eI = gridSize - 1 - x;
- VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
- VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
+ VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
+ VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
}
VertDataCopy(FACE_getIECo(f, lvl, S, 0), FACE_getCenterData(f));
@@ -2621,12 +2639,12 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
- &effectedV, &numEffectedV, &effectedE, &numEffectedE);
+ &effectedV, &numEffectedV, &effectedE, &numEffectedE);
if (ss->calcVertNormals)
ccgSubSurf__calcVertNormals(ss,
- effectedV, effectedE, effectedF,
- numEffectedV, numEffectedE, numEffectedF);
+ effectedV, effectedE, effectedF,
+ numEffectedV, numEffectedE, numEffectedF);
for (i = 0; i < numEffectedV; i++)
effectedV[i]->flags = 0;
@@ -2654,12 +2672,12 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
- &effectedV, &numEffectedV, &effectedE, &numEffectedE);
+ &effectedV, &numEffectedV, &effectedE, &numEffectedE);
for (curLvl = lvl; curLvl < subdivLevels; curLvl++) {
ccgSubSurf__calcSubdivLevel(ss,
- effectedV, effectedE, effectedF,
- numEffectedV, numEffectedE, numEffectedF, curLvl);
+ effectedV, effectedE, effectedF,
+ numEffectedV, numEffectedE, numEffectedF, curLvl);
}
for (i = 0; i < numEffectedV; i++)
@@ -2698,15 +2716,15 @@ int ccgSubSurf_getNumFaces(const CCGSubSurf *ss)
CCGVert *ccgSubSurf_getVert(CCGSubSurf *ss, CCGVertHDL v)
{
- return (CCGVert*) _ehash_lookup(ss->vMap, v);
+ return (CCGVert *) _ehash_lookup(ss->vMap, v);
}
CCGEdge *ccgSubSurf_getEdge(CCGSubSurf *ss, CCGEdgeHDL e)
{
- return (CCGEdge*) _ehash_lookup(ss->eMap, e);
+ return (CCGEdge *) _ehash_lookup(ss->eMap, e);
}
CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f)
{
- return (CCGFace*) _ehash_lookup(ss->fMap, f);
+ return (CCGFace *) _ehash_lookup(ss->fMap, f);
}
int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss)
@@ -2719,7 +2737,7 @@ int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss)
}
int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level)
{
- if (level<1 || level > ss->subdivLevels) {
+ if (level < 1 || level > ss->subdivLevels) {
return -1;
}
else {
@@ -2732,7 +2750,7 @@ int ccgSubSurf_getGridSize(const CCGSubSurf *ss)
}
int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level)
{
- if (level<1 || level > ss->subdivLevels) {
+ if (level < 1 || level > ss->subdivLevels) {
return -1;
}
else {
@@ -2750,7 +2768,7 @@ int ccgSubSurf_getVertAge(CCGSubSurf *ss, CCGVert *v)
{
if (ss->useAgeCounts) {
byte *userData = ccgSubSurf_getVertUserData(ss, v);
- return ss->currentAge - *((int*) &userData[ss->vertUserAgeOffset]);
+ return ss->currentAge - *((int *) &userData[ss->vertUserAgeOffset]);
}
else {
return 0;
@@ -2766,7 +2784,7 @@ int ccgSubSurf_getVertNumFaces(CCGVert *v)
}
CCGFace *ccgSubSurf_getVertFace(CCGVert *v, int index)
{
- if (index<0 || index>=v->numFaces) {
+ if (index < 0 || index >= v->numFaces) {
return NULL;
}
else {
@@ -2779,7 +2797,7 @@ int ccgSubSurf_getVertNumEdges(CCGVert *v)
}
CCGEdge *ccgSubSurf_getVertEdge(CCGVert *v, int index)
{
- if (index<0 || index>=v->numEdges) {
+ if (index < 0 || index >= v->numEdges) {
return NULL;
}
else {
@@ -2792,7 +2810,7 @@ void *ccgSubSurf_getVertData(CCGSubSurf *ss, CCGVert *v)
}
void *ccgSubSurf_getVertLevelData(CCGSubSurf *ss, CCGVert *v, int level)
{
- if (level<0 || level > ss->subdivLevels) {
+ if (level < 0 || level > ss->subdivLevels) {
return NULL;
}
else {
@@ -2810,7 +2828,7 @@ int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e)
{
if (ss->useAgeCounts) {
byte *userData = ccgSubSurf_getEdgeUserData(ss, e);
- return ss->currentAge - *((int*) &userData[ss->edgeUserAgeOffset]);
+ return ss->currentAge - *((int *) &userData[ss->edgeUserAgeOffset]);
}
else {
return 0;
@@ -2819,7 +2837,7 @@ int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e)
void *ccgSubSurf_getEdgeUserData(CCGSubSurf *ss, CCGEdge *e)
{
return (EDGE_getLevelData(e) +
- ss->meshIFC.vertDataSize * ccg_edgebase(ss->subdivLevels + 1));
+ ss->meshIFC.vertDataSize * ccg_edgebase(ss->subdivLevels + 1));
}
int ccgSubSurf_getEdgeNumFaces(CCGEdge *e)
{
@@ -2827,7 +2845,7 @@ int ccgSubSurf_getEdgeNumFaces(CCGEdge *e)
}
CCGFace *ccgSubSurf_getEdgeFace(CCGEdge *e, int index)
{
- if (index<0 || index>=e->numFaces) {
+ if (index < 0 || index >= e->numFaces) {
return NULL;
}
else {
@@ -2852,7 +2870,7 @@ void *ccgSubSurf_getEdgeData(CCGSubSurf *ss, CCGEdge *e, int x)
}
void *ccgSubSurf_getEdgeLevelData(CCGSubSurf *ss, CCGEdge *e, int x, int level)
{
- if (level<0 || level > ss->subdivLevels) {
+ if (level < 0 || level > ss->subdivLevels) {
return NULL;
}
else {
@@ -2874,7 +2892,7 @@ int ccgSubSurf_getFaceAge(CCGSubSurf *ss, CCGFace *f)
{
if (ss->useAgeCounts) {
byte *userData = ccgSubSurf_getFaceUserData(ss, f);
- return ss->currentAge - *((int*) &userData[ss->faceUserAgeOffset]);
+ return ss->currentAge - *((int *) &userData[ss->faceUserAgeOffset]);
}
else {
return 0;
@@ -2891,7 +2909,7 @@ int ccgSubSurf_getFaceNumVerts(CCGFace *f)
}
CCGVert *ccgSubSurf_getFaceVert(CCGFace *f, int index)
{
- if (index<0 || index>=f->numVerts) {
+ if (index < 0 || index >= f->numVerts) {
return NULL;
}
else {
@@ -2900,7 +2918,7 @@ CCGVert *ccgSubSurf_getFaceVert(CCGFace *f, int index)
}
CCGEdge *ccgSubSurf_getFaceEdge(CCGFace *f, int index)
{
- if (index<0 || index>=f->numVerts) {
+ if (index < 0 || index >= f->numVerts) {
return NULL;
}
else {
@@ -2943,66 +2961,66 @@ void *ccgSubSurf_getFaceGridData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int
CCGVertIterator *ccgSubSurf_getVertIterator(CCGSubSurf *ss)
{
- return (CCGVertIterator*) _ehashIterator_new(ss->vMap);
+ return (CCGVertIterator *) _ehashIterator_new(ss->vMap);
}
CCGEdgeIterator *ccgSubSurf_getEdgeIterator(CCGSubSurf *ss)
{
- return (CCGEdgeIterator*) _ehashIterator_new(ss->eMap);
+ return (CCGEdgeIterator *) _ehashIterator_new(ss->eMap);
}
CCGFaceIterator *ccgSubSurf_getFaceIterator(CCGSubSurf *ss)
{
- return (CCGFaceIterator*) _ehashIterator_new(ss->fMap);
+ return (CCGFaceIterator *) _ehashIterator_new(ss->fMap);
}
CCGVert *ccgVertIterator_getCurrent(CCGVertIterator *vi)
{
- return (CCGVert*) _ehashIterator_getCurrent((EHashIterator*) vi);
+ return (CCGVert *) _ehashIterator_getCurrent((EHashIterator *) vi);
}
int ccgVertIterator_isStopped(CCGVertIterator *vi)
{
- return _ehashIterator_isStopped((EHashIterator*) vi);
+ return _ehashIterator_isStopped((EHashIterator *) vi);
}
void ccgVertIterator_next(CCGVertIterator *vi)
{
- _ehashIterator_next((EHashIterator*) vi);
+ _ehashIterator_next((EHashIterator *) vi);
}
void ccgVertIterator_free(CCGVertIterator *vi)
{
- _ehashIterator_free((EHashIterator*) vi);
+ _ehashIterator_free((EHashIterator *) vi);
}
CCGEdge *ccgEdgeIterator_getCurrent(CCGEdgeIterator *vi)
{
- return (CCGEdge*) _ehashIterator_getCurrent((EHashIterator*) vi);
+ return (CCGEdge *) _ehashIterator_getCurrent((EHashIterator *) vi);
}
int ccgEdgeIterator_isStopped(CCGEdgeIterator *vi)
{
- return _ehashIterator_isStopped((EHashIterator*) vi);
+ return _ehashIterator_isStopped((EHashIterator *) vi);
}
void ccgEdgeIterator_next(CCGEdgeIterator *vi)
{
- _ehashIterator_next((EHashIterator*) vi);
+ _ehashIterator_next((EHashIterator *) vi);
}
void ccgEdgeIterator_free(CCGEdgeIterator *vi)
{
- _ehashIterator_free((EHashIterator*) vi);
+ _ehashIterator_free((EHashIterator *) vi);
}
CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *vi)
{
- return (CCGFace*) _ehashIterator_getCurrent((EHashIterator*) vi);
+ return (CCGFace *) _ehashIterator_getCurrent((EHashIterator *) vi);
}
int ccgFaceIterator_isStopped(CCGFaceIterator *vi)
{
- return _ehashIterator_isStopped((EHashIterator*) vi);
+ return _ehashIterator_isStopped((EHashIterator *) vi);
}
void ccgFaceIterator_next(CCGFaceIterator *vi)
{
- _ehashIterator_next((EHashIterator*) vi);
+ _ehashIterator_next((EHashIterator *) vi);
}
void ccgFaceIterator_free(CCGFaceIterator *vi)
{
- _ehashIterator_free((EHashIterator*) vi);
+ _ehashIterator_free((EHashIterator *) vi);
}
/*** Extern API final vert/edge/face interface ***/
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 94aed7c7a01..0fd030be39c 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -274,7 +274,7 @@ void DM_init_funcs(DerivedMesh *dm)
}
void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
- int numTessFaces, int numLoops, int numPolys)
+ int numTessFaces, int numLoops, int numPolys)
{
dm->type = type;
dm->numVertData = numVerts;
@@ -1223,7 +1223,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
for (i=0; i<dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
- BLI_array_growitems(wtcol_l, mp->totloop);
+ BLI_array_grow_items(wtcol_l, mp->totloop);
for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[4 * ml->v]);
@@ -2137,7 +2137,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
- but this avoids waiting on first stroke) */
+ * but this avoids waiting on first stroke) */
ob->sculpt->pbvh= ob->derivedFinal->getPBVH(ob, ob->derivedFinal);
}
}
@@ -2279,8 +2279,10 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit,
* the data we need, rebuild the derived mesh
*/
if (!em->derivedCage ||
- (em->lastDataMask & dataMask) != dataMask)
+ (em->lastDataMask & dataMask) != dataMask)
+ {
editbmesh_build_data(scene, obedit, em, dataMask);
+ }
*final_r = em->derivedFinal;
return em->derivedCage;
@@ -2292,8 +2294,10 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
* the data we need, rebuild the derived mesh
*/
if (!em->derivedCage ||
- (em->lastDataMask & dataMask) != dataMask)
+ (em->lastDataMask & dataMask) != dataMask)
+ {
editbmesh_build_data(scene, obedit, em, dataMask);
+ }
return em->derivedCage;
}
@@ -2701,8 +2705,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
if (nr_tris_to_pile==1 || nr_tris_to_pile==2) {
const int indices[] = {offs+0, offs+1, offs+2, offs+0, offs+2, (offs+3)&0x3 };
int t;
- for ( t=0; t<nr_tris_to_pile; t++ )
- {
+ for ( t=0; t<nr_tris_to_pile; t++ ) {
float f2x_area_uv;
float * p0 = verts[indices[t*3+0]];
float * p1 = verts[indices[t*3+1]];
@@ -2769,7 +2772,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
for (b = 0; b < gattribs->totlayer; b++) {
if (gattribs->layer[b].type == CD_MTFACE) {
/* uv coordinates */
- if(dm->type == DM_TYPE_EDITBMESH) {
+ if (dm->type == DM_TYPE_EDITBMESH) {
/* exception .. */
CustomData *ldata = dm->getLoopDataLayout(dm);
@@ -2806,7 +2809,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
}
}
else if (gattribs->layer[b].type == CD_MCOL) {
- if(dm->type == DM_TYPE_EDITBMESH) {
+ if (dm->type == DM_TYPE_EDITBMESH) {
/* exception .. */
CustomData *ldata = dm->getLoopDataLayout(dm);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index c77e384a264..93401a528ab 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1561,7 +1561,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
}
/* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */
- else {
+ else {
/* Mod to repeat */
if (strip->repeat!=1.0f) {
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index b547fedebb5..38c73ba72b9 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -482,7 +482,7 @@ void calc_curvepath(Object *ob)
if (ob==NULL || ob->type != OB_CURVE) return;
cu= ob->data;
- nurbs= BKE_curve_nurbs(cu);
+ nurbs= BKE_curve_nurbs_get(cu);
nu= nurbs->first;
if (cu->path) free_path(cu->path);
@@ -635,7 +635,7 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
p3= pp + s3;
/* note, commented out for follow constraint */
- //if(cu->flag & CU_FOLLOW) {
+ //if (cu->flag & CU_FOLLOW) {
key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE);
@@ -1350,9 +1350,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* some hair paths might be non-existent so they can't be used for duplication */
if (hair &&
- ((a < totpart && psys->pathcache[a]->steps < 0) ||
- (a >= totpart && psys->childcache[a-totpart]->steps < 0)))
+ ((a < totpart && psys->pathcache[a]->steps < 0) ||
+ (a >= totpart && psys->childcache[a-totpart]->steps < 0)))
+ {
continue;
+ }
if (part->ren_as==PART_DRAW_GR) {
/* prevent divide by zero below [#28336] */
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 121bae8380f..06913910829 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1257,8 +1257,7 @@ static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMappe
FCurve *fcu;
/* calculate then execute each curve */
- for (fcu= list->first; fcu; fcu= fcu->next)
- {
+ for (fcu= list->first; fcu; fcu= fcu->next) {
/* check if this F-Curve doesn't belong to a muted group */
if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) {
/* check if this curve should be skipped */
@@ -1281,8 +1280,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
/* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
* the depsgraph requested that this driver be evaluated...
*/
- for (fcu= adt->drivers.first; fcu; fcu= fcu->next)
- {
+ for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
ChannelDriver *driver= fcu->driver;
short ok= 0;
@@ -1358,8 +1356,7 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup
return;
/* calculate then execute each curve */
- for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next)
- {
+ for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) {
/* check if this curve should be skipped */
if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) {
calculate_fcurve(fcu, ctime);
@@ -1975,8 +1972,7 @@ void nladata_flush_channels (ListBase *channels)
float value= nec->value;
/* write values - see animsys_write_rna_setting() to sync the code */
- switch (RNA_property_type(prop))
- {
+ switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
@@ -2178,7 +2174,7 @@ static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt)
*
* Current Status:
* - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
- * However, the code fo this is relatively harmless, so is left in the code for now.
+ * However, the code for this is relatively harmless, so is left in the code for now.
*/
/* Evaluation loop for evaluation animation data
@@ -2224,7 +2220,9 @@ void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float c
* or be layered on top of existing animation data.
* - Drivers should be in the appropriate order to be evaluated without problems...
*/
- if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated
+ if ((recalc & ADT_RECALC_DRIVERS)
+ /* XXX for now, don't check yet, as depsgraph hasn't been updated */
+ /* && (adt->recalc & ADT_RECALC_DRIVERS)*/)
{
animsys_evaluate_drivers(&id_ptr, adt, ctime);
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 0f3e27a9b6e..d1d6833e903 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -566,13 +566,13 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
if (bone->segments > MAX_BBONE_SUBDIV)
bone->segments = MAX_BBONE_SUBDIV;
- forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0],
+ BKE_curve_forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0],
MAX_BBONE_SUBDIV, 4*sizeof(float));
- forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1,
+ BKE_curve_forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1,
MAX_BBONE_SUBDIV, 4*sizeof(float));
- forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2,
+ BKE_curve_forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2,
MAX_BBONE_SUBDIV, 4*sizeof(float));
- forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3,
+ BKE_curve_forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3,
MAX_BBONE_SUBDIV, 4*sizeof(float));
equalize_bezier(data[0], bone->segments); /* note: does stride 4! */
@@ -1372,7 +1372,7 @@ void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[]
/* same as object_mat3_to_rot() */
void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat)
{
- switch(pchan->rotmode) {
+ switch (pchan->rotmode) {
case ROT_MODE_QUAT:
mat3_to_quat(pchan->quat, mat);
break;
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index a14988d78b1..fbcabccd2b9 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -962,7 +962,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
set_boid_values(&val, bbd->part->boids, pa);
/* go through rules */
- switch(state->ruleset_type) {
+ switch (state->ruleset_type) {
case eBoidRulesetType_Fuzzy:
{
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -1254,11 +1254,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
madd_v3_v3fl(pa->state.vel, acc, dtime);
- //if(bpa->data.mode != eBoidMode_InAir)
+ //if (bpa->data.mode != eBoidMode_InAir)
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* change modes, constrain movement & keep track of down vector */
- switch(bpa->data.mode) {
+ switch (bpa->data.mode) {
case eBoidMode_InAir:
{
float grav[3];
@@ -1437,7 +1437,7 @@ BoidRule *boid_new_rule(int type)
if (type <= 0)
return NULL;
- switch(type) {
+ switch (type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid:
rule = MEM_callocN(sizeof(BoidRuleGoalAvoid), "BoidRuleGoalAvoid");
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index e7ba09d3959..3df6de2fd24 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -337,7 +337,7 @@ void brush_reset_sculpt(Brush *br)
brush_set_defaults(br);
brush_curve_preset(br, CURVE_PRESET_SMOOTH);
- switch(br->sculpt_tool) {
+ switch (br->sculpt_tool) {
case SCULPT_TOOL_CLAY:
br->flag |= BRUSH_FRONTFACE;
break;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 009b7ca7f99..df80ce6e87c 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -649,8 +649,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
//Not in cache
- if (tree == NULL)
- {
+ if (tree == NULL) {
int i;
int numEdges= mesh->getNumEdges(mesh);
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
@@ -675,8 +674,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
}
}
}
- else
- {
+ else {
// printf("BVHTree is already build, using cached tree\n");
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 2d764142d26..4de7df098c3 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -230,7 +230,7 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
int deformed= 0;
/* active modifiers means extra deformation, which can't be handled correct
- * on bith of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
+ * on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
* stuff and show final DerivedMesh so user would see actual object shape */
deformed|= ob->sculpt->modifiers_active;
@@ -412,8 +412,9 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
DEBUG_VBO( "Using legacy code. cdDM_drawEdges\n" );
glBegin(GL_LINES);
for (i = 0; i < dm->numEdgeData; i++, medge++) {
- if ((drawAllEdges || (medge->flag&ME_EDGEDRAW))
- && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
+ if ((drawAllEdges || (medge->flag & ME_EDGEDRAW)) &&
+ (drawLooseEdges || !(medge->flag & ME_LOOSEEDGE)))
+ {
glVertex3fv(mvert[medge->v1].co);
glVertex3fv(mvert[medge->v2].co);
}
@@ -423,17 +424,18 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
int prevstart = 0;
int prevdraw = 1;
- int draw = 1;
+ int draw = TRUE;
GPU_edge_setup(dm);
- if ( !GPU_buffer_legacy(dm) ) {
+ if (!GPU_buffer_legacy(dm)) {
for (i = 0; i < dm->numEdgeData; i++, medge++) {
- if ((drawAllEdges || (medge->flag&ME_EDGEDRAW))
- && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
- draw = 1;
+ if ((drawAllEdges || (medge->flag & ME_EDGEDRAW)) &&
+ (drawLooseEdges || !(medge->flag & ME_LOOSEEDGE)))
+ {
+ draw = TRUE;
}
else {
- draw = 0;
+ draw = FALSE;
}
if ( prevdraw != draw ) {
if ( prevdraw > 0 && (i-prevstart) > 0 ) {
@@ -538,8 +540,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
new_matnr = mface->mat_nr + 1;
new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT;
- if (new_glmode != glmode || new_matnr != matnr
- || new_shademodel != shademodel) {
+ if (new_glmode != glmode || new_matnr != matnr || new_shademodel != shademodel) {
glEnd();
drawCurrentMat = setMaterial(matnr = new_matnr, NULL);
@@ -700,14 +701,17 @@ 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 0
+ if ( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) {
col = 0;
}
else if ( mcol && dm->drawObject->colType == CD_MCOL ) {
col = 0;
}
- if ( col != 0 ) {*/
+ if ( col != 0 )
+#endif
+ {
unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common");
for ( i=0; i < dm->getNumTessFaces(dm); i++ ) {
for ( j=0; j < 4; j++ ) {
@@ -723,7 +727,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
dm->drawObject->colType = CD_TEXTURE_MCOL;
else if (mcol)
dm->drawObject->colType = CD_MCOL;
- //}
+ }
GPU_color_setup( dm );
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 7dedd71b2e0..97baaad430b 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -191,8 +191,7 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps
bvhtree = BLI_bvhtree_new(cloth->numverts, epsilon, 4, 6);
// fill tree
- for (i = 0; i < cloth->numverts; i++, verts++)
- {
+ for (i = 0; i < cloth->numverts; i++, verts++) {
copy_v3_v3(&co[0*3], verts->xold);
BLI_bvhtree_insert(bvhtree, i, co, 1);
@@ -232,8 +231,7 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon
bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26);
// fill tree
- for (i = 0; i < cloth->numfaces; i++, mfaces++)
- {
+ for (i = 0; i < cloth->numfaces; i++, mfaces++) {
copy_v3_v3(&co[0*3], verts[mfaces->v1].xold);
copy_v3_v3(&co[1*3], verts[mfaces->v2].xold);
copy_v3_v3(&co[2*3], verts[mfaces->v3].xold);
@@ -266,10 +264,8 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
mfaces = cloth->mfaces;
// update vertex position in bvh tree
- if (verts && mfaces)
- {
- for (i = 0; i < cloth->numfaces; i++, mfaces++)
- {
+ if (verts && mfaces) {
+ for (i = 0; i < cloth->numfaces; i++, mfaces++) {
copy_v3_v3(&co[0*3], verts[mfaces->v1].txold);
copy_v3_v3(&co[1*3], verts[mfaces->v2].txold);
copy_v3_v3(&co[2*3], verts[mfaces->v3].txold);
@@ -278,8 +274,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
copy_v3_v3(&co[3*3], verts[mfaces->v4].txold);
// copy new locations into array
- if (moving)
- {
+ if (moving) {
// update moving positions
copy_v3_v3(&co_moving[0*3], verts[mfaces->v1].tx);
copy_v3_v3(&co_moving[1*3], verts[mfaces->v2].tx);
@@ -319,15 +314,12 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving)
mfaces = cloth->mfaces;
// update vertex position in bvh tree
- if (verts && mfaces)
- {
- for (i = 0; i < cloth->numverts; i++, verts++)
- {
+ if (verts && mfaces) {
+ for (i = 0; i < cloth->numverts; i++, verts++) {
copy_v3_v3(&co[0*3], verts->txold);
// copy new locations into array
- if (moving)
- {
+ if (moving) {
// update moving positions
copy_v3_v3(&co_moving[0*3], verts->tx);
@@ -446,9 +438,9 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
clmd->sim_parms->timescale= timescale;
- if (clmd->sim_parms->reset
- || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0)
- || (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->numverts))
+ if (clmd->sim_parms->reset ||
+ (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) ||
+ (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->numverts))
{
clmd->sim_parms->reset = 0;
cache->flag |= PTCACHE_OUTDATED;
@@ -558,11 +550,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
cloth = clmd->clothObject;
- if ( cloth )
- {
+ if ( cloth ) {
// If our solver provides a free function, call it
- if ( solvers [clmd->sim_parms->solver_type].free )
- {
+ if ( solvers [clmd->sim_parms->solver_type].free ) {
solvers [clmd->sim_parms->solver_type].free ( clmd );
}
@@ -574,11 +564,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
cloth->numverts = 0;
// Free the springs.
- if ( cloth->springs != NULL )
- {
+ if ( cloth->springs != NULL ) {
LinkNode *search = cloth->springs;
- while (search)
- {
+ while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
@@ -628,14 +616,12 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
cloth = clmd->clothObject;
- if ( cloth )
- {
+ if ( cloth ) {
if (G.rt > 0)
printf("cloth_free_modifier_extern in\n");
// If our solver provides a free function, call it
- if ( solvers [clmd->sim_parms->solver_type].free )
- {
+ if ( solvers [clmd->sim_parms->solver_type].free ) {
solvers [clmd->sim_parms->solver_type].free ( clmd );
}
@@ -647,11 +633,9 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
cloth->numverts = 0;
// Free the springs.
- if ( cloth->springs != NULL )
- {
+ if ( cloth->springs != NULL ) {
LinkNode *search = cloth->springs;
- while (search)
- {
+ while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
@@ -708,8 +692,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte
/* inverse matrix is not uptodate... */
invert_m4_m4(ob->imat, ob->obmat);
- for (i = 0; i < cloth->numverts; i++)
- {
+ for (i = 0; i < cloth->numverts; i++) {
copy_v3_v3 (vertexCos[i], cloth->verts[i].x);
mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */
}
@@ -749,17 +732,12 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
verts = clothObj->verts;
- if (cloth_uses_vgroup(clmd))
- {
- for ( i = 0; i < numverts; i++, verts++ )
- {
+ if (cloth_uses_vgroup(clmd)) {
+ for ( i = 0; i < numverts; i++, verts++ ) {
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
- if ( dvert )
- {
- for ( j = 0; j < dvert->totweight; j++ )
- {
- if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ))
- {
+ if ( dvert ) {
+ for ( j = 0; j < dvert->totweight; j++ ) {
+ if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) {
verts->goal = dvert->dw [j].weight;
/* goalfac= 1.0f; */ /* UNUSED */
@@ -769,22 +747,18 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
*/
verts->goal = ( float ) pow ( verts->goal , 4.0f );
- if ( verts->goal >=SOFTGOALSNAP )
- {
+ if ( verts->goal >=SOFTGOALSNAP ) {
verts->flags |= CLOTH_VERT_FLAG_PINNED;
}
}
- if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING )
- {
- if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1))
- {
+ if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) {
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) {
verts->struct_stiff = dvert->dw [j].weight;
verts->shear_stiff = dvert->dw [j].weight;
}
- if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1))
- {
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) {
verts->bend_stiff = dvert->dw [j].weight;
}
}
@@ -812,8 +786,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
float maxdist = 0;
// If we have a clothObject, free it.
- if ( clmd->clothObject != NULL )
- {
+ if ( clmd->clothObject != NULL ) {
cloth_free_modifier ( clmd );
if (G.rt > 0)
printf("cloth_free_modifier cloth_from_object\n");
@@ -821,8 +794,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
// Allocate a new cloth object.
clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" );
- if ( clmd->clothObject )
- {
+ if ( clmd->clothObject ) {
clmd->clothObject->old_solver_type = 255;
// clmd->clothObject->old_collision_type = 255;
cloth = clmd->clothObject;
@@ -851,10 +823,8 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
verts = clmd->clothObject->verts;
// set initial values
- for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ )
- {
- if (first)
- {
+ for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) {
+ if (first) {
copy_v3_v3( verts->x, mvert[i].co );
mul_m4_v3( ob->obmat, verts->x );
@@ -891,18 +861,15 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
// has to be happen before springs are build!
cloth_apply_vgroup (clmd, dm);
- if ( !cloth_build_springs ( clmd, dm ) )
- {
+ if ( !cloth_build_springs ( clmd, dm ) ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs."));
printf("cloth_free_modifier cloth_build_springs\n");
return 0;
}
- for ( i = 0; i < dm->getNumVerts(dm); i++)
- {
- if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
- {
+ for ( i = 0; i < dm->getNumVerts(dm); i++) {
+ if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO)) {
cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
}
}
@@ -917,8 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, MAX2(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel) );
- for (i = 0; i < dm->getNumVerts(dm); i++)
- {
+ for (i = 0; i < dm->getNumVerts(dm); i++) {
maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f));
}
@@ -937,8 +903,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
/* Allocate our vertices. */
clmd->clothObject->numverts = numverts;
clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" );
- if ( clmd->clothObject->verts == NULL )
- {
+ if ( clmd->clothObject->verts == NULL ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts."));
printf("cloth_free_modifier clmd->clothObject->verts\n");
@@ -948,8 +913,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
// save face information
clmd->clothObject->numfaces = numfaces;
clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" );
- if ( clmd->clothObject->mfaces == NULL )
- {
+ if ( clmd->clothObject->mfaces == NULL ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces."));
printf("cloth_free_modifier clmd->clothObject->mfaces\n");
@@ -977,8 +941,7 @@ int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned in
Cloth *cloth = clmd->clothObject;
ClothSpring *spring = NULL;
- if (cloth)
- {
+ if (cloth) {
// TODO: look if this spring is already there
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
@@ -1006,11 +969,9 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
{
unsigned int i = 0;
- if ( cloth->springs != NULL )
- {
+ if ( cloth->springs != NULL ) {
LinkNode *search = cloth->springs;
- while (search)
- {
+ while (search) {
ClothSpring *spring = search->link;
MEM_freeN ( spring );
@@ -1021,10 +982,8 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
cloth->springs = NULL;
}
- if (edgelist)
- {
- for ( i = 0; i < cloth->numverts; i++ )
- {
+ if (edgelist) {
+ for ( i = 0; i < cloth->numverts; i++ ) {
BLI_linklist_free ( edgelist[i],NULL );
}
@@ -1062,8 +1021,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (!edgelist)
return 0;
- for ( i = 0; i < numverts; i++ )
- {
+ for ( i = 0; i < numverts; i++ ) {
edgelist[i] = NULL;
}
@@ -1074,12 +1032,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
edgehash = BLI_edgehash_new();
// structural springs
- for ( i = 0; i < numedges; i++ )
- {
+ for ( i = 0; i < numedges; i++ ) {
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if ( spring )
- {
+ if ( spring ) {
spring->ij = MIN2(medge[i].v1, medge[i].v2);
spring->kl = MAX2(medge[i].v2, medge[i].v1);
spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
@@ -1104,22 +1060,19 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (struct_springs > 0)
clmd->sim_parms->avg_spring_len /= struct_springs;
- for (i = 0; i < numverts; i++)
- {
+ for (i = 0; i < numverts; i++) {
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count);
}
// shear springs
- for ( i = 0; i < numfaces; i++ )
- {
+ for ( i = 0; i < numfaces; i++ ) {
// triangle faces already have shear springs due to structural geometry
if ( !mface[i].v4 )
continue;
spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if (!spring)
- {
+ if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@@ -1140,8 +1093,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
// if ( mface[i].v4 ) --> Quad face
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if (!spring)
- {
+ if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@@ -1162,27 +1114,24 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if (numfaces) {
// bending springs
search2 = cloth->springs;
- for ( i = struct_springs; i < struct_springs+shear_springs; i++ )
- {
+ for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) {
if ( !search2 )
break;
tspring2 = search2->link;
search = edgelist[tspring2->kl];
- while ( search )
- {
+ while ( search ) {
tspring = search->link;
index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) );
// check for existing spring
// check also if startpoint is equal to endpoint
- if ( !BLI_edgehash_haskey ( edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2) )
- && ( index2!=tspring2->ij ) )
+ if (!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)) &&
+ (index2 != tspring2->ij))
{
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if (!spring)
- {
+ if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@@ -1212,16 +1161,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
/* of the strands. -jahka */
search = cloth->springs;
search2 = search->next;
- while (search && search2)
- {
+ while (search && search2) {
tspring = search->link;
tspring2 = search2->link;
if (tspring->ij == tspring2->kl) {
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if (!spring)
- {
+ if (!spring) {
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
}
@@ -1242,13 +1189,12 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
}
/* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */
- for ( i = 0; i < numedges; i++ ) // struct springs
+ for (i = 0; i < numedges; i++) { /* struct springs */
BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL );
-
- for ( i = 0; i < numfaces; i++ ) // edge springs
- {
- if (mface[i].v4)
- {
+ }
+
+ for (i = 0; i < numfaces; i++) { /* edge springs */
+ if (mface[i].v4) {
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL );
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL );
@@ -1258,10 +1204,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
cloth->numsprings = struct_springs + shear_springs + bend_springs;
- if ( edgelist )
- {
- for ( i = 0; i < numverts; i++ )
- {
+ if ( edgelist ) {
+ for ( i = 0; i < numverts; i++ ) {
BLI_linklist_free ( edgelist[i],NULL );
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index f6a6ef068d6..264a251c317 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -80,8 +80,7 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev
float tv[3] = {0, 0, 0};
unsigned int i = 0;
- for ( i = 0; i < collmd->numverts; i++ )
- {
+ for ( i = 0; i < collmd->numverts; i++ ) {
sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co );
VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
@@ -101,8 +100,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert
tree = BLI_bvhtree_new ( numfaces*2, epsilon, 4, 26 );
// fill tree
- for ( i = 0; i < numfaces; i++, tface++ )
- {
+ for ( i = 0; i < numfaces; i++, tface++ ) {
copy_v3_v3 ( &co[0*3], x[tface->v1].co );
copy_v3_v3 ( &co[1*3], x[tface->v2].co );
copy_v3_v3 ( &co[2*3], x[tface->v3].co );
@@ -128,10 +126,8 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
if ( !bvhtree )
return;
- if ( x )
- {
- for ( i = 0; i < numfaces; i++, mfaces++ )
- {
+ if ( x ) {
+ for ( i = 0; i < numfaces; i++, mfaces++ ) {
copy_v3_v3 ( &co[0*3], x[mfaces->v1].co );
copy_v3_v3 ( &co[1*3], x[mfaces->v2].co );
copy_v3_v3 ( &co[2*3], x[mfaces->v3].co );
@@ -139,8 +135,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
copy_v3_v3 ( &co[3*3], x[mfaces->v4].co );
// copy new locations into array
- if ( moving && xnew )
- {
+ if ( moving && xnew ) {
// update moving positions
copy_v3_v3 ( &co_moving[0*3], xnew[mfaces->v1].co );
copy_v3_v3 ( &co_moving[1*3], xnew[mfaces->v2].co );
@@ -150,8 +145,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
ret = BLI_bvhtree_update_node ( bvhtree, i, co, co_moving, ( mfaces->v4 ? 4 : 3 ) );
}
- else
- {
+ else {
ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) );
}
@@ -465,8 +459,7 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
d = ( a * c - b * b );
- if ( ABS ( d ) < (double)ALMOST_ZERO )
- {
+ if ( ABS ( d ) < (double)ALMOST_ZERO ) {
*w1 = *w2 = *w3 = 1.0 / 3.0;
return;
}
@@ -504,8 +497,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
cloth1 = clmd->clothObject;
- for ( ; collpair != collision_end; collpair++ )
- {
+ for ( ; collpair != collision_end; collpair++ ) {
// only handle static collisions here
if ( collpair->flag & COLLISION_IN_FUTURE )
continue;
@@ -540,8 +532,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
// TODO
// If v_n_mag < 0 the edges are approaching each other.
- if ( magrelVel > ALMOST_ZERO )
- {
+ if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@@ -558,8 +549,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
- if ( magtangent > ALMOST_ZERO )
- {
+ if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 *
@@ -587,8 +577,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
- if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) )
- {
+ if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) {
repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@@ -666,8 +655,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
BVHTreeOverlap *overlap, CollPair *collpair,
GHash *visithash, MemArena *arena)
{
- ClothModifierData *clmd = ( ClothModifierData * ) md1;
- CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
+ ClothModifierData *clmd = (ClothModifierData *)md1;
+ CollisionModifierData *collmd = (CollisionModifierData *) md2;
MFace *face1=NULL, *face2 = NULL;
ClothVertex *verts1 = clmd->clothObject->verts;
double distance = 0;
@@ -685,10 +674,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
face2 = & ( collmd->mfaces[overlap->indexB] );
// check all 4 possible collisions
- for ( i = 0; i < 4; i++ )
- {
- if ( i == 0 )
- {
+ for ( i = 0; i < 4; i++ ) {
+ if ( i == 0 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@@ -699,10 +686,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
bp2 = face2->v2;
bp3 = face2->v3;
}
- else if ( i == 1 )
- {
- if ( face1->v4 )
- {
+ else if ( i == 1 ) {
+ if ( face1->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@@ -717,10 +702,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
continue;
}
}
- if ( i == 2 )
- {
- if ( face2->v4 )
- {
+ if ( i == 2 ) {
+ if ( face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@@ -735,10 +718,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
continue;
}
}
- else if ( i == 3 )
- {
- if ( face1->v4 && face2->v4 )
- {
+ else if ( i == 3 ) {
+ if ( face1->v4 && face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@@ -847,8 +828,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
cloth1 = clmd->clothObject;
- for ( ; collpair != collision_end; collpair++ )
- {
+ for ( ; collpair != collision_end; collpair++ ) {
if (!(collpair->flag & COLLISION_IS_EDGES))
continue;
@@ -865,8 +845,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
- if ( magrelVel > ALMOST_ZERO )
- {
+ if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@@ -885,8 +864,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
- if ( magtangent > ALMOST_ZERO )
- {
+ if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent;
@@ -906,8 +884,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = collpair->distance;
- if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) )
- {
+ if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) {
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@@ -949,8 +926,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
cloth1 = clmd->clothObject;
- for ( ; collpair != collision_end; collpair++ )
- {
+ for ( ; collpair != collision_end; collpair++ ) {
if (collpair->flag & COLLISION_IS_EDGES)
continue;
@@ -967,8 +943,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
- if ( magrelVel > ALMOST_ZERO )
- {
+ if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@@ -985,8 +960,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
- if ( magtangent > ALMOST_ZERO )
- {
+ if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent; // 2.0 *
@@ -1006,8 +980,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = -collpair->distance;
- if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
- {
+ if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) {
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@@ -1034,8 +1007,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
// If v_n_mag < 0 the edges are approaching each other.
- if ( magrelVel > ALMOST_ZERO )
- {
+ if ( magrelVel > ALMOST_ZERO ) {
// Calculate Impulse magnitude to stop all motion in normal direction.
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
@@ -1052,8 +1024,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
// Apply friction impulse.
- if ( magtangent > ALMOST_ZERO )
- {
+ if ( magtangent > ALMOST_ZERO ) {
normalize_v3( vrel_t_pre );
impulse = magtangent; // 2.0 *
@@ -1072,8 +1043,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
d = -collpair->distance;
- if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
- {
+ if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) {
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
@@ -1185,8 +1155,8 @@ int cloth_point_tri_moving_v3v3_f(float v1[2][3], int i1, float v2[2][3], int i2
static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap,
CollPair *collpair, double dt, GHash *gh, MemArena *arena)
{
- ClothModifierData *clmd = ( ClothModifierData * ) md1;
- CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
+ ClothModifierData *clmd = (ClothModifierData *)md1;
+ CollisionModifierData *collmd = (CollisionModifierData *) md2;
MFace *face1=NULL, *face2 = NULL;
ClothVertex *verts1 = clmd->clothObject->verts;
double distance = 0;
@@ -1202,10 +1172,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
face2 = & ( collmd->mfaces[overlap->indexB] );
// check all 4 possible collisions
- for ( i = 0; i < 4; i++ )
- {
- if ( i == 0 )
- {
+ for ( i = 0; i < 4; i++ ) {
+ if ( i == 0 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@@ -1216,10 +1184,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
bp2 = face2->v2;
bp3 = face2->v3;
}
- else if ( i == 1 )
- {
- if ( face1->v4 )
- {
+ else if ( i == 1 ) {
+ if ( face1->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@@ -1234,10 +1200,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
continue;
}
}
- if ( i == 2 )
- {
- if ( face2->v4 )
- {
+ if ( i == 2 ) {
+ if ( face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v2;
@@ -1252,10 +1216,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
continue;
}
}
- else if ( i == 3 )
- {
- if ( face1->v4 && face2->v4 )
- {
+ else if ( i == 3 ) {
+ if ( face1->v4 && face2->v4 ) {
// fill faceA
ap1 = face1->v1;
ap2 = face1->v3;
@@ -1400,8 +1362,8 @@ static void machine_epsilon_offset(Cloth *cloth)
static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
BVHTreeOverlap *overlap, CollPair *collpair, float dt )
{
- ClothModifierData *clmd = ( ClothModifierData * ) md1;
- CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
+ ClothModifierData *clmd = (ClothModifierData *)md1;
+ CollisionModifierData *collmd = (CollisionModifierData *) md2;
Cloth *cloth = clmd->clothObject;
MFace *face1=NULL, *face2 = NULL;
#ifdef USE_BULLET
@@ -1417,10 +1379,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
face2 = & ( collmd->mfaces[overlap->indexB] );
// check all 4 possible collisions
- for ( i = 0; i < 4; i++ )
- {
- if ( i == 0 )
- {
+ for ( i = 0; i < 4; i++ ) {
+ if ( i == 0 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v2;
@@ -1431,10 +1391,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
collpair->bp2 = face2->v2;
collpair->bp3 = face2->v3;
}
- else if ( i == 1 )
- {
- if ( face1->v4 )
- {
+ else if ( i == 1 ) {
+ if ( face1->v4 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v4;
@@ -1448,10 +1406,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
else
i++;
}
- if ( i == 2 )
- {
- if ( face2->v4 )
- {
+ if ( i == 2 ) {
+ if ( face2->v4 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v2;
@@ -1465,10 +1421,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
else
break;
}
- else if ( i == 3 )
- {
- if ( face1->v4 && face2->v4 )
- {
+ else if ( i == 3 ) {
+ if ( face1->v4 && face2->v4 ) {
// fill faceA
collpair->ap1 = face1->v1;
collpair->ap2 = face1->v4;
@@ -1513,8 +1467,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO );
#endif
- if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) )
- {
+ if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) {
normalize_v3_v3( collpair->normal, collpair->vector );
collpair->distance = distance;
@@ -2283,24 +2236,21 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis
#ifdef WITH_ELTOPO
machine_epsilon_offset(clmd->clothObject);
- for ( i = 0; i < numresult; i++ )
- {
- *collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd,
+ for ( i = 0; i < numresult; i++ ) {
+ *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
overlap+i, *collisions_index, dt, tri_visithash, arena );
}
- for ( i = 0; i < numresult; i++ )
- {
- *collisions_index = cloth_edge_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd,
+ for ( i = 0; i < numresult; i++ ) {
+ *collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
overlap+i, *collisions_index, visithash, arena );
}
BLI_ghash_free(visithash, NULL, NULL);
BLI_ghash_free(tri_visithash, NULL, NULL);
BLI_memarena_free(arena);
#else /* WITH_ELTOPO */
- for ( i = 0; i < numresult; i++ )
- {
- *collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd,
+ for ( i = 0; i < numresult; i++ ) {
+ *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
overlap+i, *collisions_index, dt );
}
#endif /* WITH_ELTOPO */
@@ -2323,12 +2273,10 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
// process all collisions (calculate impulses, TODO: also repulses if distance too short)
result = 1;
- for ( j = 0; j < 5; j++ ) // 5 is just a value that ensures convergence
- {
+ for ( j = 0; j < 5; j++ ) { /* 5 is just a value that ensures convergence */
result = 0;
- if ( collmd->bvhtree )
- {
+ if ( collmd->bvhtree ) {
#ifdef WITH_ELTOPO
result += cloth_collision_response_moving(clmd, collmd, collisions, collisions_index);
result += cloth_edge_collision_response_moving(clmd, collmd, collisions, collisions_index);
@@ -2339,14 +2287,11 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
{
#else
// apply impulses in parallel
- if ( result )
- {
+ if (result) {
#endif
- for ( i = 0; i < numverts; i++ )
- {
+ for (i = 0; i < numverts; i++) {
// calculate "velocities" (just xnew = xold + v; no dt in v)
- if ( verts[i].impulse_count )
- {
+ if (verts[i].impulse_count) {
VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count );
copy_v3_v3 ( verts[i].impulse, tnull );
verts[i].impulse_count = 0;
@@ -2402,8 +2347,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair");
// check all collision objects
- for (i = 0; i < numcollobj; i++)
- {
+ for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision);
BVHTreeOverlap *overlap = NULL;
@@ -2435,8 +2379,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
}
rounds++;
- for (i = 0; i < numcollobj; i++)
- {
+ for (i = 0; i < numcollobj; i++) {
if ( collisions[i] ) MEM_freeN ( collisions[i] );
}
@@ -2449,12 +2392,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
// verts come from clmd
- for ( i = 0; i < numverts; i++ )
- {
- if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
- {
- if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED )
- {
+ for ( i = 0; i < numverts; i++ ) {
+ if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
+ if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
continue;
}
}
@@ -2467,10 +2407,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
// Test on *simple* selfcollisions
////////////////////////////////////////////////////////////
- if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF )
- {
- for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++)
- {
+ if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) {
+ for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) {
// TODO: add coll quality rounds again
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
@@ -2483,14 +2421,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
verts = cloth->verts;
- if ( cloth->bvhselftree )
- {
- // search for overlapping collision pairs
+ if ( cloth->bvhselftree ) {
+ // search for overlapping collision pairs
overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result );
// #pragma omp parallel for private(k, i, j) schedule(static)
- for ( k = 0; k < result; k++ )
- {
+ for ( k = 0; k < result; k++ ) {
float temp[3];
float length = 0;
float mindistance;
@@ -2500,10 +2436,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len );
- if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
- {
- if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
- && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
+ if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
+ if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) &&
+ ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
{
continue;
}
@@ -2514,29 +2449,24 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
// check for adjacent points (i must be smaller j)
- if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
- {
+ if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) {
continue;
}
length = normalize_v3( temp );
- if ( length < mindistance )
- {
+ if ( length < mindistance ) {
float correction = mindistance - length;
- if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
- {
+ if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
mul_v3_fl( temp, -correction );
VECADD ( verts[j].tx, verts[j].tx, temp );
}
- else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
- {
+ else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) {
mul_v3_fl( temp, correction );
VECADD ( verts[i].tx, verts[i].tx, temp );
}
- else
- {
+ else {
mul_v3_fl( temp, correction * -0.5 );
VECADD ( verts[j].tx, verts[j].tx, temp );
@@ -2560,12 +2490,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
// SELFCOLLISIONS: update velocities
////////////////////////////////////////////////////////////
- if ( ret2 )
- {
- for ( i = 0; i < cloth->numverts; i++ )
- {
- if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) )
- {
+ if ( ret2 ) {
+ for ( i = 0; i < cloth->numverts; i++ ) {
+ if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) {
sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold );
}
}
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 25391a34689..6dc1b2a4b00 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -202,7 +202,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
if (cuma->curve)
MEM_freeN(cuma->curve);
- switch(preset) {
+ switch (preset) {
case CURVE_PRESET_LINE: cuma->totpoint= 2; break;
case CURVE_PRESET_SHARP: cuma->totpoint= 4; break;
case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
@@ -214,7 +214,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
- switch(preset) {
+ switch (preset) {
case CURVE_PRESET_LINE:
cuma->curve[0].x= clipr->xmin;
cuma->curve[0].y= clipr->ymax;
@@ -252,10 +252,9 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
case CURVE_PRESET_MID9:
{
int i;
- for (i=0; i < cuma->totpoint; i++)
- {
- cuma->curve[i].x= i / ((float)cuma->totpoint-1);
- cuma->curve[i].y= 0.5;
+ for (i = 0; i < cuma->totpoint; i++) {
+ cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
+ cuma->curve[i].y = 0.5;
}
}
break;
@@ -500,8 +499,8 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
for (a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]);
- forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
- forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
+ BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
+ BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
}
/* store first and last handle for extrapolation, unit length */
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 0a6e8a163cc..82a908eaf57 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3439,8 +3439,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
{
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
- if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) )
- {
+ if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) {
int fail = FALSE;
float co[3] = {0.0f, 0.0f, 0.0f};
float no[3] = {0.0f, 0.0f, 0.0f};
@@ -3461,12 +3460,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
unit_m4(ct->matrix);
- if (target != NULL)
- {
+ if (target != NULL) {
space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat);
- switch(scon->shrinkType)
- {
+ switch (scon->shrinkType) {
case MOD_SHRINKWRAP_NEAREST_SURFACE:
case MOD_SHRINKWRAP_NEAREST_VERTEX:
@@ -3475,8 +3472,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
else
bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6);
- if (treeData.tree == NULL)
- {
+ if (treeData.tree == NULL) {
fail = TRUE;
break;
}
@@ -3506,14 +3502,12 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6);
- if (treeData.tree == NULL)
- {
+ if (treeData.tree == NULL) {
fail = TRUE;
break;
}
- if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE)
- {
+ if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) {
fail = TRUE;
break;
}
@@ -3542,8 +3536,7 @@ static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, L
bConstraintTarget *ct= targets->first;
/* only evaluate if there is a target */
- if (VALID_CONS_TARGET(ct))
- {
+ if (VALID_CONS_TARGET(ct)) {
copy_v3_v3(cob->matrix[3], ct->matrix[3]);
}
}
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index e9dd4d01b0e..7a5b4ef9b24 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -777,7 +777,7 @@ int CTX_data_mode_enum(const bContext *C)
Object *obedit= CTX_data_edit_object(C);
if (obedit) {
- switch(obedit->type) {
+ switch (obedit->type) {
case OB_MESH:
return CTX_MODE_EDIT_MESH;
case OB_CURVE:
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 9232fe8ec04..e0cadac586b 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -70,7 +70,7 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c
short cox, short coy,
float *labda, float *mu, float vec[3]);
-void unlink_curve(Curve *cu)
+void BKE_curve_unlink(Curve *cu)
{
int a;
@@ -95,7 +95,7 @@ void unlink_curve(Curve *cu)
}
/* frees editcurve entirely */
-void BKE_free_editfont(Curve *cu)
+void BKE_curve_editfont_free(Curve *cu)
{
if (cu->editfont) {
EditFont *ef= cu->editfont;
@@ -112,7 +112,7 @@ void BKE_free_editfont(Curve *cu)
}
}
-void free_curve_editNurb_keyIndex(EditNurb *editnurb)
+void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb)
{
if (!editnurb->keyindex) {
return;
@@ -121,26 +121,26 @@ void free_curve_editNurb_keyIndex(EditNurb *editnurb)
editnurb->keyindex= NULL;
}
-void free_curve_editNurb (Curve *cu)
+void BKE_curve_editNurb_free (Curve *cu)
{
if (cu->editnurb) {
- freeNurblist(&cu->editnurb->nurbs);
- free_curve_editNurb_keyIndex(cu->editnurb);
+ BKE_nurbList_free(&cu->editnurb->nurbs);
+ BKE_curve_editNurb_keyIndex_free(cu->editnurb);
MEM_freeN(cu->editnurb);
cu->editnurb= NULL;
}
}
/* don't free curve itself */
-void free_curve(Curve *cu)
+void BKE_curve_free(Curve *cu)
{
- freeNurblist(&cu->nurb);
+ BKE_nurbList_free(&cu->nurb);
BLI_freelistN(&cu->bev);
freedisplist(&cu->disp);
- BKE_free_editfont(cu);
+ BKE_curve_editfont_free(cu);
- free_curve_editNurb(cu);
- unlink_curve(cu);
+ BKE_curve_editNurb_free(cu);
+ BKE_curve_unlink(cu);
BKE_free_animdata((ID *)cu);
if (cu->mat) MEM_freeN(cu->mat);
@@ -151,7 +151,7 @@ void free_curve(Curve *cu)
if (cu->tb) MEM_freeN(cu->tb);
}
-Curve *add_curve(const char *name, int type)
+Curve *BKE_curve_add(const char *name, int type)
{
Curve *cu;
@@ -187,14 +187,14 @@ Curve *add_curve(const char *name, int type)
return cu;
}
-Curve *copy_curve(Curve *cu)
+Curve *BKE_curve_copy(Curve *cu)
{
Curve *cun;
int a;
cun= copy_libblock(&cu->id);
cun->nurb.first= cun->nurb.last= NULL;
- duplicateNurblist( &(cun->nurb), &(cu->nurb));
+ BKE_nurbList_duplicate( &(cun->nurb), &(cu->nurb));
cun->mat= MEM_dupallocN(cu->mat);
for (a=0; a<cun->totcol; a++) {
@@ -242,7 +242,7 @@ static void extern_local_curve(Curve *cu)
}
}
-void make_local_curve(Curve *cu)
+void BKE_curve_make_local(Curve *cu)
{
Main *bmain= G.main;
Object *ob;
@@ -273,7 +273,7 @@ void make_local_curve(Curve *cu)
extern_local_curve(cu);
}
else if (is_local && is_lib) {
- Curve *cu_new= copy_curve(cu);
+ Curve *cu_new= BKE_curve_copy(cu);
cu_new->id.us= 0;
BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id);
@@ -291,7 +291,7 @@ void make_local_curve(Curve *cu)
}
/* Get list of nurbs from editnurbs structure */
-ListBase *curve_editnurbs(Curve *cu)
+ListBase *BKE_curve_editNurbs_get(Curve *cu)
{
if (cu->editnurb) {
return &cu->editnurb->nurbs;
@@ -300,7 +300,7 @@ ListBase *curve_editnurbs(Curve *cu)
return NULL;
}
-short curve_type(Curve *cu)
+short BKE_curve_type_get(Curve *cu)
{
Nurb *nu;
int type= cu->type;
@@ -322,9 +322,9 @@ short curve_type(Curve *cu)
return type;
}
-void update_curve_dimension(Curve *cu)
+void BKE_curve_curve_dimension_update(Curve *cu)
{
- ListBase *nurbs= BKE_curve_nurbs(cu);
+ ListBase *nurbs= BKE_curve_nurbs_get(cu);
Nurb *nu= nurbs->first;
if (cu->flag&CU_3D) {
@@ -335,24 +335,24 @@ void update_curve_dimension(Curve *cu)
else {
for ( ; nu; nu= nu->next) {
nu->flag |= CU_2D;
- test2DNurb(nu);
+ BKE_nurb_test2D(nu);
/* since the handles are moved they need to be auto-located again */
if (nu->type == CU_BEZIER)
- calchandlesNurb(nu);
+ BKE_nurb_handles_calc(nu);
}
}
}
-void test_curve_type(Object *ob)
+void BKE_curve_type_test(Object *ob)
{
- ob->type= curve_type(ob->data);
+ ob->type= BKE_curve_type_get(ob->data);
if (ob->type==OB_CURVE)
- update_curve_dimension((Curve *)ob->data);
+ BKE_curve_curve_dimension_update((Curve *)ob->data);
}
-void tex_space_curve(Curve *cu)
+void BKE_curve_tex_space_calc(Curve *cu)
{
DispList *dl;
BoundBox *bb;
@@ -408,7 +408,7 @@ void tex_space_curve(Curve *cu)
}
}
-int count_curveverts(ListBase *nurb)
+int BKE_nurbList_verts_count(ListBase *nurb)
{
Nurb *nu;
int tot=0;
@@ -423,7 +423,7 @@ int count_curveverts(ListBase *nurb)
return tot;
}
-int count_curveverts_without_handles(ListBase *nurb)
+int BKE_nurbList_verts_count_without_handles(ListBase *nurb)
{
Nurb *nu;
int tot=0;
@@ -440,7 +440,7 @@ int count_curveverts_without_handles(ListBase *nurb)
/* **************** NURBS ROUTINES ******************** */
-void freeNurb(Nurb *nu)
+void BKE_nurb_free(Nurb *nu)
{
if (nu==NULL) return;
@@ -460,7 +460,7 @@ void freeNurb(Nurb *nu)
}
-void freeNurblist(ListBase *lb)
+void BKE_nurbList_free(ListBase *lb)
{
Nurb *nu, *next;
@@ -469,13 +469,13 @@ void freeNurblist(ListBase *lb)
nu= lb->first;
while (nu) {
next= nu->next;
- freeNurb(nu);
+ BKE_nurb_free(nu);
nu= next;
}
lb->first= lb->last= NULL;
}
-Nurb *duplicateNurb(Nurb *nu)
+Nurb *BKE_nurb_duplicate(Nurb *nu)
{
Nurb *newnu;
int len;
@@ -515,22 +515,22 @@ Nurb *duplicateNurb(Nurb *nu)
return newnu;
}
-void duplicateNurblist(ListBase *lb1, ListBase *lb2)
+void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2)
{
Nurb *nu, *nun;
- freeNurblist(lb1);
+ BKE_nurbList_free(lb1);
nu= lb2->first;
while (nu) {
- nun= duplicateNurb(nu);
+ nun= BKE_nurb_duplicate(nu);
BLI_addtail(lb1, nun);
nu= nu->next;
}
}
-void test2DNurb(Nurb *nu)
+void BKE_nurb_test2D(Nurb *nu)
{
BezTriple *bezt;
BPoint *bp;
@@ -559,7 +559,7 @@ void test2DNurb(Nurb *nu)
}
}
-void minmaxNurb(Nurb *nu, float *min, float *max)
+void BKE_nurb_minmax(Nurb *nu, float *min, float *max)
{
BezTriple *bezt;
BPoint *bp;
@@ -586,7 +586,7 @@ void minmaxNurb(Nurb *nu, float *min, float *max)
}
/* be sure to call makeknots after this */
-void addNurbPoints(Nurb *nu, int number)
+void BKE_nurb_points_add(Nurb *nu, int number)
{
BPoint *tmp= nu->bp;
int i;
@@ -606,7 +606,7 @@ void addNurbPoints(Nurb *nu, int number)
nu->pntsu += number;
}
-void addNurbPointsBezier(Nurb *nu, int number)
+void BKE_nurb_bezierPoints_add(Nurb *nu, int number)
{
BezTriple *tmp= nu->bezt;
int i;
@@ -636,7 +636,7 @@ static void calcknots(float *knots, const short pnts, const short order, const s
float k;
int a;
- switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
+ switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
case CU_NURB_ENDPOINT:
k= 0.0;
for (a=1; a <= pnts_order; a++) {
@@ -706,7 +706,7 @@ static void makeknots(Nurb *nu, short uv)
if (nu->type == CU_NURBS) {
if (uv == 1) {
if (nu->knotsu) MEM_freeN(nu->knotsu);
- if (check_valid_nurb_u(nu)) {
+ if (BKE_nurb_check_valid_u(nu)) {
nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots");
if (nu->flagu & CU_NURB_CYCLIC) {
calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */
@@ -721,7 +721,7 @@ static void makeknots(Nurb *nu, short uv)
}
else if (uv == 2) {
if (nu->knotsv) MEM_freeN(nu->knotsv);
- if (check_valid_nurb_v(nu)) {
+ if (BKE_nurb_check_valid_v(nu)) {
nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots");
if (nu->flagv & CU_NURB_CYCLIC) {
calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */
@@ -736,12 +736,12 @@ static void makeknots(Nurb *nu, short uv)
}
}
-void nurbs_knot_calc_u(Nurb *nu)
+void BKE_nurb_knot_calc_u(Nurb *nu)
{
makeknots(nu, 1);
}
-void nurbs_knot_calc_v(Nurb *nu)
+void BKE_nurb_knot_calc_v(Nurb *nu)
{
makeknots(nu, 2);
}
@@ -809,7 +809,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
}
-void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
+void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
/* coord_array has to be 3*4*resolu*resolv in size, and zero-ed */
{
BPoint *bp;
@@ -972,7 +972,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
MEM_freeN(jend);
}
-void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
+void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
/* coord_array has to be 3*4*pntsu*resolu in size and zero-ed
* tilt_array and radius_array will be written to if valid */
{
@@ -1074,7 +1074,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
}
/* forward differencing method for bezier curve */
-void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
+void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
{
float rt0,rt1,rt2,rt3,f;
int a;
@@ -1122,7 +1122,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-float *make_orco_surf(Object *ob)
+float *BKE_curve_surf_make_orco(Object *ob)
{
/* Note: this function is used in convertblender only atm, so
* suppose nonzero curve's render resolution should always be used */
@@ -1190,7 +1190,7 @@ float *make_orco_surf(Object *ob)
float *_tdata= MEM_callocN((nu->pntsu*resolu) * (nu->pntsv*resolv) *3*sizeof(float), "temp data");
float *tdata= _tdata;
- makeNurbfaces(nu, tdata, 0, resolu, resolv);
+ BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv);
for (b=0; b<sizeu; b++) {
int use_b= b;
@@ -1224,7 +1224,7 @@ float *make_orco_surf(Object *ob)
/* NOTE: This routine is tied to the order of vertex
* built by displist and as passed to the renderer.
*/
-float *make_orco_curve(Scene *scene, Object *ob)
+float *BKE_curve_make_orco(Scene *scene, Object *ob)
{
Curve *cu = ob->data;
DispList *dl;
@@ -1312,7 +1312,7 @@ float *make_orco_curve(Scene *scene, Object *ob)
/* ***************** BEVEL ****************** */
-void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
+void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRender)
{
DispList *dl, *dlnew;
Curve *bevcu, *cu;
@@ -2038,7 +2038,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
{
- switch(twist_mode) {
+ switch (twist_mode) {
case CU_TWIST_TANGENT:
make_bevel_list_3D_tangent(bl);
break;
@@ -2083,7 +2083,7 @@ static void make_bevel_list_segment_3D(BevList *bl)
-void makeBevelList(Object *ob)
+void BKE_curve_bevelList_make(Object *ob)
{
/*
* - convert all curves to polys, with indication of resol and flags for double-vertices
@@ -2112,7 +2112,7 @@ void makeBevelList(Object *ob)
BLI_freelistN(&(cu->bev));
if (cu->editnurb && ob->type!=OB_FONT) {
- ListBase *nurbs= curve_editnurbs(cu);
+ ListBase *nurbs= BKE_curve_editNurbs_get(cu);
nu = nurbs->first;
}
else {
@@ -2128,7 +2128,7 @@ void makeBevelList(Object *ob)
/* check we are a single point? also check we are not a surface and that the orderu is sane,
* enforced in the UI but can go wrong possibly */
- if (!check_valid_nurb_u(nu)) {
+ if (!BKE_nurb_check_valid_u(nu)) {
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList1");
BLI_addtail(&(cu->bev), bl);
bl->nr= 0;
@@ -2201,7 +2201,7 @@ void makeBevelList(Object *ob)
/* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */
for (j=0; j<3; j++) {
- forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j],
+ BKE_curve_forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j],
bezt->vec[0][j], bezt->vec[1][j],
&(bevp->vec[j]), resolu, sizeof(BevPoint));
}
@@ -2256,7 +2256,7 @@ void makeBevelList(Object *ob)
else bl->poly= -1;
bevp= (BevPoint *)(bl+1);
- makeNurbcurve( nu, &bevp->vec[0],
+ BKE_nurb_makeCurve( nu, &bevp->vec[0],
do_tilt ? &bevp->alfa : NULL,
do_radius ? &bevp->radius : NULL,
do_weight ? &bevp->weight : NULL,
@@ -2719,18 +2719,18 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align)
}
}
-void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
+void BKE_nurb_handle_calc(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
{
calchandleNurb_intern(bezt, prev, next, mode, FALSE);
}
-void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
+void BKE_nurb_handles_calc(Nurb *nu) /* first, if needed, set handle flags */
{
calchandlesNurb_intern(nu, FALSE);
}
-void testhandlesNurb(Nurb *nu)
+void BKE_nurb_handles_test(Nurb *nu)
{
/* use when something has changed with handles.
* it treats all BezTriples with the following rules:
@@ -2770,10 +2770,10 @@ void testhandlesNurb(Nurb *nu)
bezt++;
}
- calchandlesNurb(nu);
+ BKE_nurb_handles_calc(nu);
}
-void autocalchandlesNurb(Nurb *nu, int flag)
+void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
{
/* checks handle coordinates and calculates type */
@@ -2841,21 +2841,21 @@ void autocalchandlesNurb(Nurb *nu, int flag)
bezt2++;
}
- calchandlesNurb(nu);
+ BKE_nurb_handles_calc(nu);
}
-void autocalchandlesNurb_all(ListBase *editnurb, int flag)
+void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag)
{
Nurb *nu;
nu= editnurb->first;
while (nu) {
- autocalchandlesNurb(nu, flag);
+ BKE_nurb_handles_autocalc(nu, flag);
nu= nu->next;
}
}
-void sethandlesNurb(ListBase *editnurb, short code)
+void BKE_nurbList_handles_set(ListBase *editnurb, short code)
{
/* code==1: set autohandle */
/* code==2: set vectorhandle */
@@ -2884,7 +2884,7 @@ void sethandlesNurb(ListBase *editnurb, short code)
}
bezt++;
}
- calchandlesNurb(nu);
+ BKE_nurb_handles_calc(nu);
}
nu= nu->next;
}
@@ -2928,7 +2928,7 @@ void sethandlesNurb(ListBase *editnurb, short code)
bezt++;
}
- calchandlesNurb(nu);
+ BKE_nurb_handles_calc(nu);
}
nu= nu->next;
}
@@ -2958,7 +2958,7 @@ static void swapdata(void *adr1, void *adr2, int len)
}
}
-void switchdirectionNurb(Nurb *nu)
+void BKE_nurb_direction_switch(Nurb *nu)
{
BezTriple *bezt1, *bezt2;
BPoint *bp1, *bp2;
@@ -3064,9 +3064,9 @@ void switchdirectionNurb(Nurb *nu)
}
-float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
+float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
{
- int i, numVerts = *numVerts_r = count_curveverts(lb);
+ int i, numVerts = *numVerts_r = BKE_nurbList_verts_count(lb);
float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos");
Nurb *nu;
@@ -3093,7 +3093,7 @@ float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
return cos;
}
-void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3])
+void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3])
{
float *co = vertexCos[0];
Nurb *nu;
@@ -3121,9 +3121,9 @@ void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3]
}
}
-float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
+float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
{
- int i, numVerts = count_curveverts(lb);
+ int i, numVerts = BKE_nurbList_verts_count(lb);
float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos");
Nurb *nu;
@@ -3152,7 +3152,7 @@ float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
return cos;
}
-void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key)
+void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key)
{
Nurb *nu;
int i;
@@ -3179,7 +3179,7 @@ void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key)
}
}
-int check_valid_nurb_u( struct Nurb *nu )
+int BKE_nurb_check_valid_u( struct Nurb *nu )
{
if (nu==NULL) return 0;
if (nu->pntsu <= 1) return 0;
@@ -3194,7 +3194,7 @@ int check_valid_nurb_u( struct Nurb *nu )
}
return 1;
}
-int check_valid_nurb_v( struct Nurb *nu)
+int BKE_nurb_check_valid_v( struct Nurb *nu)
{
if (nu==NULL) return 0;
if (nu->pntsv <= 1) return 0;
@@ -3210,7 +3210,7 @@ int check_valid_nurb_v( struct Nurb *nu)
return 1;
}
-int clamp_nurb_order_u( struct Nurb *nu )
+int BKE_nurb_order_clamp_u( struct Nurb *nu )
{
int change = 0;
if (nu->pntsu<nu->orderu) {
@@ -3224,7 +3224,7 @@ int clamp_nurb_order_u( struct Nurb *nu )
return change;
}
-int clamp_nurb_order_v( struct Nurb *nu)
+int BKE_nurb_order_clamp_v( struct Nurb *nu)
{
int change = 0;
if (nu->pntsv<nu->orderv) {
@@ -3239,10 +3239,10 @@ int clamp_nurb_order_v( struct Nurb *nu)
}
/* Get edit nurbs or normal nurbs list */
-ListBase *BKE_curve_nurbs(Curve *cu)
+ListBase *BKE_curve_nurbs_get(Curve *cu)
{
if (cu->editnurb) {
- return curve_editnurbs(cu);
+ return BKE_curve_editNurbs_get(cu);
}
return &cu->nurb;
@@ -3250,20 +3250,20 @@ ListBase *BKE_curve_nurbs(Curve *cu)
/* basic vertex data functions */
-int minmax_curve(Curve *cu, float min[3], float max[3])
+int BKE_curve_minmax(Curve *cu, float min[3], float max[3])
{
- ListBase *nurb_lb= BKE_curve_nurbs(cu);
+ ListBase *nurb_lb= BKE_curve_nurbs_get(cu);
Nurb *nu;
for (nu= nurb_lb->first; nu; nu= nu->next)
- minmaxNurb(nu, min, max);
+ BKE_nurb_minmax(nu, min, max);
return (nurb_lb->first != NULL);
}
-int curve_center_median(Curve *cu, float cent[3])
+int BKE_curve_center_median(Curve *cu, float cent[3])
{
- ListBase *nurb_lb= BKE_curve_nurbs(cu);
+ ListBase *nurb_lb= BKE_curve_nurbs_get(cu);
Nurb *nu;
int total= 0;
@@ -3297,11 +3297,11 @@ int curve_center_median(Curve *cu, float cent[3])
return (total != 0);
}
-int curve_center_bounds(Curve *cu, float cent[3])
+int BKE_curve_center_bounds(Curve *cu, float cent[3])
{
float min[3], max[3];
INIT_MINMAX(min, max);
- if (minmax_curve(cu, min, max)) {
+ if (BKE_curve_minmax(cu, min, max)) {
mid_v3_v3v3(cent, min, max);
return 1;
}
@@ -3309,9 +3309,9 @@ int curve_center_bounds(Curve *cu, float cent[3])
return 0;
}
-void curve_translate(Curve *cu, float offset[3], int do_keys)
+void BKE_curve_translate(Curve *cu, float offset[3], int do_keys)
{
- ListBase *nurb_lb= BKE_curve_nurbs(cu);
+ ListBase *nurb_lb= BKE_curve_nurbs_get(cu);
Nurb *nu;
int i;
@@ -3346,9 +3346,9 @@ void curve_translate(Curve *cu, float offset[3], int do_keys)
}
}
-void curve_delete_material_index(Curve *cu, int index)
+void BKE_curve_delete_material_index(Curve *cu, int index)
{
- const int curvetype= curve_type(cu);
+ const int curvetype= BKE_curve_type_get(cu);
if (curvetype == OB_FONT) {
struct CharInfo *info= cu->strinfo;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 536d4d9c823..ee8e57d5a3e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -167,7 +167,7 @@ static void layerCopy_bmesh_elem_py_ptr(const void *UNUSED(source), void *dest,
int i, size = sizeof(void *);
for (i = 0; i < count; ++i) {
- void **ptr = (void **)((char *)dest + i * size);
+ void **ptr = (void **)((char *)dest + i * size);
*ptr = NULL;
}
}
@@ -1810,9 +1810,9 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while (dest_i < dest->totlayer
- && dest->layers[dest_i].type < source->layers[src_i].type)
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
++dest_i;
+ }
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) return;
@@ -1901,9 +1901,9 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while (dest_i < dest->totlayer
- && dest->layers[dest_i].type < source->layers[src_i].type)
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
++dest_i;
+ }
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) return;
@@ -2056,7 +2056,7 @@ void CustomData_set(const CustomData *data, int index, int type, void *source)
/*Bmesh functions*/
/*needed to convert to/from different face reps*/
void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata,
- int totloop, int totpoly)
+ int totloop, int totpoly)
{
int i;
for (i=0; i < fdata->totlayer; i++) {
@@ -2167,7 +2167,7 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
int t;
/* copy old layer description so that old data can be copied into
- the new allocation */
+ * the new allocation */
destold = *dest;
if (destold.layers) destold.layers = MEM_dupallocN(destold.layers);
@@ -2272,9 +2272,9 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while (dest_i < dest->totlayer
- && dest->layers[dest_i].type < source->layers[src_i].type)
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
++dest_i;
+ }
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) return;
@@ -2337,7 +2337,10 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n)
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
- typeInfo->initminmax && typeInfo->dominmax) return 1;
+ typeInfo->initminmax && typeInfo->dominmax)
+ {
+ return 1;
+ }
return 0;
}
@@ -2504,9 +2507,9 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while (dest_i < dest->totlayer
- && dest->layers[dest_i].type < source->layers[src_i].type)
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
++dest_i;
+ }
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) return;
@@ -2547,9 +2550,9 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while (dest_i < dest->totlayer
- && dest->layers[dest_i].type < source->layers[src_i].type)
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
++dest_i;
+ }
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) return;
@@ -2684,7 +2687,9 @@ int CustomData_verify_versions(struct CustomData *data, int index)
if (!typeInfo->defaultname && (index > 0) &&
data->layers[index-1].type == layer->type)
+ {
keeplayer = 0; /* multiple layers of which we only support one */
+ }
}
if (!keeplayer) {
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 1232177fa10..3e0c947ff4a 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -479,7 +479,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
/* first case; separator . - _ with extensions r R l L */
if (is_char_sep(name[len - 2]) ) {
- switch(name[len - 1]) {
+ switch (name[len - 1]) {
case 'l':
prefix[len - 1] = 0;
strcpy(replace, "r");
@@ -500,7 +500,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
}
/* case; beginning with r R l L , with separator after it */
else if (is_char_sep(name[1]) ) {
- switch(name[0]) {
+ switch (name[0]) {
case 'l':
strcpy(replace, "r");
BLI_strncpy(suffix, name + 1, sizeof(suffix));
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 366e808d32c..045d85242f1 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -462,7 +462,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ob->parent) {
node2 = dag_get_node(dag,ob->parent);
- switch(ob->partype) {
+ switch (ob->partype) {
case PARSKEL:
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent");
break;
@@ -539,7 +539,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
break;
case OB_MBALL:
{
- Object *mom= find_basis_mball(scene, ob);
+ Object *mom= BKE_metaball_basis_find(scene, ob);
if (mom!=ob) {
node2 = dag_get_node(dag, mom);
@@ -1309,11 +1309,11 @@ DagNodeQueue * graph_dfs(void)
/* is_cycle = 1; */ /* UNUSED */
}
else if (itA->node->color == DAG_BLACK) {
- ;
/* already processed node but we may want later to change distance either to shorter to longer.
* DFS_dist is the first encounter
*/
- /*if (node->DFS_dist >= itA->node->DFS_dist)
+#if 0
+ if (node->DFS_dist >= itA->node->DFS_dist)
itA->node->DFS_dist = node->DFS_dist + 1;
fprintf(stderr,"dfs forward or cross edge :%15s %i-%i %15s %i-%i\n",
@@ -1323,7 +1323,7 @@ DagNodeQueue * graph_dfs(void)
((ID *) itA->node->ob)->name,
itA->node->DFS_dvtm,
itA->node->DFS_fntm);
- */
+#endif
}
else
fprintf(stderr,"dfs unknown edge\n");
@@ -1579,6 +1579,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
}
/* unused */
+#if 0
short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
{
DagNode * node;
@@ -1595,6 +1596,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
}
return DAG_NO_RELATION;
}
+#endif
int is_acyclic( DagForest *dag)
{
@@ -1803,7 +1805,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
while (base) {
BLI_remlink(&sce->base,base);
BLI_addhead(&tempbase,base);
- //if(G.debug & G_DEBUG)
+ //if (G.debug & G_DEBUG)
printf("cyclic %s\n", base->object->id.name);
base = sce->base.first;
}
@@ -2243,7 +2245,7 @@ static void dag_object_time_update_flags(Object *ob)
Curve *cu;
Lattice *lt;
- switch(ob->type) {
+ switch (ob->type) {
case OB_MESH:
me= ob->data;
if (me->key) {
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 01d5d6ef2ad..3d79386e19a 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1,4 +1,5 @@
/*
+
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -228,7 +229,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
dl= lb->first;
while (dl) {
- switch(dl->type) {
+ switch (dl->type) {
case DL_SURF:
*totvert+= dl->nr*dl->parts;
*totface+= (dl->nr-1)*(dl->parts-1);
@@ -296,7 +297,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
else
resolu= nu->resolu;
- if (!check_valid_nurb_u(nu));
+ if (!BKE_nurb_check_valid_u(nu));
else if (nu->type == CU_BEZIER) {
/* count */
@@ -351,7 +352,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
else {
int j;
for (j=0; j<3; j++) {
- forward_diff_bezier( prevbezt->vec[1][j],
+ BKE_curve_forward_diff_bezier( prevbezt->vec[1][j],
prevbezt->vec[2][j],
bezt->vec[0][j],
bezt->vec[1][j],
@@ -384,7 +385,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
data= dl->verts;
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
- makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
+ BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
}
else if (nu->type == CU_POLY) {
len= nu->pntsu;
@@ -672,9 +673,9 @@ void makeDispListMBall(Scene *scene, Object *ob)
freedisplist(&(ob->disp));
if (ob->type==OB_MBALL) {
- if (ob==find_basis_mball(scene, ob)) {
- metaball_polygonize(scene, ob, &ob->disp);
- tex_space_mball(ob);
+ if (ob==BKE_metaball_basis_find(scene, ob)) {
+ BKE_metaball_polygonize(scene, ob, &ob->disp);
+ BKE_metaball_tex_space_calc(ob);
object_deform_mball(ob, &ob->disp);
}
@@ -685,8 +686,8 @@ void makeDispListMBall(Scene *scene, Object *ob)
void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase)
{
- metaball_polygonize(scene, ob, dispbase);
- tex_space_mball(ob);
+ BKE_metaball_polygonize(scene, ob, dispbase);
+ BKE_metaball_tex_space_calc(ob);
object_deform_mball(ob, dispbase);
}
@@ -730,7 +731,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *pretessellatePoint;
Curve *cu= ob->data;
- ListBase *nurb= BKE_curve_nurbs(cu);
+ ListBase *nurb= BKE_curve_nurbs_get(cu);
int numVerts = 0;
int editmode = (!forRender && cu->editnurb);
float (*originalVerts)[3] = NULL;
@@ -753,9 +754,9 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
* tilts, which is passed through in the modifier stack.
* this is also the reason curves do not use a virtual
* shape key modifier yet. */
- deformedVerts= curve_getKeyVertexCos(cu, nurb, keyVerts);
+ deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts);
originalVerts= MEM_dupallocN(deformedVerts);
- numVerts = count_curveverts_without_handles(nurb);
+ numVerts = BKE_nurbList_verts_count_without_handles(nurb);
}
}
@@ -770,7 +771,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
if (!deformedVerts) {
- deformedVerts = curve_getVertexCos(cu, nurb, &numVerts);
+ deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts);
originalVerts = MEM_dupallocN(deformedVerts);
}
@@ -782,9 +783,9 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
}
if (deformedVerts)
- curve_applyVertexCos(cu, nurb, deformedVerts);
+ BK_curve_vertexCos_apply(cu, nurb, deformedVerts);
if (keyVerts) /* these are not passed through modifier stack */
- curve_applyKeyVertexTilts(cu, nurb, keyVerts);
+ BKE_curve_keyVertexTilts_apply(cu, nurb, keyVerts);
if (keyVerts)
MEM_freeN(keyVerts);
@@ -834,7 +835,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *pretessellatePoint;
Curve *cu= ob->data;
- ListBase *nurb= BKE_curve_nurbs(cu);
+ ListBase *nurb= BKE_curve_nurbs_get(cu);
int required_mode = 0, totvert = 0;
int editmode = (!forRender && cu->editnurb);
DerivedMesh *dm= NULL, *ndm;
@@ -956,7 +957,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
}
if (deformedVerts) {
- curve_applyVertexCos(ob->data, nurb, originalVerts);
+ BK_curve_vertexCos_apply(ob->data, nurb, originalVerts);
MEM_freeN(originalVerts);
MEM_freeN(deformedVerts);
}
@@ -1023,7 +1024,7 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
dm->getVertCos(dm, orco);
}
else {
- orco= (float(*)[3])make_orco_curve(scene, ob);
+ orco= (float(*)[3])BKE_curve_make_orco(scene, ob);
}
for (a=0; a<totvert; a++) {
@@ -1108,7 +1109,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
float (*deformedVerts)[3];
if (!forRender && cu->editnurb)
- nubase= curve_editnurbs(cu);
+ nubase= BKE_curve_editNurbs_get(cu);
else
nubase= &cu->nurb;
@@ -1144,7 +1145,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
- makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
+ BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
}
else {
len= (nu->pntsu*resolu) * (nu->pntsv*resolv);
@@ -1168,7 +1169,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */
if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V;
- makeNurbfaces(nu, data, 0, resolu, resolv);
+ BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
/* gl array drawing: using indices */
displist_surf_indices(dl);
@@ -1182,7 +1183,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
copy_displist(&cu->disp, dispbase);
if (!forRender) {
- tex_space_curve(cu);
+ BKE_curve_tex_space_calc(cu);
}
if (!forOrco)
@@ -1262,7 +1263,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
float (*deformedVerts)[3];
int numVerts;
- nubase= BKE_curve_nurbs(cu);
+ nubase= BKE_curve_nurbs_get(cu);
BLI_freelistN(&(cu->bev));
@@ -1273,10 +1274,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
- makeBevelList(ob);
+ BKE_curve_bevelList_make(ob);
/* If curve has no bevel will return nothing */
- makebevelcurve(scene, ob, &dlbev, forRender);
+ BKE_curve_bevel_make(scene, ob, &dlbev, forRender);
/* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width==1.0f) {
@@ -1410,7 +1411,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
copy_displist(&cu->disp, dispbase);
if (!forRender) {
- tex_space_curve(cu);
+ BKE_curve_tex_space_calc(cu);
}
if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 872f678d456..e6f38a3a334 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -231,13 +231,22 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
/* checks whether surface's format/type has realtime preview */
int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
{
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 0;
+ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
+ return 0;
+ }
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WAVE) return 0;
- else return 1;
+ surface->type == MOD_DPAINT_SURFACE_T_WAVE)
+ {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+ }
+ else {
+ return 1;
}
- else return 1;
}
/* get currently active surface (in user interface) */
@@ -393,11 +402,15 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
static int surface_totalSamples(DynamicPaintSurface *surface)
{
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ &&
- surface->flags & MOD_DPAINT_ANTIALIAS)
- return (surface->data->total_points*5);
+ surface->flags & MOD_DPAINT_ANTIALIAS)
+ {
+ return (surface->data->total_points * 5);
+ }
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
- surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
+ surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
+ {
return (surface->data->total_points+surface->data->adj_data->total_targets);
+ }
return surface->data->total_points;
}
@@ -548,8 +561,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
else
base = scene->base.first;
- while (base || go)
- {
+ while (base || go) {
brushObj = NULL;
/* select object */
@@ -559,8 +571,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
else
brushObj = base->object;
- if (!brushObj)
- {
+ if (!brushObj) {
if (surface->brush_group) go = go->next;
else base= base->next;
continue;
@@ -572,12 +583,10 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
base= base->next;
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
- if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
- {
+ if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
- if (pmd2->brush)
- {
+ if (pmd2->brush) {
DynamicPaintBrushSettings *brush = pmd2->brush;
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
@@ -888,8 +897,10 @@ void surface_freeUnusedData(DynamicPaintSurface *surface)
/* free bakedata if not active or surface is baked */
if (!(surface->flags & MOD_DPAINT_ACTIVE) ||
- (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
+ (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
+ {
free_bakeData(surface->data);
+ }
}
void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
@@ -1219,9 +1230,13 @@ static int surface_usesAdjData(DynamicPaintSurface *surface)
{
if (surface_usesAdjDistance(surface)) return 1;
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
- surface->flags & MOD_DPAINT_ANTIALIAS) return 1;
-
- return 0;
+ surface->flags & MOD_DPAINT_ANTIALIAS)
+ {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
/* initialize surface adjacency data */
@@ -1294,10 +1309,12 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
/* now check if total number of edges+faces for
* each vertex is even, if not -> vertex is on mesh edge */
for (i=0; i<sData->total_points; i++) {
- if ((temp_data[i]%2) ||
- temp_data[i] < 4)
+ if ((temp_data[i] % 2) ||
+ (temp_data[i] < 4))
+ {
ad->flags[i] |= ADJ_ON_MESH_EDGE;
-
+ }
+
/* reset temp data */
temp_data[i] = 0;
}
@@ -1577,14 +1594,14 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) {
- DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
+ DynamicPaintSurface *surface;
int update_normals = 0;
/* loop through surfaces */
- for (; surface; surface=surface->next) {
+ for (surface = pmd->canvas->surfaces.first; surface; surface=surface->next) {
PaintSurfaceData *sData = surface->data;
- if (surface && surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) {
+ if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) {
if (!(surface->flags & (MOD_DPAINT_ACTIVE))) continue;
/* process vertex surface previews */
@@ -1844,8 +1861,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
BKE_ptcache_id_time(&pid, scene, (float)scene->r.cfra, NULL, NULL, NULL);
/* reset non-baked cache at first frame */
- if ((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED))
- {
+ if ((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED)) {
cache->flag |= PTCACHE_REDO_NEEDED;
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -1856,8 +1872,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
BKE_ptcache_validate(cache, (int)scene->r.cfra);
}
/* if read failed and we're on surface range do recalculate */
- else if ((int)scene->r.cfra == current_frame
- && !(cache->flag & PTCACHE_BAKED)) {
+ else if ((int)scene->r.cfra == current_frame && !(cache->flag & PTCACHE_BAKED)) {
/* calculate surface frame */
canvas->flags |= MOD_DPAINT_BAKING;
dynamicPaint_calculateFrame(surface, scene, ob, current_frame);
@@ -1865,8 +1880,10 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
/* restore canvas derivedmesh if required */
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE &&
- surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next)
+ surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next)
+ {
canvas_copyDerivedMesh(canvas, dm);
+ }
BKE_ptcache_validate(cache, surface->current_frame);
BKE_ptcache_write(&pid, surface->current_frame);
@@ -2044,9 +2061,12 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
//printf("connected UV : %f,%f & %f,%f - %f,%f & %f,%f\n", s_uv1[0], s_uv1[1], s_uv2[0], s_uv2[1], t_uv1[0], t_uv1[1], t_uv2[0], t_uv2[1]);
if (((s_uv1[0] == t_uv1[0] && s_uv1[1] == t_uv1[1]) &&
- (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) ||
- ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
- (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
+ (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) ||
+ ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
+ (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) ))
+ {
+ return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
+ }
/*
* Find a point that is relatively at same edge position
@@ -2187,11 +2207,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
*/
if (!error) {
#pragma omp parallel for schedule(static)
- for (ty = 0; ty < h; ty++)
- {
+ for (ty = 0; ty < h; ty++) {
int tx;
- for (tx = 0; tx < w; tx++)
- {
+ for (tx = 0; tx < w; tx++) {
int i, sample;
int index = tx+w*ty;
PaintUVPoint *tPoint = (&tempPoints[index]);
@@ -2259,8 +2277,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
/* If collision wasn't found but the face is a quad
* do another check for the second half */
- if ((!isInside) && mface[i].v4)
- {
+ if ((!isInside) && mface[i].v4) {
/* change d2 to test the other half */
sub_v2_v2v2(d2, tface[i].uv[3], tface[i].uv[0]); // uv3 - uv0
@@ -2332,11 +2349,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
* (To avoid seams on uv island edges)
*/
#pragma omp parallel for schedule(static)
- for (ty = 0; ty < h; ty++)
- {
+ for (ty = 0; ty < h; ty++) {
int tx;
- for (tx = 0; tx < w; tx++)
- {
+ for (tx = 0; tx < w; tx++) {
int index = tx+w*ty;
PaintUVPoint *tPoint = (&tempPoints[index]);
@@ -2410,11 +2425,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
* When base loop is over convert found neighbor indexes to real ones
* Also count the final number of active surface points
*/
- for (ty = 0; ty < h; ty++)
- {
+ for (ty = 0; ty < h; ty++) {
int tx;
- for (tx = 0; tx < w; tx++)
- {
+ for (tx = 0; tx < w; tx++) {
int index = tx+w*ty;
PaintUVPoint *tPoint = (&tempPoints[index]);
@@ -2442,11 +2455,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
if (sData->adj_data) {
PaintAdjData *ed = sData->adj_data;
unsigned int n_pos = 0;
- for (ty = 0; ty < h; ty++)
- {
+ for (ty = 0; ty < h; ty++) {
int tx;
- for (tx = 0; tx < w; tx++)
- {
+ for (tx = 0; tx < w; tx++) {
int i, index = tx+w*ty;
if (tempPoints[index].face_index != -1) {
@@ -2578,8 +2589,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam
if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory.");return;}
#pragma omp parallel for schedule(static)
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
int pos=f_data->uv_p[index].pixel_index*4; /* image buffer position */
/* Set values of preferred type */
@@ -2761,8 +2771,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
{
float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
- if (dist >= 0 && dist < hit->dist)
- {
+ if (dist >= 0 && dist < hit->dist) {
hit->index = index;
hit->dist = dist;
hit->no[0] = (quad) ? 1.0f : 0.0f;
@@ -2782,7 +2791,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
* To optimize brush detection speed this doesn't calculate hit normal.
* If ray hit the second half of a quad, no[0] is set to 1.0f, else 0.0f
*/
-static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *co, BVHTreeNearest *nearest)
+static void mesh_faces_nearest_point_dp(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
{
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
MVert *vert = data->vert;
@@ -2801,8 +2810,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *
int vertex, edge;
dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, nearest_tmp);
- if (dist < nearest->dist)
- {
+ if (dist < nearest->dist) {
nearest->index = index;
nearest->dist = dist;
copy_v3_v3(nearest->co, nearest_tmp);
@@ -3190,8 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* check bounding box collision */
if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius))
/* Build a bvh tree from transformed vertices */
- if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8))
- {
+ if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8)) {
int c_index;
int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
@@ -3205,8 +3212,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* loop through cell points and process brush */
#pragma omp parallel for schedule(static)
- for (id = 0; id < grid->s_num[c_index]; id++)
- {
+ for (id = 0; id < grid->s_num[c_index]; id++) {
int index = grid->t_index[grid->s_pos[c_index] + id];
int ss, samples = bData->s_num[index];
float total_sample = (float)samples;
@@ -3222,8 +3228,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
total_sample = gaussianTotal;
/* Supersampling */
- for (ss=0; ss<samples; ss++)
- {
+ for (ss=0; ss<samples; ss++) {
float ray_start[3], ray_dir[3];
float sample_factor = 0.0f;
@@ -3265,8 +3270,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* Check volume collision */
if (brush->collision == MOD_DPAINT_COL_VOLUME || brush->collision == MOD_DPAINT_COL_VOLDIST)
- if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
- {
+ if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) {
/* We hit a triangle, now check if collision point normal is facing the point */
/* For optimization sake, hit point normal isn't calculated in ray cast loop */
@@ -3279,8 +3283,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* If ray and hit face normal are facing same direction
* hit point is inside a closed mesh. */
- if (dot>=0)
- {
+ if (dot>=0) {
float dist = hit.dist;
int f_index = hit.index;
@@ -3337,15 +3340,14 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
else if (brush->ray_dir == MOD_DPAINT_RAY_BRUSH_AVG) {
copy_v3_v3(proj_ray, avg_brushNor);
}
- else { /* MOD_DPAINT_RAY_ZPLUS */
+ else { /* MOD_DPAINT_RAY_ZPLUS */
proj_ray[2] = 1.0f;
}
hit.index = -1;
hit.dist = brush_radius;
/* Do a face normal directional raycast, and use that distance */
- if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
- {
+ if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) {
proxDist = hit.dist;
madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */
hQuad = (hit.no[0] == 1.0f);
@@ -3448,8 +3450,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/*
* Process hit color and alpha
*/
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
- {
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
float sampleColor[3];
float alpha_factor = 1.0f;
@@ -3591,8 +3592,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
BLI_begin_threaded_malloc();
/* only continue if particle bb is close enough to canvas bb */
- if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range))
- {
+ if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) {
int c_index;
int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
@@ -3605,13 +3605,14 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
/* check cell bounding box */
if (!grid->s_num[c_index] ||
- !boundsIntersectDist(&grid->bounds[c_index], &part_bb, range))
+ !boundsIntersectDist(&grid->bounds[c_index], &part_bb, range))
+ {
continue;
+ }
/* loop through cell points */
#pragma omp parallel for schedule(static)
- for (id = 0; id < grid->s_num[c_index]; id++)
- {
+ for (id = 0; id < grid->s_num[c_index]; id++) {
int index = grid->t_index[grid->s_pos[c_index] + id];
float disp_intersect = 0.0f;
float radius = 0.0f;
@@ -3716,8 +3717,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
}
}
- if (strength > 0.001f)
- {
+ if (strength > 0.001f) {
float paintColor[4] = {0.0f};
float depth = 0.0f;
@@ -3783,8 +3783,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po
* Loop through every surface point
*/
#pragma omp parallel for schedule(static)
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
float distance = len_v3v3(pointCoord, bData->realCoord[bData->s_pos[index]].v);
float colorband[4] = {0.0f};
float strength;
@@ -3893,8 +3892,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
if (!bNeighs) return;
#pragma omp parallel for schedule(static)
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = adj_data->n_num[index];
@@ -3913,8 +3911,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
/* calculate average values (single thread) */
bData->average_dist = 0.0f;
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = adj_data->n_num[index];
@@ -4082,8 +4079,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
if (*force) {
#pragma omp parallel for schedule(static)
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
float forc[3] = {0};
/* apply force fields */
@@ -4123,8 +4119,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
}
/* calculate average values (single thread) */
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
average_force += (*force)[index*4+3];
}
average_force /= sData->total_points;
@@ -4173,8 +4168,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
#pragma omp parallel for schedule(static)
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index];
@@ -4216,8 +4210,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
#pragma omp parallel for schedule(static)
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
float totalAlpha = 0.0f;
@@ -4258,8 +4251,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
/*
* Drip Effect
*/
- if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force)
- {
+ if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) {
float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*timescale/2.0f;
/* Copy current surface to the previous points array to read unmodified values */
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
@@ -4337,8 +4329,7 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale)
if (!prevPoint) return;
/* calculate average neigh distance (single thread) */
- for (index = 0; index < sData->total_points; index++)
- {
+ for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
@@ -4437,8 +4428,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time
int index;
#pragma omp parallel for schedule(static)
- for (index=0; index<sData->total_points; index++)
- {
+ for (index=0; index<sData->total_points; index++) {
/* Do drying dissolve effects */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index];
@@ -4653,8 +4643,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
* Prepare each surface point for a new step
*/
#pragma omp parallel for schedule(static)
- for (index=0; index<sData->total_points; index++)
- {
+ for (index=0; index<sData->total_points; index++) {
float prev_point[3] = {0.0f, 0.0f, 0.0f};
if (do_velocity_data && !new_bdata) {
copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v);
@@ -4798,8 +4787,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
else
base = scene->base.first;
- while (base || go)
- {
+ while (base || go) {
brushObj = NULL;
/* select object */
if (surface->brush_group) {
@@ -4823,12 +4811,10 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
/* check if target has an active dp modifier */
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
- if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
- {
+ if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
/* make sure we're dealing with a brush */
- if (pmd2->brush)
- {
+ if (pmd2->brush) {
DynamicPaintBrushSettings *brush = pmd2->brush;
BrushMaterials bMats = {0};
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index b6aebcddd4c..263f89a363e 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -162,7 +162,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
/* no need to ensure the loop order, we know its ok */
else if (f->len == 3) {
- BLI_array_growone(looptris);
+ BLI_array_grow_one(looptris);
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
for (j=0; l; l=BM_iter_step(&liter), j++) {
looptris[i][j] = l;
@@ -171,7 +171,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
}
else if (f->len == 4) {
BMLoop *ltmp[4];
- BLI_array_growitems(looptris, 2);
+ BLI_array_grow_items(looptris, 2);
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
for (j=0; l; l=BM_iter_step(&liter), j++) {
@@ -219,7 +219,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
BLI_addfilledge(&sf_ctx, firstv, v);
totfilltri = BLI_edgefill_ex(&sf_ctx, FALSE, f->no);
- BLI_array_growitems(looptris, totfilltri);
+ BLI_array_grow_items(looptris, totfilltri);
for (efa = sf_ctx.fillfacebase.first; efa; efa=efa->next) {
BMLoop *l1= efa->v1->tmp.p;
@@ -1320,7 +1320,7 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
ev = BM_vert_at_index(bmdm->tc->bm, index); /* warning, does list loop, _not_ ideal */
bmvert_to_mvert(bmdm->tc->bm, ev, vert_r);
- if(bmdm->vertexCos)
+ if (bmdm->vertexCos)
copy_v3_v3(vert_r->co, bmdm->vertexCos[index]);
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index cb8220c8fb3..c275d4ef0ac 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -129,7 +129,7 @@ PartDeflect *object_add_collision_fields(int type)
pd->f_damp = 1.0f;
/* set sensible defaults based on type */
- switch(type) {
+ switch (type) {
case PFIELD_VORTEX:
pd->shape = PFIELD_SHAPE_PLANE;
break;
@@ -419,8 +419,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
len = normalize_v3(norm);
// check all collision objects
- for (col = colls->first; col; col = col->next)
- {
+ for (col = colls->first; col; col = col->next) {
CollisionModifierData *collmd = col->collmd;
if (col->ob == eff->ob)
@@ -506,7 +505,8 @@ 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;
@@ -529,6 +529,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
+ }
}
return falloff;
@@ -622,7 +623,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
ret = psys_get_particle_state(&sim, *efd->index, &state, 0);
/* TODO */
- //if(eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
+ //if (eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
// if (pa->dietime < eff->psys->cfra)
// eff->flag |= PE_VELOCITY_TO_IMPULSE;
//}
@@ -835,7 +836,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);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index bb8cfe37a88..e85432581d5 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -800,7 +800,7 @@ void calchandles_fcurve (FCurve *fcu)
if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0];
/* calculate auto-handles */
- calchandleNurb(bezt, prev, next, 1); /* 1==special autohandle */
+ BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */
/* for automatic ease in and out */
if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) && ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
@@ -1655,8 +1655,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
{
driver->curval= 0.0f;
}
- else
- {
+ else {
/* this evaluates the expression using Python,and returns its result:
* - on errors it reports, then returns 0.0f
*/
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index ed5cf5e7924..0b722aabd4c 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -318,8 +318,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
/* get function pointer to the func to use:
* WARNING: must perform special argument validation hereto guard against crashes
*/
- switch (data->type)
- {
+ switch (data->type) {
/* simple ones */
case FCM_GENERATOR_FN_SIN: /* sine wave */
fn= sin;
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index b2759f18e9b..5d7960a9823 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -68,8 +68,7 @@ void free_vfont(struct VFont *vf)
if (vf == NULL) return;
if (vf->data) {
- while (vf->data->characters.first)
- {
+ while (vf->data->characters.first) {
VChar *che = vf->data->characters.first;
while (che->nurbsbase.first) {
@@ -136,8 +135,7 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont)
// Try finding the font from font list
tmpfnt = ttfdata.first;
- while (tmpfnt)
- {
+ while (tmpfnt) {
if (tmpfnt->vfont == vfont)
break;
tmpfnt = tmpfnt->next;
@@ -280,7 +278,7 @@ VFont *load_vfont(Main *bmain, const char *name)
static VFont *which_vfont(Curve *cu, CharInfo *info)
{
- switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
+ switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
case CU_CHINFO_BOLD:
if (cu->vfontb) return(cu->vfontb); else return(cu->vfont);
case CU_CHINFO_ITALIC:
@@ -397,8 +395,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
nu1 = che->nurbsbase.first;
// Create the character
- while (nu1)
- {
+ while (nu1) {
bezt1 = nu1->bezt;
if (bezt1) {
nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb");
@@ -822,10 +819,15 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
}
else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
- float curofs= 0.0f;
- for (i=0; i<=slen; i++) {
- for (j=i; (mem[j]) && (mem[j]!='\n') &&
- (mem[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
+ float curofs = 0.0f;
+ for (i = 0; i <= slen; i++) {
+ for (j=i; (mem[j]) && (mem[j]!='\n') &&
+ (mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen);
+ j++)
+ {
+ /* pass */
+ }
+
if ((mem[j]!='\r') && (mem[j]!='\n') &&
((chartransdata[j].dobreak!=0))) {
if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr];
@@ -833,7 +835,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0;
ct++;
- }
+ }
}
}
@@ -950,7 +952,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0);
else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr);
else {
- switch(mode) {
+ switch (mode) {
case FO_CURSUP: lnr= ct->linenr-1; break;
case FO_CURSDOWN: lnr= ct->linenr+1; break;
case FO_PAGEUP: lnr= ct->linenr-10; break;
@@ -1009,7 +1011,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if (mode == FO_EDIT) {
/* make nurbdata */
- freeNurblist(&cu->nurb);
+ BKE_nurbList_free(&cu->nurb);
ct= chartransdata;
if (cu->sepchar==0) {
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 1fee5cfa359..dfe73ae20db 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -484,7 +484,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
}
/*
* replaces a property with the same name in a group, or adds
- * it if the propery doesn't exist.
+ * it if the properly doesn't exist.
*/
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{
@@ -581,8 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
static void IDP_FreeGroup(IDProperty *prop)
{
IDProperty *loop;
- for (loop=prop->data.group.first; loop; loop=loop->next)
- {
+ for (loop=prop->data.group.first; loop; loop=loop->next) {
IDP_FreeProperty(loop);
}
BLI_freelistN(&prop->data.group);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 3b91afbc126..5c9c942cc6c 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -578,7 +578,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
ibuf->userflags |= IB_BITMAPDIRTY;
- switch(uvtestgrid) {
+ switch (uvtestgrid) {
case 1:
BKE_image_buf_fill_checker(rect, rect_float, width, height);
break;
@@ -929,7 +929,7 @@ char BKE_ftype_to_imtype(const int ftype)
int BKE_imtype_is_movie(const char imtype)
{
- switch(imtype) {
+ switch (imtype) {
case R_IMF_IMTYPE_AVIRAW:
case R_IMF_IMTYPE_AVIJPEG:
case R_IMF_IMTYPE_AVICODEC:
@@ -946,7 +946,7 @@ int BKE_imtype_is_movie(const char imtype)
int BKE_imtype_supports_zbuf(const char imtype)
{
- switch(imtype) {
+ switch (imtype) {
case R_IMF_IMTYPE_IRIZ:
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
return 1;
@@ -956,7 +956,7 @@ int BKE_imtype_supports_zbuf(const char imtype)
int BKE_imtype_supports_compress(const char imtype)
{
- switch(imtype) {
+ switch (imtype) {
case R_IMF_IMTYPE_PNG:
return 1;
}
@@ -965,7 +965,7 @@ int BKE_imtype_supports_compress(const char imtype)
int BKE_imtype_supports_quality(const char imtype)
{
- switch(imtype) {
+ switch (imtype) {
case R_IMF_IMTYPE_JPEG90:
case R_IMF_IMTYPE_JP2:
case R_IMF_IMTYPE_AVIJPEG:
@@ -979,7 +979,7 @@ char BKE_imtype_valid_channels(const char imtype)
char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */
/* alpha */
- switch(imtype) {
+ switch (imtype) {
case R_IMF_IMTYPE_TARGA:
case R_IMF_IMTYPE_IRIS:
case R_IMF_IMTYPE_PNG:
@@ -995,7 +995,7 @@ char BKE_imtype_valid_channels(const char imtype)
}
/* bw */
- switch(imtype) {
+ switch (imtype) {
case R_IMF_IMTYPE_PNG:
case R_IMF_IMTYPE_JPEG90:
case R_IMF_IMTYPE_TARGA:
@@ -1110,8 +1110,11 @@ int BKE_add_image_extension(char *string, const char imtype)
}
#ifdef WITH_TIFF
else if (imtype==R_IMF_IMTYPE_TIFF) {
- if (!BLI_testextensie(string, ".tif") &&
- !BLI_testextensie(string, ".tiff")) extension= ".tif";
+ if (!BLI_testextensie(string, ".tif") &&
+ !BLI_testextensie(string, ".tiff"))
+ {
+ extension= ".tif";
+ }
}
#endif
#ifdef WITH_OPENEXR
@@ -1148,8 +1151,9 @@ int BKE_add_image_extension(char *string, const char imtype)
if (extension) {
/* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
/* remove any other known image extension */
- if (BLI_testextensie_array(string, imb_ext_image)
- || (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt))) {
+ if (BLI_testextensie_array(string, imb_ext_image) ||
+ (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt)))
+ {
return BLI_replace_extension(string, FILE_MAX, extension);
}
else {
@@ -1162,6 +1166,15 @@ int BKE_add_image_extension(char *string, const char imtype)
}
}
+void BKE_imformat_defaults(ImageFormatData *im_format)
+{
+ memset(im_format, 0, sizeof(*im_format));
+ im_format->planes = R_IMF_PLANES_RGB;
+ im_format->imtype = R_IMF_IMTYPE_PNG;
+ im_format->quality = 90;
+ im_format->compress = 90;
+}
+
/* could allow access externally - 512 is for long names, 64 is for id names */
typedef struct StampData {
char file[512];
@@ -1781,7 +1794,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
if (ima==NULL)
return;
- switch(signal) {
+ switch (signal) {
case IMA_SIGNAL_FREE:
image_free_buffers(ima);
if (iuser)
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 675c0771140..1441bd7b12b 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -169,12 +169,10 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
hue_step= power_of_2_max_i(width / 8);
if (hue_step < 8) hue_step= 8;
- for (y= 0; y < height; y++)
- {
+ for (y= 0; y < height; y++) {
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
- for (x= 0; x < width; x++)
- {
+ for (x= 0; x < width; x++) {
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step);
hsv_to_rgb(hue, sat, val, &r, &g, &b);
@@ -291,12 +289,10 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
BLF_buffer(mono, rect_float, rect, width, height, 4);
- for (y= 0; y < height; y+=step)
- {
+ for (y= 0; y < height; y+=step) {
text[1]= '1';
- for (x= 0; x < width; x+=step)
- {
+ for (x= 0; x < width; x+=step) {
/* hard coded offset */
pen_x = x + 33;
pen_y = y + 44;
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 23aa03b0331..b593419db9f 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -178,8 +178,7 @@ static void print_fvector(float m3[3])
DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
print_fvector(fLongVector[i]);
}
}
@@ -193,8 +192,7 @@ DO_INLINE lfVector *create_lfvector(unsigned int verts)
/* delete long vector */
DO_INLINE void del_lfvector(float (*fLongVector)[3])
{
- if (fLongVector != NULL)
- {
+ if (fLongVector != NULL) {
MEM_freeN (fLongVector);
// cloth_aligned_free(&MEMORY_BASE, fLongVector);
}
@@ -208,8 +206,7 @@ DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
copy_v3_v3(fLongVector[i], vector);
}
}
@@ -223,8 +220,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
mul_fvector_S(to[i], fLongVector[i], scalar);
}
}
@@ -233,8 +229,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
VECSUBMUL(to[i], fLongVector[i], scalar);
}
}
@@ -258,8 +253,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
VECADD(to[i], fLongVectorA[i], fLongVectorB[i]);
}
@@ -269,8 +263,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
VECADDS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
}
@@ -280,8 +273,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
VECADDSS(to[i], fLongVectorA[i], aS, fLongVectorB[i], bS);
}
}
@@ -289,8 +281,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
VECSUBS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
}
@@ -300,8 +291,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
{
unsigned int i = 0;
- for (i = 0; i < verts; i++)
- {
+ for (i = 0; i < verts; i++) {
sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
}
@@ -350,15 +340,12 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
unsigned int i, j;
float d;
- if ((d=det_fmatrix(from))==0)
- {
+ if ((d=det_fmatrix(from)) == 0) {
printf("can't build inverse");
exit(0);
}
- for (i=0;i<3;i++)
- {
- for (j=0;j<3;j++)
- {
+ for (i=0;i<3;i++) {
+ for (j=0;j<3;j++) {
int i1=(i+1)%3;
int i2=(i+2)%3;
int j1=(j+1)%3;
@@ -535,8 +522,7 @@ DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs)
/* delete big matrix */
DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
{
- if (matrix != NULL)
- {
+ if (matrix != NULL) {
MEM_freeN (matrix);
}
}
@@ -554,8 +540,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
{
unsigned int i;
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
cp_fmatrix(matrix[i].m, m3);
}
}
@@ -567,12 +552,10 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
unsigned int i,j;
float tmatrix[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
- for (i = 0; i < matrix[0].vcount; i++)
- {
+ for (i = 0; i < matrix[0].vcount; i++) {
cp_fmatrix(matrix[i].m, m3);
}
- for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++)
- {
+ for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) {
cp_fmatrix(matrix[j].m, tmatrix);
}
}
@@ -581,8 +564,7 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
{
unsigned int i = 0;
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
mul_fmatrix_S(matrix[i].m, scalar);
}
}
@@ -601,15 +583,13 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
{
#pragma omp section
{
- for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++)
- {
+ for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
}
}
#pragma omp section
{
- for (i = 0; i < from[0].vcount+from[0].scount; i++)
- {
+ for (i = 0; i < from[0].vcount+from[0].scount; i++) {
muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
}
}
@@ -627,8 +607,7 @@ DO_INLINE void mul_prevfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVec
{
unsigned int i = 0;
- for (i = 0; i < from[0].vcount; i++)
- {
+ for (i = 0; i < from[0].vcount; i++) {
mul_fmatrix_fvector(to[from[i].r], from[i].m, fLongVector[from[i].c]);
}
}
@@ -639,8 +618,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -651,8 +629,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -663,8 +640,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -675,8 +651,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -687,8 +662,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount; i++)
- {
+ for (i = 0; i < matrix[0].vcount; i++) {
sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m);
}
@@ -699,8 +673,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -713,8 +686,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
- {
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
}
@@ -772,12 +744,10 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
id->dV = create_lfvector(cloth->numverts);
id->z = create_lfvector(cloth->numverts);
- for (i=0;i<cloth->numverts;i++)
- {
+ for (i=0;i<cloth->numverts;i++) {
id->A[i].r = id->A[i].c = id->dFdV[i].r = id->dFdV[i].c = id->dFdX[i].r = id->dFdX[i].c = id->P[i].c = id->P[i].r = id->Pinv[i].c = id->Pinv[i].r = id->bigI[i].c = id->bigI[i].r = id->M[i].r = id->M[i].c = i;
- if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
- {
+ if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
id->S[pinned].pinned = 1;
id->S[pinned].c = id->S[pinned].r = i;
pinned++;
@@ -791,8 +761,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
// init springs
search = cloth->springs;
- for (i=0;i<cloth->numsprings;i++)
- {
+ for (i=0;i<cloth->numsprings;i++) {
spring = search->link;
// dFdV_start[i].r = big_I[i].r = big_zero[i].r =
@@ -810,8 +779,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
initdiag_bfmatrix(id->bigI, I);
- for (i = 0; i < cloth->numverts; i++)
- {
+ for (i = 0; i < cloth->numverts; i++) {
copy_v3_v3(id->X[i], verts[i].x);
}
@@ -823,12 +791,10 @@ int implicit_free (ClothModifierData *clmd)
Cloth *cloth;
cloth = (Cloth *)clmd->clothObject;
- if (cloth)
- {
+ if (cloth) {
id = cloth->implicit;
- if (id)
- {
+ if (id) {
del_bfmatrix(id->A);
del_bfmatrix(id->dFdV);
del_bfmatrix(id->dFdX);
@@ -886,12 +852,10 @@ DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
float tempfb = kb * fb(length, L);
float fbstar = cb * (length - L);
- if (tempfb < fbstar)
- {
+ if (tempfb < fbstar) {
return cb;
}
- else
- {
+ else {
return kb * fbderiv(length, L);
}
}
@@ -900,8 +864,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
{
unsigned int i=0;
- for (i=0;i<S[0].vcount;i++)
- {
+ for (i = 0; i < S[0].vcount; i++) {
mul_fvector_fmatrix(V[S[i].r], V[S[i].r], S[i].m);
}
}
@@ -936,8 +899,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
s = dot_lfvector(r, r, numverts);
starget = s * sqrt(conjgrad_epsilon);
- while (s>starget && conjgrad_loopcount < conjgrad_looplimit)
- {
+ while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
// Mul(q,A,d); // q = A*d;
mul_bfmatrix_lfvector(q, lA, d);
@@ -979,8 +941,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
// Take only the diagonal blocks of A
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
- for (i = 0; i<lA[0].vcount; i++)
- {
+ for (i = 0; i<lA[0].vcount; i++) {
// block diagonalizer
cp_fmatrix(P[i].m, lA[i].m);
inverse_fmatrix(Pinv[i].m, P[i].m);
@@ -1255,13 +1216,12 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
- if (length > ALMOST_ZERO)
- {
+ if (length > ALMOST_ZERO) {
/*
if (length>L)
{
- if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)
- && ((((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen))) // cut spring!
+ if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
+ ((((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen))) // cut spring!
{
s->flags |= CSPRING_FLAG_DEACTIVATE;
return;
@@ -1270,16 +1230,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
*/
mul_fvector_S(dir, extent, 1.0f/length);
}
- else
- {
+ else {
mul_fvector_S(dir, extent, 0.0f);
}
// calculate force of structural + shear springs
- if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR))
- {
- if (length > L || no_compress)
- {
+ if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) {
+ if (length > L || no_compress) {
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
k = clmd->sim_parms->structural;
@@ -1337,10 +1294,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
// dfdx_spring(s->dfdx, dir, length, 0.0, k);
// dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0)));
}
- else // calculate force of bending springs
- {
- if (length < L)
- {
+ else { /* calculate force of bending springs */
+ if (length < L) {
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
k = clmd->sim_parms->bending;
@@ -1358,10 +1313,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSpring *s, lfVector *lF, lfVector *UNUSED(X), lfVector *UNUSED(V), fmatrix3x3 *dFdV, fmatrix3x3 *dFdX)
{
- if (s->flags & CLOTH_SPRING_FLAG_NEEDED)
- {
- if (!(s->type & CLOTH_SPRING_TYPE_BENDING))
- {
+ if (s->flags & CLOTH_SPRING_FLAG_NEEDED) {
+ if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) {
sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv);
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
@@ -1424,9 +1377,9 @@ typedef struct HairGridVert {
#define HAIR_GRID_INDEX(vec, min, max, axis) (int)((vec[axis] - min[axis]) / (max[axis] - min[axis]) * 9.99f)
/* Smoothing of hair velocities:
* adapted from
- Volumetric Methods for Simulation and Rendering of Hair
- by Lena Petrovic, Mark Henne and John Anderson
- * Pixar Technical Memo #06-08, Pixar Animation Studios
+ * Volumetric Methods for Simulation and Rendering of Hair
+ * by Lena Petrovic, Mark Henne and John Anderson
+ * Pixar Technical Memo #06-08, Pixar Animation Studios
*/
static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVector *lV, unsigned int numverts)
{
@@ -1486,8 +1439,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
}
/* gather colliders */
- if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next)
- {
+ if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next) {
MVert *loc0 = col->collmd->x;
MVert *loc1 = col->collmd->xnew;
float vel[3];
@@ -1591,10 +1543,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
hair_velocity_smoothing(clmd, lF, lX, lV, numverts);
/* multiply lF with mass matrix
- // force = mass * acceleration (in this case: gravity)
- */
- for (i = 0; i < numverts; i++)
- {
+ * force = mass * acceleration (in this case: gravity)
+ */
+ for (i = 0; i < numverts; i++) {
float temp[3];
copy_v3_v3(temp, lF[i]);
mul_fmatrix_fvector(lF[i], M[i].m, temp);
@@ -1603,8 +1554,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
submul_lfvectorS(lF, lV, spring_air, numverts);
/* handle external forces like wind */
- if (effectors)
- {
+ if (effectors) {
// 0 = force, 1 = normalized force
winvec = create_lfvector(cloth->numverts);
@@ -1612,14 +1562,12 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
printf("winvec: out of memory in implicit.c\n");
// precalculate wind forces
- for (i = 0; i < cloth->numverts; i++)
- {
+ for (i = 0; i < cloth->numverts; i++) {
pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);
pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
}
- for (i = 0; i < cloth->numfaces; i++)
- {
+ for (i = 0; i < cloth->numfaces; i++) {
float trinormal[3]={0,0,0}; // normalized triangle normal
float triunnormal[3]={0,0,0}; // not-normalized-triangle normal
float tmp[3]={0,0,0};
@@ -1650,8 +1598,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
// add wind from v4
- if (mfaces[i].v4)
- {
+ if (mfaces[i].v4) {
copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
@@ -1692,8 +1639,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
// calculate spring forces
search = cloth->springs;
- while (search)
- {
+ 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)) {}
cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time);
@@ -1703,8 +1649,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
// apply spring forces
search = cloth->springs;
- while (search)
- {
+ 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))
cloth_apply_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX);
@@ -1745,10 +1690,10 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect
del_lfvector(dFdXmV);
}
-/*computes where the cloth would be if it were subject to perfectly stiff edges
- (edge distance constraints) in a lagrangian solver. then add forces to help
- guide the implicit solver to that state. this function is called after
- collisions*/
+/* computes where the cloth would be if it were subject to perfectly stiff edges
+ * (edge distance constraints) in a lagrangian solver. then add forces to help
+ * guide the implicit solver to that state. this function is called after
+ * collisions*/
int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt)
{
Cloth *cloth= clmd->clothObject;
@@ -1836,21 +1781,17 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
Implicit_Data *id = cloth->implicit;
int do_extra_solve;
- if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
- {
- for (i = 0; i < numverts; i++)
- {
+ if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */
+ for (i = 0; i < numverts; i++) {
// update velocities with constrained velocities from pinned verts
- if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
- {
+ if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold);
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
}
}
}
- while (step < tf)
- {
+ while (step < tf) {
// damping velocity for artistic reasons
mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
@@ -1864,13 +1805,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts);
/* move pinned verts to correct position */
- for (i = 0; i < numverts; i++)
- {
- if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
- {
- if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
- {
- float tvect[3] = {.0,.0,.0};
+ for (i = 0; i < numverts; i++) {
+ if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) {
+ if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
+ float tvect[3] = {0.0f, 0.0f, 0.0f};
sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold);
mul_fvector_S(tvect, tvect, step+dt);
VECADD(tvect, tvect, verts[i].xold);
@@ -1881,14 +1819,12 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
copy_v3_v3(verts[i].txold, id->X[i]);
}
- if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
- {
+ if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) {
// collisions
// itstart();
// update verts to current positions
- for (i = 0; i < numverts; i++)
- {
+ for (i = 0; i < numverts; i++) {
copy_v3_v3(verts[i].tx, id->Xnew[i]);
sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold);
@@ -1904,8 +1840,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
// copy corrected positions back to simulation
- for (i = 0; i < numverts; i++)
- {
+ for (i = 0; i < numverts; i++) {
// correct velocity again, just to be sure we had to change it due to adaptive collisions
sub_v3_v3v3(verts[i].tv, verts[i].tx, id->X[i]);
}
@@ -1913,11 +1848,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
//if (do_extra_solve)
// cloth_calc_helper_forces(ob, clmd, initial_cos, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
- for (i = 0; i < numverts; i++)
- {
+ for (i = 0; i < numverts; i++) {
- if (do_extra_solve)
- {
+ if (do_extra_solve) {
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
continue;
@@ -1933,8 +1866,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// if there were collisions, advance the velocity from v_n+1/2 to v_n+1
- if (do_extra_solve)
- {
+ if (do_extra_solve) {
// V = Vnew;
cp_lfvector(id->V, id->Vnew, numverts);
@@ -1944,8 +1876,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI);
}
}
- else
- {
+ else {
// X = Xnew;
cp_lfvector(id->X, id->Xnew, numverts);
}
@@ -1959,16 +1890,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
step += dt;
}
- for (i = 0; i < numverts; i++)
- {
- if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
- {
+ for (i = 0; i < numverts; i++) {
+ if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) {
copy_v3_v3(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x
copy_v3_v3(verts[i].x, verts[i].xconst);
copy_v3_v3(verts[i].v, id->V[i]);
}
- else
- {
+ else {
copy_v3_v3(verts[i].txold, id->X[i]);
copy_v3_v3(verts[i].x, id->X[i]);
copy_v3_v3(verts[i].v, id->V[i]);
@@ -1987,8 +1915,7 @@ void implicit_set_positions (ClothModifierData *clmd)
unsigned int numverts = cloth->numverts, i;
Implicit_Data *id = cloth->implicit;
- for (i = 0; i < numverts; i++)
- {
+ for (i = 0; i < numverts; i++) {
copy_v3_v3(id->X[i], verts[i].x);
copy_v3_v3(id->V[i], verts[i].v);
}
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index c1b5d07de4a..c33bb973385 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1105,20 +1105,18 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
/* get the group to use */
agrp= action_groups_find_named(&tmp_act, grpname);
+ /* no matching group, so add one */
if (agrp == NULL) {
- /* no matching group, so add one */
- if (agrp == NULL) {
- /* Add a new group, and make it active */
- agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
-
- agrp->flag = AGRP_SELECTED;
- if (muteipo) agrp->flag |= AGRP_MUTED;
-
- BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
-
- BLI_addtail(&tmp_act.groups, agrp);
- BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
- }
+ /* Add a new group, and make it active */
+ agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
+
+ agrp->flag = AGRP_SELECTED;
+ if (muteipo) agrp->flag |= AGRP_MUTED;
+
+ BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
+
+ BLI_addtail(&tmp_act.groups, agrp);
+ BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
}
/* add F-Curve to group */
@@ -1908,7 +1906,7 @@ void do_versions_ipos_to_animato(Main *main)
AnimData *adt= BKE_id_add_animdata(id);
- SEQ_BEGIN(ed, seq) {
+ SEQ_BEGIN (ed, seq) {
IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
short adrcode = SEQ_FAC1;
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 0a1c0467244..54a2613991a 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1594,7 +1594,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
int a, tot;
/* count */
- tot = count_curveverts(nurb);
+ tot = BKE_nurbList_verts_count(nurb);
if (tot == 0) return;
if (kb->data) MEM_freeN(kb->data);
@@ -1647,7 +1647,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
nu = nurb->first;
fp = kb->data;
- tot = count_curveverts(nurb);
+ tot = BKE_nurbList_verts_count(nurb);
tot = MIN2(kb->totelem, tot);
@@ -1742,7 +1742,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3]
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = (Curve *)ob->data;
- tot = count_curveverts(&cu->nurb);
+ tot = BKE_nurbList_verts_count(&cu->nurb);
}
if (tot == 0) return NULL;
@@ -1822,7 +1822,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = (Curve *)ob->data;
elemsize = cu->key->elemsize;
- tot = count_curveverts(&cu->nurb);
+ tot = BKE_nurbList_verts_count(&cu->nurb);
}
if (tot == 0) {
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index f182d7bcb7c..12f11a9dee1 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -342,7 +342,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
}
}
-void calc_latt_deform(Object *ob, float *co, float weight)
+void calc_latt_deform(Object *ob, float co[3], float weight)
{
Lattice *lt= ob->data;
float u, v, w, tu[4], tv[4], tw[4];
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index b4dec452f8c..8612e9f2b97 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -183,7 +183,7 @@ int id_make_local(ID *id, int test)
if (id->flag & LIB_INDIRECT)
return 0;
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_SCE:
return 0; /* not implemented */
case ID_LI:
@@ -199,12 +199,12 @@ int id_make_local(ID *id, int test)
return 1;
case ID_CU:
if (!test) {
- make_local_curve((Curve*)id);
+ BKE_curve_make_local((Curve*)id);
make_local_key(((Curve*)id)->key);
}
return 1;
case ID_MB:
- if (!test) make_local_mball((MetaBall*)id);
+ if (!test) BKE_metaball_make_local((MetaBall*)id);
return 1;
case ID_MA:
if (!test) make_local_material((Material*)id);
@@ -282,7 +282,7 @@ int id_copy(ID *id, ID **newid, int test)
/* conventions:
* - make shallow copy, only this ID block
* - id.us of the new ID is set to 1 */
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_SCE:
return 0; /* can't be copied from here */
case ID_LI:
@@ -294,10 +294,10 @@ int id_copy(ID *id, ID **newid, int test)
if (!test) *newid= (ID*)copy_mesh((Mesh*)id);
return 1;
case ID_CU:
- if (!test) *newid= (ID*)copy_curve((Curve*)id);
+ if (!test) *newid= (ID*)BKE_curve_copy((Curve*)id);
return 1;
case ID_MB:
- if (!test) *newid= (ID*)copy_mball((MetaBall*)id);
+ if (!test) *newid= (ID*)BKE_metaball_copy((MetaBall*)id);
return 1;
case ID_MA:
if (!test) *newid= (ID*)copy_material((Material*)id);
@@ -374,7 +374,7 @@ int id_unlink(ID *id, int test)
Main *mainlib= G.main;
ListBase *lb;
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_TXT:
if (test) return 1;
unlink_text(mainlib, (Text*)id);
@@ -431,7 +431,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
ListBase *which_libbase(Main *mainlib, short type)
{
- switch( type ) {
+ switch ( type ) {
case ID_SCE:
return &(mainlib->scene);
case ID_LI:
@@ -598,7 +598,7 @@ static ID *alloc_libblock_notest(short type)
{
ID *id= NULL;
- switch( type ) {
+ switch ( type ) {
case ID_SCE:
id= MEM_callocN(sizeof(Scene), "scene");
break;
@@ -808,7 +808,7 @@ void free_libblock(ListBase *lb, void *idv)
BPY_id_release(id);
#endif
- switch( GS(id->name) ) { /* GetShort from util.h */
+ switch ( GS(id->name) ) { /* GetShort from util.h */
case ID_SCE:
free_scene((Scene *)id);
break;
@@ -822,10 +822,10 @@ void free_libblock(ListBase *lb, void *idv)
free_mesh((Mesh *)id, 1);
break;
case ID_CU:
- free_curve((Curve *)id);
+ BKE_curve_free((Curve *)id);
break;
case ID_MB:
- free_mball((MetaBall *)id);
+ BKE_metaball_free((MetaBall *)id);
break;
case ID_MA:
free_material((Material *)id);
@@ -898,7 +898,7 @@ void free_libblock(ListBase *lb, void *idv)
free_gpencil_data((bGPdata *)id);
break;
case ID_MC:
- free_movieclip((MovieClip *)id);
+ BKE_movieclip_free((MovieClip *)id);
break;
case ID_LS:
FRS_free_linestyle((FreestyleLineStyle *)id);
@@ -1025,8 +1025,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
BLI_dynstr_append(pupds, numstr);
/* icon */
- switch(GS(id->name))
- {
+ switch (GS(id->name)) {
case ID_MA: /* fall through */
case ID_TE: /* fall through */
case ID_IM: /* fall through */
@@ -1070,6 +1069,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra
}
/* skips viewer images */
+#if 0 /* unused */
void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr)
{
DynStr *pupds= BLI_dynstr_new();
@@ -1090,6 +1090,7 @@ void IMAnames_to_pupstring(const char **str, const char *title, const char *extr
*str= BLI_dynstr_get_cstring(pupds);
BLI_dynstr_free(pupds);
}
+#endif
void id_sort_by_name(ListBase *lb, ID *id)
{
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index f962881cd52..6ddbf56605a 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -494,7 +494,7 @@ short *give_totcolp(Object *ob)
/* same as above but for ID's */
Material ***give_matarar_id(ID *id)
{
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_ME:
return &(((Mesh *)id)->mat);
break;
@@ -510,7 +510,7 @@ Material ***give_matarar_id(ID *id)
short *give_totcolp_id(ID *id)
{
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_ME:
return &(((Mesh *)id)->totcol);
break;
@@ -526,12 +526,12 @@ short *give_totcolp_id(ID *id)
static void data_delete_material_index_id(ID *id, short index)
{
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_ME:
mesh_delete_material_index((Mesh *)id, index);
break;
case ID_CU:
- curve_delete_material_index((Curve *)id, index);
+ BKE_curve_delete_material_index((Curve *)id, index);
break;
case ID_MB:
/* meta-elems don't have materials atm */
@@ -1053,7 +1053,7 @@ int material_in_material(Material *parmat, Material *mat)
}
/* ****************** */
-
+#if 0 /* UNUSED */
static char colname_array[125][20]= {
"Black","DarkRed","HalfRed","Red","Red",
"DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed",
@@ -1099,7 +1099,7 @@ void automatname(Material *ma)
new_id(&G.main->mat, (ID *)ma, colname_array[nr]);
}
-
+#endif
int object_remove_material_slot(Object *ob)
{
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index da5e02c17f1..73e3576b57f 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -65,6 +65,106 @@
#include "BKE_object.h"
#include "BKE_material.h"
+/* Data types */
+
+typedef struct point { /* a three-dimensional point */
+ float x, y, z; /* its coordinates */
+} MB_POINT;
+
+typedef struct vertex { /* surface vertex */
+ MB_POINT position, normal; /* position and surface normal */
+} VERTEX;
+
+typedef struct vertices { /* list of vertices in polygonization */
+ int count, max; /* # vertices, max # allowed */
+ VERTEX *ptr; /* dynamically allocated */
+} VERTICES;
+
+typedef struct corner { /* corner of a cube */
+ int i, j, k; /* (i, j, k) is index within lattice */
+ float x, y, z, value; /* location and function value */
+ struct corner *next;
+} CORNER;
+
+typedef struct cube { /* partitioning cell (cube) */
+ int i, j, k; /* lattice location of cube */
+ CORNER *corners[8]; /* eight corners */
+} CUBE;
+
+typedef struct cubes { /* linked list of cubes acting as stack */
+ CUBE cube; /* a single cube */
+ struct cubes *next; /* remaining elements */
+} CUBES;
+
+typedef struct centerlist { /* list of cube locations */
+ int i, j, k; /* cube location */
+ struct centerlist *next; /* remaining elements */
+} CENTERLIST;
+
+typedef struct edgelist { /* list of edges */
+ int i1, j1, k1, i2, j2, k2; /* edge corner ids */
+ int vid; /* vertex id */
+ struct edgelist *next; /* remaining elements */
+} EDGELIST;
+
+typedef struct intlist { /* list of integers */
+ int i; /* an integer */
+ struct intlist *next; /* remaining elements */
+} INTLIST;
+
+typedef struct intlists { /* list of list of integers */
+ INTLIST *list; /* a list of integers */
+ struct intlists *next; /* remaining elements */
+} INTLISTS;
+
+typedef struct process { /* parameters, function, storage */
+ /* what happens here? floats, I think. */
+ /* float (*function)(void); */ /* implicit surface function */
+ float (*function)(float, float, float);
+ float size, delta; /* cube size, normal delta */
+ int bounds; /* cube range within lattice */
+ CUBES *cubes; /* active cubes */
+ VERTICES vertices; /* surface vertices */
+ CENTERLIST **centers; /* cube center hash table */
+ CORNER **corners; /* corner value hash table */
+ EDGELIST **edges; /* edge and vertex id hash table */
+} PROCESS;
+
+/* dividing scene using octal tree makes polygonisation faster */
+typedef struct ml_pointer {
+ struct ml_pointer *next, *prev;
+ struct MetaElem *ml;
+} ml_pointer;
+
+typedef struct octal_node {
+ struct octal_node *nodes[8]; /* children of current node */
+ struct octal_node *parent; /* parent of current node */
+ struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */
+ float x_min, y_min, z_min; /* 1st border point */
+ float x_max, y_max, z_max; /* 7th border point */
+ float x,y,z; /* center of node */
+ int pos, neg; /* number of positive and negative MetaElements in the node */
+ int count; /* number of MetaElems, which belongs to the node */
+} octal_node;
+
+typedef struct octal_tree {
+ struct octal_node *first; /* first node */
+ int pos, neg; /* number of positive and negative MetaElements in the scene */
+ short depth; /* number of scene subdivision */
+} octal_tree;
+
+struct pgn_elements {
+ struct pgn_elements *next, *prev;
+ char *data;
+};
+
+/* Forward declarations */
+static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb);
+static int setcenter(CENTERLIST *table[], int i, int j, int k);
+static CORNER *setcorner(PROCESS* p, int i, int j, int k);
+static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
+ float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f);
+
/* Global variables */
static float thresh= 0.6f;
@@ -73,7 +173,7 @@ static MetaElem **mainb;
static octal_tree *metaball_tree = NULL;
/* Functions */
-void unlink_mball(MetaBall *mb)
+void BKE_metaball_unlink(MetaBall *mb)
{
int a;
@@ -85,9 +185,9 @@ void unlink_mball(MetaBall *mb)
/* do not free mball itself */
-void free_mball(MetaBall *mb)
+void BKE_metaball_free(MetaBall *mb)
{
- unlink_mball(mb);
+ BKE_metaball_unlink(mb);
if (mb->adt) {
BKE_free_animdata((ID *)mb);
@@ -99,7 +199,7 @@ void free_mball(MetaBall *mb)
if (mb->disp.first) freedisplist(&mb->disp);
}
-MetaBall *add_mball(const char *name)
+MetaBall *BKE_metaball_add(const char *name)
{
MetaBall *mb;
@@ -115,7 +215,7 @@ MetaBall *add_mball(const char *name)
return mb;
}
-MetaBall *copy_mball(MetaBall *mb)
+MetaBall *BKE_metaball_copy(MetaBall *mb)
{
MetaBall *mbn;
int a;
@@ -143,7 +243,7 @@ static void extern_local_mball(MetaBall *mb)
}
}
-void make_local_mball(MetaBall *mb)
+void BKE_metaball_make_local(MetaBall *mb)
{
Main *bmain= G.main;
Object *ob;
@@ -174,7 +274,7 @@ void make_local_mball(MetaBall *mb)
extern_local_mball(mb);
}
else if (is_local && is_lib) {
- MetaBall *mb_new= copy_mball(mb);
+ MetaBall *mb_new= BKE_metaball_copy(mb);
mb_new->id.us= 0;
/* Remap paths of new ID using old library as base. */
@@ -194,7 +294,7 @@ void make_local_mball(MetaBall *mb)
/* most simple meta-element adding function
* don't do context manipulation here (rna uses) */
-MetaElem *add_metaball_element(MetaBall *mb, const int type)
+MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type)
{
MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem");
@@ -204,7 +304,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type)
ml->s= 2.0;
ml->flag= MB_SCALE_RAD;
- switch(type) {
+ switch (type) {
case MB_BALL:
ml->type = MB_BALL;
ml->expx= ml->expy= ml->expz= 1.0;
@@ -246,7 +346,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type)
* basic MetaBall (usually with name Meta). All other MetaBalls (with
* names Meta.001, Meta.002, etc) are included in this Bounding Box.
*/
-void tex_space_mball(Object *ob)
+void BKE_metaball_tex_space_calc(Object *ob)
{
DispList *dl;
BoundBox *bb;
@@ -290,7 +390,7 @@ void tex_space_mball(Object *ob)
boundbox_set_from_min_max(bb, min, max);
}
-float *make_orco_mball(Object *ob, ListBase *dispbase)
+float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase)
{
BoundBox *bb;
DispList *dl;
@@ -342,7 +442,7 @@ float *make_orco_mball(Object *ob, ListBase *dispbase)
* It test last character of Object ID name. If last character
* is digit it return 0, else it return 1.
*/
-int is_basis_mball(Object *ob)
+int BKE_metaball_is_basis(Object *ob)
{
int len;
@@ -353,7 +453,7 @@ int is_basis_mball(Object *ob)
}
/* return nonzero if ob1 is a basis mball for ob */
-int is_mball_basis_for (Object *ob1, Object *ob2)
+int BKE_metaball_is_basis_for (Object *ob1, Object *ob2)
{
int basis1nr, basis2nr;
char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME];
@@ -361,7 +461,7 @@ int is_mball_basis_for (Object *ob1, Object *ob2)
BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.');
BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.');
- if (!strcmp(basis1name, basis2name)) return is_basis_mball(ob1);
+ if (!strcmp(basis1name, basis2name)) return BKE_metaball_is_basis(ob1);
else return 0;
}
@@ -371,7 +471,7 @@ int is_mball_basis_for (Object *ob1, Object *ob2)
* are copied to all metaballs in same "group" (metaballs with same base name: MBall,
* MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball,
* because this metaball influence polygonisation of metaballs. */
-void copy_mball_properties(Scene *scene, Object *active_object)
+void BKE_metaball_properties_copy(Scene *scene, Object *active_object)
{
Scene *sce_iter= scene;
Base *base;
@@ -416,7 +516,7 @@ void copy_mball_properties(Scene *scene, Object *active_object)
*
* warning!, is_basis_mball() can fail on returned object, see long note above.
*/
-Object *find_basis_mball(Scene *scene, Object *basis)
+Object *BKE_metaball_basis_find(Scene *scene, Object *basis)
{
Scene *sce_iter= scene;
Base *base;
@@ -522,14 +622,14 @@ Object *find_basis_mball(Scene *scene, Object *basis)
/* **************** POLYGONIZATION ************************ */
-void calc_mballco(MetaElem *ml, float vec[3])
+static void calc_mballco(MetaElem *ml, float vec[3])
{
if (ml->mat) {
- mul_m4_v3((float ( * )[4])ml->mat, vec);
+ mul_m4_v3((float (*)[4])ml->mat, vec);
}
}
-float densfunc(MetaElem *ball, float x, float y, float z)
+static float densfunc(MetaElem *ball, float x, float y, float z)
{
float dist2 = 0.0, dx, dy, dz;
float vec[3];
@@ -537,7 +637,7 @@ float densfunc(MetaElem *ball, float x, float y, float z)
vec[0]= x;
vec[1]= y;
vec[2]= z;
- mul_m4_v3((float ( * )[4])ball->imat, vec);
+ mul_m4_v3((float (*)[4])ball->imat, vec);
dx= vec[0];
dy= vec[1];
dz= vec[2];
@@ -605,7 +705,7 @@ float densfunc(MetaElem *ball, float x, float y, float z)
}
}
-octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth)
+static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth)
{
if (!depth) return node;
@@ -673,7 +773,7 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z
return node;
}
-float metaball(float x, float y, float z)
+static float metaball(float x, float y, float z)
/* float x, y, z; */
{
struct octal_node *node;
@@ -713,7 +813,7 @@ static int *indices=NULL;
static int totindex, curindex;
-void accum_mballfaces(int i1, int i2, int i3, int i4)
+static void accum_mballfaces(int i1, int i2, int i3, int i4)
{
int *newi, *cur;
/* static int i=0; I would like to delete altogether, but I don't dare to, yet */
@@ -746,7 +846,7 @@ void accum_mballfaces(int i1, int i2, int i3, int i4)
}
/* ******************* MEMORY MANAGEMENT *********************** */
-void *new_pgn_element(int size)
+static void *new_pgn_element(int size)
{
/* during polygonize 1000s of elements are allocated
* and never freed in between. Freeing only done at the end.
@@ -789,7 +889,7 @@ void *new_pgn_element(int size)
return cur->data;
}
-void freepolygonize(PROCESS *p)
+static void freepolygonize(PROCESS *p)
{
MEM_freeN(p->corners);
MEM_freeN(p->edges);
@@ -832,7 +932,7 @@ static int rightface[12] = {
/* docube: triangulate the cube directly, without decomposition */
-void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
+static void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
{
INTLISTS *polys;
CORNER *c1, *c2;
@@ -853,7 +953,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
count++;
}
if (count>2) {
- switch(count) {
+ switch (count) {
case 3:
accum_mballfaces(indexar[2], indexar[1], indexar[0], 0);
break;
@@ -900,7 +1000,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
* if surface crosses face, compute other four corners of adjacent cube
* and add new cube to cube stack */
-void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p)
+static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p)
{
CUBE newc;
CUBES *oldcubes = p->cubes;
@@ -951,7 +1051,7 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i
/* setcorner: return corner with the given lattice location
* set (and cache) its function value */
-CORNER *setcorner (PROCESS* p, int i, int j, int k)
+static CORNER *setcorner (PROCESS* p, int i, int j, int k)
{
/* for speed, do corner value caching here */
CORNER *c;
@@ -986,7 +1086,7 @@ CORNER *setcorner (PROCESS* p, int i, int j, int k)
/* nextcwedge: return next clockwise edge from given edge around given face */
-int nextcwedge (int edge, int face)
+static int nextcwedge (int edge, int face)
{
switch (edge) {
case LB:
@@ -1020,7 +1120,7 @@ int nextcwedge (int edge, int face)
/* otherface: return face adjoining edge that is not the given face */
-int otherface (int edge, int face)
+static int otherface (int edge, int face)
{
int other = leftface[edge];
return face == other? rightface[edge] : other;
@@ -1029,7 +1129,7 @@ int otherface (int edge, int face)
/* makecubetable: create the 256 entry table for cubical polygonization */
-void makecubetable (void)
+static void makecubetable (void)
{
static int isdone= 0;
int i, e, c, done[12], pos[8];
@@ -1070,7 +1170,7 @@ void makecubetable (void)
}
}
-void BKE_freecubetable(void)
+void BKE_metaball_cubeTable_free(void)
{
int i;
INTLISTS *lists, *nlists;
@@ -1100,7 +1200,7 @@ void BKE_freecubetable(void)
/* setcenter: set (i,j,k) entry of table[]
* return 1 if already set; otherwise, set and return 0 */
-int setcenter(CENTERLIST *table[], int i, int j, int k)
+static int setcenter(CENTERLIST *table[], int i, int j, int k)
{
int index;
CENTERLIST *newc, *l, *q;
@@ -1125,7 +1225,7 @@ int setcenter(CENTERLIST *table[], int i, int j, int k)
/* setedge: set vertex id for edge */
-void setedge (EDGELIST *table[],
+static void setedge (EDGELIST *table[],
int i1, int j1,
int k1, int i2,
int j2, int k2,
@@ -1161,7 +1261,7 @@ void setedge (EDGELIST *table[],
/* getedge: return vertex id for edge; return -1 if not set */
-int getedge (EDGELIST *table[],
+static int getedge (EDGELIST *table[],
int i1, int j1, int k1,
int i2, int j2, int k2)
{
@@ -1179,10 +1279,13 @@ int getedge (EDGELIST *table[],
k2=t;
}
q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)];
- for (; q != NULL; q = q->next)
+ for (; q != NULL; q = q->next) {
if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 &&
q->i2 == i2 && q->j2 == j2 && q->k2 == k2)
+ {
return q->vid;
+ }
+ }
return -1;
}
@@ -1199,7 +1302,7 @@ int getedge (EDGELIST *table[],
/* addtovertices: add v to sequence of vertices */
-void addtovertices (VERTICES *vertices, VERTEX v)
+static void addtovertices (VERTICES *vertices, VERTEX v)
{
if (vertices->count == vertices->max) {
int i;
@@ -1217,7 +1320,7 @@ void addtovertices (VERTICES *vertices, VERTEX v)
/* vnormal: compute unit length surface normal at point */
-void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
+static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
{
float delta= 0.2f*p->delta;
float f = p->function(point->x, point->y, point->z);
@@ -1267,7 +1370,7 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
}
-int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb)
+static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb)
{
VERTEX v;
MB_POINT a, b;
@@ -1296,7 +1399,7 @@ int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb)
/* converge: from two points of differing sign, converge to zero crossing */
/* watch it: p1 and p2 are used to calculate */
-void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
+static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f)
{
int i = 0;
@@ -1396,7 +1499,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
}
/* ************************************** */
-void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
+static void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
{
CUBES *ncube;
int n;
@@ -1426,7 +1529,7 @@ void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
}
-void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
+static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
{
MB_POINT IN, in, OUT, out; /*point;*/
MetaElem *ml;
@@ -1546,7 +1649,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
}
}
-void polygonize(PROCESS *mbproc, MetaBall *mb)
+static void polygonize(PROCESS *mbproc, MetaBall *mb)
{
CUBE c;
int a;
@@ -1586,7 +1689,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb)
}
}
-float init_meta(Scene *scene, Object *ob) /* return totsize */
+static float init_meta(Scene *scene, Object *ob) /* return totsize */
{
Scene *sce_iter= scene;
Base *base;
@@ -1738,7 +1841,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* transformation of Metalem bb */
for (i=0; i<8; i++)
- mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]);
+ mul_m4_v3((float (*)[4])mat, mainb[a]->bb->vec[i]);
/* find max and min of transformed bb */
for (i=0; i<8; i++) {
@@ -1812,7 +1915,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* if MetaElem lies in node, then node includes MetaElem pointer (ml_p)
* pointing at MetaElem (ml)
*/
-void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
+static void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
{
ml_pointer *ml_p;
@@ -1844,7 +1947,7 @@ void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
* +------+------+
*
*/
-void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth)
+static void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth)
{
MetaElem *ml;
ml_pointer *ml_p;
@@ -2101,7 +2204,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
/* free all octal nodes recursively */
-void free_metaball_octal_node(octal_node *node)
+static void free_metaball_octal_node(octal_node *node)
{
int a;
for (a=0;a<8;a++) {
@@ -2112,7 +2215,7 @@ void free_metaball_octal_node(octal_node *node)
}
/* If scene include more then one MetaElem, then octree is used */
-void init_metaball_octal_tree(int depth)
+static void init_metaball_octal_tree(int depth)
{
struct octal_node *node;
ml_pointer *ml_p;
@@ -2170,7 +2273,7 @@ void init_metaball_octal_tree(int depth)
subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth);
}
-void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
+void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
{
PROCESS mbproc;
MetaBall *mb;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index b7b9f6b21f4..c7f6bf93831 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -128,18 +128,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
CustomDataLayer *l1, *l2;
int i, i1=0, i2=0, tot, j;
- for (i=0; i<c1->totlayer; i++) {
- if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
- CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ for (i = 0; i < c1->totlayer; i++) {
+ if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ {
i1++;
+ }
}
-
- for (i=0; i<c2->totlayer; i++) {
- if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
- CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+
+ for (i = 0; i < c2->totlayer; i++) {
+ if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ {
i2++;
+ }
}
-
+
if (i1 != i2)
return MESHCMP_CDLAYERS_MISMATCH;
@@ -148,12 +152,16 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
i1 = 0; i2 = 0;
for (i=0; i < tot; i++) {
while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
- CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ {
i1++, l1++;
+ }
- while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
- CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ {
i2++, l2++;
+ }
if (l1->type == CD_MVERT) {
MVert *v1 = l1->data;
@@ -327,7 +335,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me)
/* TODO - add some --debug-mesh option */
if (G.debug & G_DEBUG) {
- /* note: this warning may be un-called for if we are inirializing the mesh for the
+ /* note: this warning may be un-called for if we are initializing the mesh for the
* first time from bmesh, rather then giving a warning about this we could be smarter
* and check if there was any data to begin with, for now just print the warning with
* some info to help troubleshoot whats going on - campbell */
@@ -1058,7 +1066,7 @@ void mesh_strip_loose_polysloops(Mesh *me)
MLoop *l;
int a, b;
/* New loops idx! */
- int *new_idx = MEM_mallocN(sizeof(int) * me->totloop, "strip_loose_polysloops old2new idx mapping for polys.");
+ int *new_idx = MEM_mallocN(sizeof(int) * me->totloop, __func__);
for (a = b = 0, p = me->mpoly; a < me->totpoly; a++, p++) {
int invalid = FALSE;
@@ -1104,7 +1112,7 @@ void mesh_strip_loose_polysloops(Mesh *me)
b++;
}
else {
- /* XXX Theorically, we should be able to not do this, as no remaining poly
+ /* XXX Theoretically, we should be able to not do this, as no remaining poly
* should use any stripped loop. But for security's sake... */
new_idx[a] = -a;
}
@@ -1119,6 +1127,8 @@ void mesh_strip_loose_polysloops(Mesh *me)
for (a = 0, p = me->mpoly; a < me->totpoly; a++, p++) {
p->loopstart = new_idx[p->loopstart];
}
+
+ MEM_freeN(new_idx);
}
void mesh_strip_loose_edges(Mesh *me)
@@ -1126,7 +1136,7 @@ void mesh_strip_loose_edges(Mesh *me)
MEdge *e;
MLoop *l;
int a, b;
- unsigned int *new_idx = MEM_mallocN(sizeof(int) * me->totedge, "strip_loose_edges old2new idx mapping for loops.");
+ unsigned int *new_idx = MEM_mallocN(sizeof(int) * me->totedge, __func__);
for (a = b = 0, e = me->medge; a < me->totedge; a++, e++) {
if (e->v1 != e->v2) {
@@ -1152,6 +1162,8 @@ void mesh_strip_loose_edges(Mesh *me)
for (a = 0, l = me->mloop; a < me->totloop; a++, l++) {
l->e = new_idx[l->e];
}
+
+ MEM_freeN(new_idx);
}
void mball_to_mesh(ListBase *lb, Mesh *me)
@@ -1224,7 +1236,10 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
int *totloop, int *totpoly)
{
return nurbs_to_mdata_customdb(ob, &ob->disp,
- allvert, totvert, alledge, totedge, allloop, allpoly, totloop, totpoly);
+ allvert, totvert,
+ alledge, totedge,
+ allloop, allpoly,
+ totloop, totpoly);
}
/* BMESH: this doesn't calculate all edges from polygons,
@@ -1232,9 +1247,11 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */
/* use specified dispbase */
-int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int *_totvert,
- MEdge **alledge, int *_totedge, MLoop **allloop, MPoly **allpoly,
- int *_totloop, int *_totpoly)
+int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase,
+ MVert **allvert, int *_totvert,
+ MEdge **alledge, int *_totedge,
+ MLoop **allloop, MPoly **allpoly,
+ int *_totloop, int *_totpoly)
{
DispList *dl;
Curve *cu;
@@ -1316,7 +1333,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
for (b=1; b<dl->nr; b++) {
medge->v1= startvert+ofs+b-1;
medge->v2= startvert+ofs+b;
- medge->flag = ME_LOOSEEDGE|ME_EDGERENDER;
+ medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW;
medge++;
}
@@ -1341,7 +1358,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
medge->v1= startvert+ofs+b;
if (b==dl->nr-1) medge->v2= startvert+ofs;
else medge->v2= startvert+ofs+b+1;
- medge->flag = ME_LOOSEEDGE|ME_EDGERENDER;
+ medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW;
medge++;
}
}
@@ -1466,7 +1483,7 @@ void nurbs_to_mesh(Object *ob)
cu= ob->data;
if (dm == NULL) {
- if (nurbs_to_mdata (ob, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) {
+ if (nurbs_to_mdata(ob, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) {
/* Error initializing */
return;
}
@@ -1599,7 +1616,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
BLI_edgehash_free(eh, NULL);
if (edges.first) {
- Curve *cu = add_curve(ob->id.name+2, OB_CURVE);
+ Curve *cu = BKE_curve_add(ob->id.name+2, OB_CURVE);
cu->flag |= CU_3D;
while (edges.first) {
@@ -1858,8 +1875,8 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
BLI_array_empty(vertcos);
BLI_array_empty(vertnos);
- BLI_array_growitems(vertcos, mp->totloop);
- BLI_array_growitems(vertnos, mp->totloop);
+ BLI_array_grow_items(vertcos, mp->totloop);
+ BLI_array_grow_items(vertnos, mp->totloop);
for (j=0; j < mp->totloop; j++) {
int vindex = ml[j].v;
@@ -1868,7 +1885,7 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
}
BLI_array_empty(edgevecbuf);
- BLI_array_growitems(edgevecbuf, mp->totloop);
+ BLI_array_grow_items(edgevecbuf, mp->totloop);
accumulate_vertex_normals_poly(vertnos, pnors[i], vertcos, edgevecbuf, mp->totloop);
}
@@ -2054,8 +2071,11 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
/*build edge hash*/
me = mesh->medge;
- for (i=0; i<mesh->totedge; i++, me++) {
+ for (i = 0; i < mesh->totedge; i++, me++) {
BLI_edgehash_insert(eh, me->v1, me->v2, SET_INT_IN_POINTER(i));
+
+ /* unrelated but avoid having the FGON flag enabled, so we can reuse it later for something else */
+ me->flag &= ~ME_FGON;
}
j = 0; /*current loop index*/
@@ -2070,7 +2090,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
mp->mat_nr = mf->mat_nr;
mp->flag = mf->flag;
- #define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++;}
+# define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++;}
ML(v1, v2);
ML(v2, v3);
@@ -2082,7 +2102,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
ML(v3, v1);
}
- #undef ML
+# undef ML
bm_corners_to_loops(mesh, i, mp->loopstart, numTex, numCol);
}
@@ -2402,8 +2422,8 @@ int mesh_recalcTessellation(CustomData *fdata,
#ifdef USE_TESSFACE_SPEEDUP
#define ML_TO_MF(i1, i2, i3) \
- BLI_array_growone(mface_to_poly_map); \
- BLI_array_growone(mface); \
+ BLI_array_grow_one(mface_to_poly_map); \
+ BLI_array_grow_one(mface); \
mface_to_poly_map[mface_index] = poly_index; \
mf= &mface[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
@@ -2421,8 +2441,8 @@ int mesh_recalcTessellation(CustomData *fdata,
/* ALMOST IDENTICAL TO DEFINE ABOVE (see EXCEPTION) */
#define ML_TO_MF_QUAD() \
- BLI_array_growone(mface_to_poly_map); \
- BLI_array_growone(mface); \
+ BLI_array_grow_one(mface_to_poly_map); \
+ BLI_array_grow_one(mface); \
mface_to_poly_map[mface_index] = poly_index; \
mf= &mface[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
@@ -2480,10 +2500,10 @@ int mesh_recalcTessellation(CustomData *fdata,
totfilltri = BLI_edgefill(&sf_ctx, FALSE);
if (totfilltri) {
- BLI_array_growitems(mface_to_poly_map, totfilltri);
- BLI_array_growitems(mface, totfilltri);
+ BLI_array_grow_items(mface_to_poly_map, totfilltri);
+ BLI_array_grow_items(mface, totfilltri);
if (poly_orig_index) {
- BLI_array_growitems(mface_orig_index, totfilltri);
+ BLI_array_grow_items(mface_orig_index, totfilltri);
}
for (f = sf_ctx.fillfacebase.first; f; f = f->next, mf++) {
@@ -2652,7 +2672,7 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
k = 0;
for (i = 0; i<totpoly; i++, mp++) {
if (ELEM(mp->totloop, 3, 4)) {
- BLI_array_growone(mface);
+ BLI_array_grow_one(mface);
mf = &mface[k];
mf->mat_nr = mp->mat_nr;
@@ -3031,7 +3051,7 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly,
}
/* update the hide flag for edges and faces from the corresponding
- flag in verts */
+ * flag in verts */
void mesh_flush_hidden_from_verts(const MVert *mvert,
const MLoop *mloop,
MEdge *medge, int totedge,
@@ -3042,10 +3062,13 @@ void mesh_flush_hidden_from_verts(const MVert *mvert,
for (i = 0; i < totedge; i++) {
MEdge *e = &medge[i];
if (mvert[e->v1].flag & ME_HIDE ||
- mvert[e->v2].flag & ME_HIDE)
+ mvert[e->v2].flag & ME_HIDE)
+ {
e->flag |= ME_HIDE;
- else
+ }
+ else {
e->flag &= ~ME_HIDE;
+ }
}
for (i = 0; i < totpoly; i++) {
MPoly *p = &mpoly[i];
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index c5c2060d5c0..446ad399e11 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -240,9 +240,23 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
PRINT(" loop %u has invalid vert reference (%u)\n", sp->loopstart + j, ml->v);
sp->invalid = TRUE;
}
+
+ mverts[ml->v].flag |= ME_VERT_TMP_TAG;
*v = ml->v;
}
+ /* is the same vertex used more then once */
+ if (!sp->invalid) {
+ v = sp->verts;
+ for (j = 0; j < mp->totloop; j++, v++) {
+ if ((mverts[*v].flag & ME_VERT_TMP_TAG) == 0) {
+ PRINT(" poly %u has duplicate vert reference at corner (%u)\n", i, j);
+ sp->invalid = TRUE;
+ }
+ mverts[*v].flag &= ~ME_VERT_TMP_TAG;
+ }
+ }
+
if (sp->invalid)
continue;
@@ -309,7 +323,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
prev_v = v;
}
}
- if (v - prev_v > 1) { /* Don’t forget final verts! */
+ if (v - prev_v > 1) { /* Don't forget final verts! */
PRINT(" poly %u is invalid, it multi-uses vertex %u (%u times)\n",
sp->index, *prev_v, (int)(v - prev_v));
sp->invalid = TRUE;
@@ -420,7 +434,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
/* DO NOT REMOVE ITS LOOPS!!!
* As already invalid polys are at the end of the SortPoly list, the loops they
* were the only users have already been tagged as "to remove" during previous
- * iterations, and we don’t want to remove some loops that may be used by
+ * iterations, and we don't want to remove some loops that may be used by
* another valid poly! */
}
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 6c855b8f242..12aa6232cb0 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -76,7 +76,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
types_init= 0;
}
- /* type unsigned, no need to chech < 0 */
+ /* type unsigned, no need to check < 0 */
if (type < NUM_MODIFIER_TYPES && types[type]->name[0] != '\0') {
return types[type];
}
diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c
index 573b8a725b3..99bb3468320 100644
--- a/source/blender/blenkernel/intern/modifiers_bmesh.c
+++ b/source/blender/blenkernel/intern/modifiers_bmesh.c
@@ -117,8 +117,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BLI_array_empty(verts);
BLI_array_empty(edges);
- BLI_array_growitems(verts, mp->totloop);
- BLI_array_growitems(edges, mp->totloop);
+ BLI_array_grow_items(verts, mp->totloop);
+ BLI_array_grow_items(edges, mp->totloop);
ml = mloop + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++) {
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 9a640bcb8eb..d548d7589bb 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -450,7 +450,7 @@ static MovieClip *movieclip_alloc(const char *name)
* otherwise creates new.
* does not load ibuf itself
* pass on optional frame for #name images */
-MovieClip *BKE_add_movieclip_file(const char *name)
+MovieClip *BKE_movieclip_file_add(const char *name)
{
MovieClip *clip;
MovieClipUser user;
@@ -517,7 +517,7 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in
*height = ibuf->y;
if (clip->flag & MCLIP_USE_PROXY) {
- switch(user->render_size) {
+ switch (user->render_size) {
case MCLIP_PROXY_RENDER_SIZE_25:
(*width) *= 4;
(*height) *= 4;
@@ -925,8 +925,8 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in
real_ibuf_size(clip, user, ibuf, width, height);
}
else {
- *width = 0;
- *height = 0;
+ *width = clip->lastsize[0];
+ *height = clip->lastsize[1];
}
if (ibuf)
@@ -1149,14 +1149,14 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi
}
}
-void free_movieclip(MovieClip *clip)
+void BKE_movieclip_free(MovieClip *clip)
{
free_buffers(clip);
BKE_tracking_free(&clip->tracking);
}
-void unlink_movieclip(Main *bmain, MovieClip *clip)
+void BKE_movieclip_unlink(Main *bmain, MovieClip *clip)
{
bScreen *scr;
ScrArea *area;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 2167495ef08..d7212e5eaf9 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -104,7 +104,7 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
int hi_level,
/* assumed to be at hi_level (or
- null) */
+ * null) */
BLI_bitmap prev_hidden)
{
BLI_bitmap subd;
@@ -144,8 +144,8 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
if (prev_hidden) {
/* If prev_hidden is available, copy it to
- subd, except when the equivalent element in
- lo_hidden is different */
+ * subd, except when the equivalent element in
+ * lo_hidden is different */
if (lo_val != prev_hidden[hi_ndx])
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
else
@@ -215,7 +215,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
}
/* subdivide mdisps.hidden if needed (assumes that md.level reflects
- the current level of md.hidden) */
+ * the current level of md.hidden) */
static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
{
BLI_bitmap subd;
@@ -835,7 +835,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
MDisps *mdisps;
int lvl= mmd->totlvl;
- if (totlvl > multires_max_levels)
+ if ((totlvl > multires_max_levels) || (me->totpoly == 0))
return;
multires_force_update(ob);
@@ -1017,7 +1017,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
column_vectors_to_mat3(mat, tx, ty, no);
- switch(op) {
+ switch (op) {
case APPLY_DISPLACEMENTS:
/* Convert displacement to object space
* and add to grid points */
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
index 34e0be1de92..23d2f50c3f7 100644
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ b/source/blender/blenkernel/intern/navmesh_conversion.c
@@ -57,8 +57,7 @@ BLI_INLINE int left(const float* a, const float* b, const float* c)
int polyNumVerts(const unsigned short* p, const int vertsPerPoly)
{
int i, nv = 0;
- for (i=0; i<vertsPerPoly; i++)
- {
+ for (i=0; i<vertsPerPoly; i++) {
if (p[i]==0xffff)
break;
nv++;
@@ -71,8 +70,7 @@ int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* v
int j, nv = polyNumVerts(p, vertsPerPoly);
if (nv<3)
return 0;
- for (j=0; j<nv; j++)
- {
+ for (j=0; j<nv; j++) {
const float* v = &verts[3*p[j]];
const float* v_next = &verts[3*p[(j+1)%nv]];
const float* v_prev = &verts[3*p[(nv+j-1)%nv]];
@@ -119,8 +117,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
MFace *faces;
nverts = dm->getNumVerts(dm);
- if (nverts>=0xffff)
- {
+ if (nverts>=0xffff) {
printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
return 0;
}
@@ -128,8 +125,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
dm->getVertCos(dm, (float(*)[3])verts);
//flip coordinates
- for (vi=0; vi<nverts; vi++)
- {
+ for (vi=0; vi<nverts; vi++) {
SWAP(float, verts[3*vi+1], verts[3*vi+2]);
}
@@ -137,8 +133,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
nfaces = dm->getNumTessFaces(dm);
faces = dm->getTessFaceArray(dm);
ntris = nfaces;
- for (fi=0; fi<nfaces; fi++)
- {
+ for (fi=0; fi<nfaces; fi++) {
MFace* face = &faces[fi];
if (face->v4)
ntris++;
@@ -149,15 +144,13 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris");
tri = tris;
triIdx = 0;
- for (fi=0; fi<nfaces; fi++)
- {
+ for (fi=0; fi<nfaces; fi++) {
MFace* face = &faces[fi];
tri[3*triIdx+0] = (unsigned short) face->v1;
tri[3*triIdx+1] = (unsigned short) face->v3;
tri[3*triIdx+2] = (unsigned short) face->v2;
trisToFacesMap[triIdx++]=fi;
- if (face->v4)
- {
+ if (face->v4) {
tri[3*triIdx+0] = (unsigned short) face->v1;
tri[3*triIdx+1] = (unsigned short) face->v4;
tri[3*triIdx+2] = (unsigned short) face->v3;
@@ -187,8 +180,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly");
memset(newPoly, 0xff, sizeof(unsigned short)*capacity);
- for (polyidx=0; polyidx<npolys; polyidx++)
- {
+ for (polyidx=0; polyidx<npolys; polyidx++) {
size_t i;
int j, k;
int nv = 0;
@@ -202,22 +194,18 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
int adjustedNv;
int allBorderTraversed;
- for (j=0; j<dtrisNum && btri==-1;j++)
- {
+ for (j=0; j<dtrisNum && btri==-1;j++) {
int curpolytri = dtrisBase+j;
- for (k=0; k<3; k++)
- {
+ for (k=0; k<3; k++) {
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
- if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
- {
+ if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
btri = curpolytri;
bedge = k;
break;
}
}
}
- if (btri==-1 || bedge==-1)
- {
+ if (btri==-1 || bedge==-1) {
//can't find triangle with border edge
MEM_freeN(traversedTris);
MEM_freeN(newPoly);
@@ -229,13 +217,10 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
tri = btri;
edge = (bedge+1)%3;
traversedTris[tri-dtrisBase] = 1;
- while (tri!=btri || edge!=bedge)
- {
+ while (tri != btri || edge != bedge) {
int neighbortri = dtris[tri*3*2+3+edge];
- if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
- {
- if (nv==capacity)
- {
+ if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
+ if (nv==capacity) {
unsigned short* newPolyBig;
capacity += vertsPerPoly;
newPolyBig = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPolyBig");
@@ -251,16 +236,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
else {
//move to next tri
int twinedge = -1;
- for (k=0; k<3; k++)
- {
- if (dtris[neighbortri*3*2+3+k] == tri)
- {
+ for (k=0; k<3; k++) {
+ if (dtris[neighbortri*3*2+3+k] == tri) {
twinedge = k;
break;
}
}
- if (twinedge==-1)
- {
+ if (twinedge==-1) {
printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
MEM_freeN(traversedTris);
goto returnLabel;
@@ -273,8 +255,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
adjustedPoly = MEM_callocN(sizeof(unsigned short)*nv, "buildPolygonsByDetailedMeshes adjustedPoly");
adjustedNv = 0;
- for (i=0; i<nv; i++)
- {
+ for (i=0; i<nv; i++) {
unsigned short prev = newPoly[(nv+i-1)%nv];
unsigned short cur = newPoly[i];
unsigned short next = newPoly[(i+1)%nv];
@@ -288,17 +269,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
nv = adjustedNv;
allBorderTraversed = 1;
- for (i=0; i<dtrisNum; i++)
- {
- if (traversedTris[i]==0)
- {
+ for (i=0; i<dtrisNum; i++) {
+ if (traversedTris[i]==0) {
//check whether it has border edges
int curpolytri = dtrisBase+i;
- for (k=0; k<3; k++)
- {
+ for (k=0; k<3; k++) {
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
- if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
- {
+ if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
allBorderTraversed = 0;
break;
}
@@ -306,10 +283,8 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
}
}
- if (nv<=vertsPerPoly && allBorderTraversed)
- {
- for (i=0; i<nv; i++)
- {
+ if (nv<=vertsPerPoly && allBorderTraversed) {
+ for (i=0; i<nv; i++) {
polys[polyidx*vertsPerPoly*2+i] = newPoly[i];
}
}
@@ -353,8 +328,7 @@ int buildNavMeshData(const int nverts, const float* verts,
unsigned short *dtris, *dmeshes, *polys;
int *dtrisToPolysMap, *dtrisToTrisMap;
- if (!recastData)
- {
+ if (!recastData) {
printf("Converting navmesh: Error! Can't find recast custom data\n");
return 0;
}
@@ -370,17 +344,14 @@ int buildNavMeshData(const int nverts, const float* verts,
//search first valid triangle - triangle of convex polygon
validTriStart = -1;
- for (i=0; i< ntris; i++)
- {
- if (recastData[trisToFacesMap[trisMapping[i]]]>0)
- {
+ for (i=0; i< ntris; i++) {
+ if (recastData[trisToFacesMap[trisMapping[i]]]>0) {
validTriStart = i;
break;
}
}
- if (validTriStart<0)
- {
+ if (validTriStart<0) {
printf("Converting navmesh: Error! No valid polygons in mesh\n");
MEM_freeN(trisMapping);
return 0;
@@ -396,8 +367,7 @@ int buildNavMeshData(const int nverts, const float* verts,
//and reserve memory for adjacency info
dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris");
memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris);
- for (i=0; i<ndtris; i++)
- {
+ for (i=0; i<ndtris; i++) {
memcpy(dtris+3*2*i, tris+3*dtrisToTrisMap[i], sizeof(unsigned short)*3);
}
@@ -405,11 +375,9 @@ int buildNavMeshData(const int nverts, const float* verts,
prevPolyIdx = -1;
newPolyIdx = 0;
dtrisToPolysMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToPolysMap");
- for (i=0; i<ndtris; i++)
- {
+ for (i=0; i<ndtris; i++) {
curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
- if (curPolyIdx!=prevPolyIdx)
- {
+ if (curPolyIdx!=prevPolyIdx) {
newPolyIdx++;
prevPolyIdx=curPolyIdx;
}
@@ -426,13 +394,10 @@ int buildNavMeshData(const int nverts, const float* verts,
memset(dmeshes, 0, npolys*4*sizeof(unsigned short));
dmesh = NULL;
prevpolyidx = 0;
- for (i=0; i<ndtris; i++)
- {
+ for (i=0; i<ndtris; i++) {
int curpolyidx = dtrisToPolysMap[i];
- if (curpolyidx!=prevpolyidx)
- {
- if (curpolyidx!=prevpolyidx+1)
- {
+ if (curpolyidx!=prevpolyidx) {
+ if (curpolyidx!=prevpolyidx+1) {
printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
return 0;
}
@@ -476,8 +441,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
unsigned short *tris=NULL;
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
- if (!res)
- {
+ if (!res) {
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
goto exit;
}
@@ -485,8 +449,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
ndtris, dtris, npolys, dmeshes,polys, vertsPerPoly,
dtrisToPolysMap, dtrisToTrisMap);
- if (!res)
- {
+ if (!res) {
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
goto exit;
}
@@ -501,12 +464,10 @@ exit:
int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx)
{
int i, res = -1;
- for (i=0; i<vertsPerPoly; i++)
- {
+ for (i=0; i<vertsPerPoly; i++) {
if (p[i]==0xffff)
break;
- if (p[i]==vertexIdx)
- {
+ if (p[i] == vertexIdx) {
res = i;
break;
}
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 56fec119cce..5dfeb37b2ee 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -357,7 +357,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
strip->end = (float)ceil((double)info.length * FPS);
}
- else
+ else
#endif
{
strip->end = 10.0f;
@@ -373,7 +373,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */
/* strip should be referenced as-is */
- strip->scale= 1.0f;
+ strip->scale = 1.0f;
strip->repeat = 1.0f;
/* return this strip */
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index bd0853decbe..78a57534e2b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -321,8 +321,8 @@ void free_object(Object *ob)
id->us--;
if (id->us==0) {
if (ob->type==OB_MESH) unlink_mesh(ob->data);
- else if (ob->type==OB_CURVE) unlink_curve(ob->data);
- else if (ob->type==OB_MBALL) unlink_mball(ob->data);
+ else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data);
+ else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data);
}
ob->data= NULL;
}
@@ -461,7 +461,7 @@ void unlink_object(Object *ob)
}
}
else if (ELEM(OB_MBALL, ob->type, obt->type)) {
- if (is_mball_basis_for (obt, ob))
+ if (BKE_metaball_is_basis_for (obt, ob))
obt->recalc|= OB_RECALC_DATA;
}
@@ -627,10 +627,11 @@ void unlink_object(Object *ob)
#endif
if (sce->ed) {
Sequence *seq;
- SEQ_BEGIN(sce->ed, seq)
- if (seq->scene_camera==ob) {
- seq->scene_camera= NULL;
+ SEQ_BEGIN (sce->ed, seq) {
+ if (seq->scene_camera == ob) {
+ seq->scene_camera = NULL;
}
+ }
SEQ_END
}
@@ -758,10 +759,10 @@ static void *add_obdata_from_type(int type)
{
switch (type) {
case OB_MESH: return add_mesh("Mesh");
- case OB_CURVE: return add_curve("Curve", OB_CURVE);
- case OB_SURF: return add_curve("Surf", OB_SURF);
- case OB_FONT: return add_curve("Text", OB_FONT);
- case OB_MBALL: return add_mball("Meta");
+ case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE);
+ case OB_SURF: return BKE_curve_add("Surf", OB_SURF);
+ case OB_FONT: return BKE_curve_add("Text", OB_FONT);
+ case OB_MBALL: return BKE_metaball_add("Meta");
case OB_CAMERA: return add_camera("Camera");
case OB_LAMP: return add_lamp("Lamp");
case OB_LATTICE: return add_lattice("Lattice");
@@ -1493,7 +1494,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
{
- switch(ob->rotmode) {
+ switch (ob->rotmode) {
case ROT_MODE_QUAT:
{
float dquat[4];
@@ -1831,7 +1832,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
ListBase *nurbs;
cu= par->data;
- nurbs= BKE_curve_nurbs(cu);
+ nurbs= BKE_curve_nurbs_get(cu);
nu= nurbs->first;
count= 0;
@@ -2035,7 +2036,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
- switch(ob->partype & PARTYPE) {
+ switch (ob->partype & PARTYPE) {
case PAROBJECT:
ok= 0;
if (par->type==OB_CURVE) {
@@ -2270,14 +2271,14 @@ void minmax_object(Object *ob, float min[3], float max[3])
int a;
short change= FALSE;
- switch(ob->type) {
+ switch (ob->type) {
case OB_CURVE:
case OB_FONT:
case OB_SURF:
{
Curve *cu= ob->data;
- if (cu->bb==NULL) tex_space_curve(cu);
+ if (cu->bb==NULL) BKE_curve_tex_space_calc(cu);
bb= *(cu->bb);
for (a=0; a<8; a++) {
@@ -2578,7 +2579,7 @@ void object_handle_update(Scene *scene, Object *ob)
}
/* includes all keys and modifiers */
- switch(ob->type) {
+ switch (ob->type) {
case OB_MESH:
{
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
@@ -2641,9 +2642,11 @@ void object_handle_update(Scene *scene, Object *ob)
if (psys_check_enabled(ob, psys)) {
/* check use of dupli objects here */
if (psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) &&
- ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob)
- || (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
+ ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) ||
+ (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
+ {
ob->transflag |= OB_DUPLIPARTS;
+ }
particle_system_update(scene, ob, psys);
psys= psys->next;
@@ -2674,9 +2677,11 @@ void object_handle_update(Scene *scene, Object *ob)
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
for (pid=pidlist.first; pid; pid=pid->next) {
- if ((pid->cache->flag & PTCACHE_BAKED)
- || (pid->cache->flag & PTCACHE_QUICK_CACHE)==0)
+ if ((pid->cache->flag & PTCACHE_BAKED) ||
+ (pid->cache->flag & PTCACHE_QUICK_CACHE) == 0)
+ {
continue;
+ }
if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
scene->physics_settings.quick_cache_step =
@@ -2790,8 +2795,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
int result = 0;
int i;
- for (i = 0; i < 12 && result == 0; i++)
- {
+ for (i = 0; i < 12 && result == 0; i++) {
float lambda;
int v1, v2, v3;
v1 = triangle_indexes[i][0];
@@ -2818,8 +2822,7 @@ int object_insert_ptcache(Object *ob)
BLI_sortlist(&ob->pc_ids, pc_cmp);
- for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++)
- {
+ for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) {
int index = GET_INT_FROM_POINTER(link->data);
if (i < index)
@@ -2937,7 +2940,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
Curve *cu= ob->data;
Key *key= cu->key;
KeyBlock *kb;
- ListBase *lb= BKE_curve_nurbs(cu);
+ ListBase *lb= BKE_curve_nurbs_get(cu);
int newkey= 0;
if (key==NULL) {
@@ -2964,7 +2967,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
/* create new block with prepared data */
kb = add_keyblock_ctime(key, name, FALSE);
- kb->totelem= count_curveverts(lb);
+ kb->totelem= BKE_nurbList_verts_count(lb);
kb->data= data;
}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 907de7888cb..5ba1b3d86c3 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -196,15 +196,13 @@ static float Ph(struct Ocean* o, float kx,float kz )
float tmp;
float k2 = kx*kx + kz*kz;
- if (k2 == 0.0f)
- {
+ if (k2 == 0.0f) {
return 0.0f; // no DC component
}
// damp out the waves going in the direction opposite the wind
tmp = (o->_wx * kx + o->_wz * kz)/sqrtf(k2);
- if (tmp < 0)
- {
+ if (tmp < 0) {
tmp *= o->_damp_reflections;
}
@@ -421,18 +419,15 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
frac_z)
{
- if (oc->_do_disp_y)
- {
+ if (oc->_do_disp_y) {
ocr->disp[1] = INTERP(oc->_disp_y);
}
- if (oc->_do_normals)
- {
+ if (oc->_do_normals) {
ocr->normal[0] = INTERP(oc->_N_x);
ocr->normal[1] = oc->_N_y/*INTERP(oc->_N_y) (MEM01)*/;
ocr->normal[2] = INTERP(oc->_N_z);
}
- if (oc->_do_chop)
- {
+ if (oc->_do_chop) {
ocr->disp[0] = INTERP(oc->_disp_x);
ocr->disp[2] = INTERP(oc->_disp_z);
}
@@ -441,8 +436,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
ocr->disp[2] = 0.0;
}
- if (oc->_do_jacobian)
- {
+ if (oc->_do_jacobian) {
compute_eigenstuff(ocr, INTERP(oc->_Jxx),INTERP(oc->_Jzz),INTERP(oc->_Jxz));
}
}
@@ -474,8 +468,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
ocr->disp[1] = oc->_do_disp_y ? oc->_disp_y[i*oc->_N+j] : 0.0f;
- if (oc->_do_chop)
- {
+ if (oc->_do_chop) {
ocr->disp[0] = oc->_disp_x[i*oc->_N+j];
ocr->disp[2] = oc->_disp_z[i*oc->_N+j];
}
@@ -484,8 +477,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
ocr->disp[2] = 0.0f;
}
- if (oc->_do_normals)
- {
+ if (oc->_do_normals) {
ocr->normal[0] = oc->_N_x[i*oc->_N+j];
ocr->normal[1] = oc->_N_y/*oc->_N_y[i*oc->_N+j] (MEM01)*/;
ocr->normal[2] = oc->_N_z[i*oc->_N+j];
@@ -493,8 +485,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
normalize_v3(ocr->normal);
}
- if (oc->_do_jacobian)
- {
+ if (oc->_do_jacobian) {
compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j],oc->_Jzz[i*oc->_N+j],oc->_Jxz[i*oc->_N+j]);
}
@@ -511,12 +502,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
// compute a new htilda
#pragma omp parallel for private(i, j)
- for (i = 0 ; i < o->_M ; ++i)
- {
+ for (i = 0 ; i < o->_M ; ++i) {
// note the <= _N/2 here, see the fftw doco about
// the mechanics of the complex->real fft storage
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex exp_param1;
fftw_complex exp_param2;
fftw_complex conj_param;
@@ -541,8 +530,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_disp_y)
- {
+ if (o->_do_disp_y) {
// y displacement
fftw_execute(o->_disp_y_plan);
}
@@ -550,13 +538,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_chop)
- {
+ if (o->_do_chop) {
// x displacement
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
fftw_complex minus_i;
@@ -575,13 +560,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_chop)
- {
+ if (o->_do_chop) {
// z displacement
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
fftw_complex minus_i;
@@ -600,13 +582,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_jacobian)
- {
+ if (o->_do_jacobian) {
// Jxx
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
//init_complex(mul_param, -scale, 0);
@@ -620,10 +599,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
}
fftw_execute(o->_Jxx_plan);
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j < o->_N ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j < o->_N ; ++j) {
o->_Jxx[i*o->_N+j] += 1.0;
}
}
@@ -632,13 +609,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_jacobian)
- {
+ if (o->_do_jacobian) {
// Jzz
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
//init_complex(mul_param, -scale, 0);
@@ -651,10 +625,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
}
}
fftw_execute(o->_Jzz_plan);
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j < o->_N ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j < o->_N ; ++j) {
o->_Jzz[i*o->_N+j] += 1.0;
}
}
@@ -663,13 +635,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_jacobian)
- {
+ if (o->_do_jacobian) {
// Jxz
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
//init_complex(mul_param, -scale, 0);
@@ -688,12 +657,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
// fft normals
- if (o->_do_normals)
- {
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ if (o->_do_normals) {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
init_complex(mul_param, 0.0, -1.0);
@@ -709,12 +675,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
#pragma omp section
{
- if (o->_do_normals)
- {
- for ( i = 0 ; i < o->_M ; ++i)
- {
- for ( j = 0 ; j <= o->_N / 2 ; ++j)
- {
+ if (o->_do_normals) {
+ for ( i = 0 ; i < o->_M ; ++i) {
+ for ( j = 0 ; j <= o->_N / 2 ; ++j) {
fftw_complex mul_param;
init_complex(mul_param, 0.0, -1.0);
@@ -757,12 +720,9 @@ static void set_height_normalize_factor(struct Ocean *oc)
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
- for (i = 0; i < oc->_M; ++i)
- {
- for (j = 0; j < oc->_N; ++j)
- {
- if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j]))
- {
+ for (i = 0; i < oc->_M; ++i) {
+ for (j = 0; j < oc->_N; ++j) {
+ if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) {
max_h = fabsf(oc->_disp_y[i*oc->_N+j]);
}
}
@@ -851,10 +811,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
/*srand(seed);*/
BLI_srand(seed);
- for (i = 0 ; i < o->_M ; ++i)
- {
- for (j = 0 ; j < o->_N ; ++j)
- {
+ for (i = 0 ; i < o->_M ; ++i) {
+ for (j = 0 ; j < o->_N ; ++j) {
float r1 = gaussRand();
float r2 = gaussRand();
@@ -921,14 +879,12 @@ void BKE_free_ocean_data(struct Ocean *oc)
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE);
- if (oc->_do_disp_y)
- {
+ if (oc->_do_disp_y) {
fftw_destroy_plan(oc->_disp_y_plan);
MEM_freeN(oc->_disp_y);
}
- if (oc->_do_normals)
- {
+ if (oc->_do_normals) {
MEM_freeN(oc->_fft_in_nx);
MEM_freeN(oc->_fft_in_nz);
fftw_destroy_plan(oc->_N_x_plan);
@@ -938,8 +894,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
MEM_freeN(oc->_N_z);
}
- if (oc->_do_chop)
- {
+ if (oc->_do_chop) {
MEM_freeN(oc->_fft_in_x);
MEM_freeN(oc->_fft_in_z);
fftw_destroy_plan(oc->_disp_x_plan);
@@ -948,8 +903,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
MEM_freeN(oc->_disp_z);
}
- if (oc->_do_jacobian)
- {
+ if (oc->_do_jacobian) {
MEM_freeN(oc->_fft_in_jxx);
MEM_freeN(oc->_fft_in_jzz);
MEM_freeN(oc->_fft_in_jxz);
@@ -1002,7 +956,7 @@ static void cache_filename(char *string, const char *path, const char *relbase,
char cachepath[FILE_MAX];
const char *fname;
- switch(type) {
+ switch (type) {
case CACHE_TYPE_FOAM:
fname= "foam_";
break;
@@ -1043,8 +997,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
if (!och) return;
if (och->ibufs_disp) {
- for (i=och->start, f=0; i<=och->end; i++, f++)
- {
+ for (i=och->start, f=0; i<=och->end; i++, f++) {
if (och->ibufs_disp[f]) {
IMB_freeImBuf(och->ibufs_disp[f]);
}
@@ -1053,8 +1006,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
}
if (och->ibufs_foam) {
- for (i=och->start, f=0; i<=och->end; i++, f++)
- {
+ for (i=och->start, f=0; i<=och->end; i++, f++) {
if (och->ibufs_foam[f]) {
IMB_freeImBuf(och->ibufs_foam[f]);
}
@@ -1063,8 +1015,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
}
if (och->ibufs_norm) {
- for (i=och->start, f=0; i<=och->end; i++, f++)
- {
+ for (i=och->start, f=0; i<=och->end; i++, f++) {
if (och->ibufs_norm[f]) {
IMB_freeImBuf(och->ibufs_norm[f]);
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 8a940e339bc..e0c61fbcc90 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -72,7 +72,7 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
if (pf) {
oldseek = pf->seek;
- switch(whence) {
+ switch (whence) {
case SEEK_CUR:
seek = oldseek + offset;
break;
@@ -392,7 +392,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
/* unpackFile() looks at the existing files (abs_name, local_name) and a packed file.
*
* It returns a char *to the existing file name / new file name or NULL when
- * there was an error or when the user desides to cancel the operation.
+ * there was an error or when the user decides to cancel the operation.
*/
char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how)
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 975602c2918..f417f9b79fb 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -59,7 +59,7 @@ Paint *paint_get_active(Scene *sce)
ToolSettings *ts = sce->toolsettings;
if (sce->basact && sce->basact->object) {
- switch(sce->basact->object->mode) {
+ switch (sce->basact->object->mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT:
@@ -151,7 +151,7 @@ void copy_paint(Paint *src, Paint *tar)
}
/* returns non-zero if any of the face's vertices
- are hidden, zero otherwise */
+ * are hidden, zero otherwise */
int paint_is_face_hidden(const MFace *f, const MVert *mvert)
{
return ((mvert[f->v1].flag & ME_HIDE) ||
@@ -161,8 +161,8 @@ int paint_is_face_hidden(const MFace *f, const MVert *mvert)
}
/* returns non-zero if any of the corners of the grid
- face whose inner corner is at (x,y) are hidden,
- zero otherwise */
+ * face whose inner corner is at (x,y) are hidden,
+ * zero otherwise */
int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
int gridsize, int x, int y)
{
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index a851c440230..febe4277010 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -201,6 +201,8 @@ void psys_set_current_num(Object *ob, int index)
psys->flag &= ~PSYS_CURRENT;
}
}
+
+#if 0 /* UNUSED */
Object *psys_find_object(Scene *scene, ParticleSystem *psys)
{
Base *base;
@@ -215,6 +217,8 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys)
return NULL;
}
+#endif
+
Object *psys_get_lattice(ParticleSimulationData *sim)
{
Object *lattice=NULL;
@@ -1568,7 +1572,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:
@@ -1695,7 +1699,7 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_
*mapindex = index;
}
- else { /* FROM_FACE/FROM_VOLUME */
+ else { /* FROM_FACE/FROM_VOLUME */
if (index >= dm->getNumTessFaces(dm))
return 0;
@@ -1713,7 +1717,7 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_
*mapindex = index_dmcache;
}
- else { /* FROM_FACE/FROM_VOLUME */
+ else { /* FROM_FACE/FROM_VOLUME */
/* find a face on the derived mesh that uses this face */
MFace *mface;
OrigSpaceFace *osface;
@@ -1932,7 +1936,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
copy_v3_v3(result, state->co);
sub_v3_v3v3(par_vec, par->co, state->co);
- switch(type) {
+ switch (type) {
case PART_KINK_CURL:
{
negate_v3(par_vec);
@@ -2842,7 +2846,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache
{
float cosangle, angle, tangent[3], normal[3], q[4];
- switch(i) {
+ switch (i) {
case 0:
/* start from second key */
break;
@@ -3774,7 +3778,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
texco = TEXCO_GLOB;
- switch(texco) {
+ switch (texco) {
case TEXCO_GLOB:
copy_v3_v3(texvec, par->state.co);
break;
@@ -3842,7 +3846,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
texco = TEXCO_GLOB;
- switch(texco) {
+ switch (texco) {
case TEXCO_GLOB:
copy_v3_v3(texvec, pa->state.co);
break;
@@ -4276,10 +4280,13 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
state->time = psys_get_child_time(psys, cpa, cfra, NULL, NULL);
- if (!always)
- if ((state->time < 0.0f && !(part->flag & PART_UNBORN))
- || (state->time > 1.0f && !(part->flag & PART_DIED)))
+ if (!always) {
+ if ((state->time < 0.0f && !(part->flag & PART_UNBORN)) ||
+ (state->time > 1.0f && !(part->flag & PART_DIED)))
+ {
return 0;
+ }
+ }
state->time= (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24));
@@ -4296,10 +4303,13 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
}
if (pa) {
- if (!always)
- if ((cfra < pa->time && (part->flag & PART_UNBORN)==0)
- || (cfra > pa->dietime && (part->flag & PART_DIED)==0))
+ if (!always) {
+ if ((cfra < pa->time && (part->flag & PART_UNBORN) == 0) ||
+ (cfra > pa->dietime && (part->flag & PART_DIED) == 0))
+ {
return 0;
+ }
+ }
cfra = MIN2(cfra, pa->dietime);
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index aadd9d675b0..d3644657de7 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -126,10 +126,12 @@ static int psys_get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
- if ((psys->renderdata && !particles_are_dynamic(psys)) /* non-dynamic particles can be rendered fully */
- || (part->child_nbr && part->childtype) /* display percentage applies to children */
- || (psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */
+ if ((psys->renderdata && !particles_are_dynamic(psys)) || /* non-dynamic particles can be rendered fully */
+ (part->child_nbr && part->childtype) || /* display percentage applies to children */
+ (psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */
+ {
return 100;
+ }
return psys->part->disp;
}
@@ -785,7 +787,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)
@@ -853,13 +855,15 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
}
if (intersect==0)
pa->foffset=0.0;
- else switch(distr) {
- case PART_DISTR_JIT:
- pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)];
- break;
- case PART_DISTR_RAND:
- pa->foffset*=BLI_frand();
- break;
+ else {
+ switch (distr) {
+ case PART_DISTR_JIT:
+ pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)];
+ break;
+ case PART_DISTR_RAND:
+ pa->foffset *= BLI_frand();
+ break;
+ }
}
}
}
@@ -1479,7 +1483,7 @@ void psys_threads_free(ParticleThread *threads)
if (ctx->index) MEM_freeN(ctx->index);
if (ctx->skip) MEM_freeN(ctx->skip);
if (ctx->seams) MEM_freeN(ctx->seams);
- //if(ctx->vertpart) MEM_freeN(ctx->vertpart);
+ //if (ctx->vertpart) MEM_freeN(ctx->vertpart);
BLI_kdtree_free(ctx->tree);
/* threads */
@@ -1573,7 +1577,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec)
{
- switch(avemode) {
+ switch (avemode) {
case PART_AVE_VELOCITY:
copy_v3_v3(vec, state->vel);
break;
@@ -1777,7 +1781,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
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;
@@ -1862,9 +1866,11 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* and gravity in r_ve */
bpa->gravity[0] = bpa->gravity[1] = 0.0f;
bpa->gravity[2] = -1.0f;
- if ((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
- && sim->scene->physics_settings.gravity[2]!=0.0f)
+ if ((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) &&
+ (sim->scene->physics_settings.gravity[2] != 0.0f))
+ {
bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
+ }
bpa->data.health = part->boids->health;
bpa->data.mode = eBoidMode_InAir;
@@ -2137,7 +2143,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;
@@ -2171,7 +2177,7 @@ 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);
@@ -2189,7 +2195,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);
@@ -2375,6 +2381,7 @@ typedef struct SPHRangeData
float massfac;
int use_size;
} SPHRangeData;
+
typedef struct SPHData {
ParticleSystem *psys[10];
ParticleData *pa;
@@ -2390,7 +2397,7 @@ typedef struct SPHData {
/* Integrator callbacks. This allows different SPH implementations. */
void (*force_cb) (void *sphdata_v, ParticleKey *state, float *force, float *impulse);
void (*density_cb) (void *rangedata_v, int index, float squared_dist);
-}SPHData;
+} SPHData;
static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
{
@@ -2682,9 +2689,10 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
efdata.sim = sim;
/* add global acceleration (gravitation) */
- if (psys_uses_gravity(sim)
+ if (psys_uses_gravity(sim) &&
/* normal gravity is too strong for hair so it's disabled by default */
- && (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) {
+ (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR))
+ {
zero_v3(gr);
madd_v3_v3fl(gr, sim->scene->physics_settings.gravity, part->effector_weights->global_gravity * efdata.ptex.gravity);
gravity = gr;
@@ -2853,7 +2861,7 @@ static float collision_point_distance_with_normal(float p[3], ParticleCollisionE
if (fac >= 0.f)
collision_interpolate_element(pce, 0.f, fac, col);
- switch(pce->tot) {
+ switch (pce->tot) {
case 1:
{
sub_v3_v3v3(nor, p, pce->x0);
@@ -2878,7 +2886,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce
{
collision_interpolate_element(pce, 0.f, fac, col);
- switch(pce->tot) {
+ switch (pce->tot) {
case 1:
{
sub_v3_v3v3(co, p, pce->x0);
@@ -3827,7 +3835,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL);
/* initialize physics type specific stuff */
- switch(part->phystype) {
+ switch (part->phystype) {
case PART_PHYS_BOIDS:
{
ParticleTarget *pt = psys->targets.first;
@@ -3891,17 +3899,18 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
}
/* only reset unborn particles if they're shown or if the particle is born soon*/
- if (pa->alive==PARS_UNBORN
- && (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time))
+ if (pa->alive==PARS_UNBORN && (part->flag & PART_UNBORN || (cfra + psys->pointcache->step > pa->time))) {
reset_particle(sim, pa, dtime, cfra);
- else if (part->phystype == PART_PHYS_NO)
+ }
+ else if (part->phystype == PART_PHYS_NO) {
reset_particle(sim, pa, dtime, cfra);
+ }
if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING)==0 || (pa->flag & (PARS_UNEXIST|PARS_NO_DISP)))
pa->state.time = -1.f;
}
- switch(part->phystype) {
+ switch (part->phystype) {
case PART_PHYS_NEWTON:
{
LOOP_DYNAMIC_PARTICLES {
@@ -4125,7 +4134,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
pa->dietime = sim->scene->r.efra + 1;
pa->lifetime = sim->scene->r.efra;
pa->alive = PARS_ALIVE;
- //if(a<25) fprintf(stderr,"FSPARTICLE debug set %s , a%d = %f,%f,%f , life=%f\n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime );
+ //if (a < 25) fprintf(stderr,"FSPARTICLE debug set %s , a%d = %f,%f,%f , life=%f\n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime );
}
else {
// skip...
@@ -4492,7 +4501,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* setup necessary physics type dependent additional data if it doesn't yet exist */
psys_prepare_physics(&sim);
- switch(part->type) {
+ switch (part->type) {
case PART_HAIR:
{
/* nothing to do so bail out early */
@@ -4544,7 +4553,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
}
default:
{
- switch(part->phystype) {
+ switch (part->phystype) {
case PART_PHYS_NO:
case PART_PHYS_KEYED:
{
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 100bd485c36..39293084dc0 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -433,7 +433,7 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS
PTCacheExtra *extra = pm->extradata.first;
for (; extra; extra=extra->next) {
- switch(extra->type) {
+ switch (extra->type) {
case BPHYS_EXTRA_FLUID_SPRINGS:
{
if (psys->fluid_springs)
@@ -690,14 +690,20 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
/* cache type */
ptcache_file_write(pf, &surface->type, 1, sizeof(int));
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
- in_len = sizeof(PaintPoint)*total_points;
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
+ in_len = sizeof(PaintPoint) * total_points;
+ }
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
- in_len = sizeof(float)*total_points;
- else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
- in_len = sizeof(PaintWavePoint)*total_points;
- else return 0;
+ surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+ {
+ in_len = sizeof(float) * total_points;
+ }
+ else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
+ in_len = sizeof(PaintWavePoint) * total_points;
+ }
+ else {
+ return 0;
+ }
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
@@ -727,14 +733,20 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
return 0;
/* read surface data */
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
data_len = sizeof(PaintPoint);
+ }
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+ surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+ {
data_len = sizeof(float);
- else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
+ }
+ else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
data_len = sizeof(PaintWavePoint);
- else return 0;
+ }
+ else {
+ return 0;
+ }
ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points);
@@ -821,9 +833,12 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
if (psys->part->flag & PART_ROTATIONS) {
pid->data_types|= (1<<BPHYS_DATA_ROTATION);
- if (psys->part->rotmode!=PART_ROT_VEL
- || psys->part->avemode==PART_AVE_RAND || psys->part->avefac!=0.0f)
- pid->data_types|= (1<<BPHYS_DATA_AVELOCITY);
+ if (psys->part->rotmode != PART_ROT_VEL ||
+ psys->part->avemode == PART_AVE_RAND ||
+ psys->part->avefac != 0.0f)
+ {
+ pid->data_types |= (1 << BPHYS_DATA_AVELOCITY);
+ }
}
pid->info_types= (1<<BPHYS_DATA_TIMES);
@@ -986,8 +1001,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
}
else if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
- {
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
BLI_addtail(lb, pid);
@@ -995,8 +1009,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
}
else if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if (pmd->canvas)
- {
+ if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for (; surface; surface=surface->next) {
@@ -1202,8 +1215,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
#endif
#ifdef WITH_LZMA
- if (compressed == 2)
- {
+ if (compressed == 2) {
size_t sizeOfIt;
size_t leni = in_len, leno = len;
ptcache_file_read(pf, &size, 1, sizeof(unsigned int));
@@ -1267,8 +1279,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
else
ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
- if (compressed == 2)
- {
+ if (compressed == 2) {
unsigned int size = sizeOfIt;
ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
ptcache_file_write(pf, props, size, sizeof(unsigned char));
@@ -2310,7 +2321,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
if (timescale) {
time= BKE_curframe(scene);
- nexttime= BKE_frame_to_ctime(scene, CFRA+1);
+ nexttime = BKE_frame_to_ctime(scene, CFRA + 1.0f);
*timescale= MAX2(nexttime - time, 0.0f);
}
@@ -2502,16 +2513,14 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
}
if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
- {
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if (pmd->canvas)
- {
+ if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for (; surface; surface=surface->next) {
@@ -2810,8 +2819,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
PTCacheID *pid2;
BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
for (pid2=pidlist2.first; pid2; pid2=pid2->next) {
- if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN)
- {
+ if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
@@ -3243,8 +3251,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
}
if (cache->flag & PTCACHE_DISK_CACHE) {
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
- {
+ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
int totpoint = pid->totpoint(pid->calldata, 0);
if (cache->totpoint > totpoint)
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index 066de61575d..e7247be7f51 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -99,7 +99,7 @@ void init_property(bProperty *prop)
prop->data= 0;
- switch(prop->type) {
+ switch (prop->type) {
case GPROP_BOOL:
case GPROP_INT:
case GPROP_FLOAT:
@@ -206,7 +206,7 @@ int compare_property(bProperty *prop, const char *str)
// extern int Gdfra; /* sector.c */
float fvalue, ftest;
- switch(prop->type) {
+ switch (prop->type) {
case GPROP_BOOL:
if (BLI_strcasecmp(str, "true")==0) {
if (prop->data==1) return 0;
@@ -242,7 +242,7 @@ void set_property(bProperty *prop, const char *str)
{
// extern int Gdfra; /* sector.c */
- switch(prop->type) {
+ switch (prop->type) {
case GPROP_BOOL:
if (BLI_strcasecmp(str, "true")==0) prop->data= 1;
else if (BLI_strcasecmp(str, "false")==0) prop->data= 0;
@@ -266,7 +266,7 @@ void add_property(bProperty *prop, const char *str)
{
// extern int Gdfra; /* sector.c */
- switch(prop->type) {
+ switch (prop->type) {
case GPROP_BOOL:
case GPROP_INT:
prop->data+= atoi(str);
@@ -288,7 +288,7 @@ void set_property_valstr(bProperty *prop, char *str)
if (str == NULL) return;
- switch(prop->type) {
+ switch (prop->type) {
case GPROP_BOOL:
case GPROP_INT:
sprintf(str, "%d", prop->data);
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index b3e288dfc74..a7df6b10f06 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -43,7 +43,7 @@
static const char *report_type_str(int type)
{
- switch(type) {
+ switch (type) {
case RPT_DEBUG: return "Debug";
case RPT_INFO: return "Info";
case RPT_OPERATOR: return "Operator";
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 8123cbf3f0b..b5bb6b76c61 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -110,7 +110,7 @@ void init_sensor(bSensor *sens)
sens->data= NULL;
sens->pulse = 0;
- switch(sens->type) {
+ switch (sens->type) {
case SENS_ALWAYS:
sens->pulse = 0;
break;
@@ -272,7 +272,7 @@ void init_controller(bController *cont)
if (cont->data) MEM_freeN(cont->data);
cont->data= NULL;
- switch(cont->type) {
+ switch (cont->type) {
case CONT_EXPRESSION:
cont->data= MEM_callocN(sizeof(bExpressionCont), "expcont");
break;
@@ -400,7 +400,7 @@ void init_actuator(bActuator *act)
if (act->data) MEM_freeN(act->data);
act->data= NULL;
- switch(act->type) {
+ switch (act->type) {
case ACT_ACTION:
case ACT_SHAPEACTION:
act->data= MEM_callocN(sizeof(bActionActuator), "actionact");
@@ -647,7 +647,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
sens= obt->sensors.first;
while (sens) {
- switch(sens->type) {
+ switch (sens->type) {
case SENS_MESSAGE:
ms= sens->data;
if (ms->fromObject==ob) ms->fromObject= NULL;
@@ -657,7 +657,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
act= obt->actuators.first;
while (act) {
- switch(act->type) {
+ switch (act->type) {
case ACT_CAMERA:
ca= act->data;
if (ca->ob==ob) ca->ob= NULL;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index e7b6738f7c3..f1caa6ba272 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -425,7 +425,6 @@ Scene *add_scene(const char *name)
sce->toolsettings->segments = 32;
sce->toolsettings->rings = 32;
sce->toolsettings->vertices = 32;
- sce->toolsettings->editbutflag = 1;
sce->toolsettings->uvcalc_radius = 1.0f;
sce->toolsettings->uvcalc_cubesize = 1.0f;
sce->toolsettings->uvcalc_mapdir = 1;
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 3aadfa309c5..d3eade834e6 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1781,7 +1781,7 @@ static float check_zone(WipeZone *wipezone, int x, int y,
/* BOX WIPE IS NOT WORKING YET */
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
- /*
+#if 0
case DO_BOX_WIPE:
if (invert)facf0 = 1-facf0;
@@ -1843,7 +1843,7 @@ static float check_zone(WipeZone *wipezone, int x, int y,
}
break;
-*/
+#endif
case DO_IRIS_WIPE:
if (xo > yo) yo = xo;
else xo = yo;
@@ -2112,7 +2112,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out
yt += (yo / 2.0f);
//interpolate
- switch(interpolation) {
+ switch (interpolation) {
case 0:
neareast_interpolation(ibuf1,out, xt,yt,xi,yi);
break;
@@ -3076,8 +3076,9 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
fallback_fac = 1.0;
if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
- if (seq->seq1->enddisp != seq->seq1->start
- && seq->seq1->len != 0) {
+ if ((seq->seq1->enddisp != seq->seq1->start) &&
+ (seq->seq1->len != 0))
+ {
fallback_fac = (float) seq->seq1->len /
(float) (seq->seq1->enddisp - seq->seq1->start);
flags = SEQ_SPEED_INTEGRATE;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 99fc2242f9f..9291cb90dff 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -259,8 +259,7 @@ void seq_free_editing(Scene *scene)
if (ed == NULL)
return;
- SEQ_BEGIN(ed, seq)
- {
+ SEQ_BEGIN (ed, seq) {
seq_free_sequence(scene, seq);
}
SEQ_END
@@ -363,7 +362,7 @@ unsigned int seq_hash_render_data(const SeqRenderData *a)
/* ************************* iterator ************************** */
/* *************** (replaces old WHILE_SEQ) ********************* */
-/* **************** use now SEQ_BEGIN() SEQ_END ***************** */
+/* **************** use now SEQ_BEGIN () SEQ_END ***************** */
/* sequence strip iterator:
* - builds a full array, recursively into meta strips */
@@ -515,8 +514,17 @@ void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq,
*seqar = tseqar;
}
+static int metaseq_start(Sequence *metaseq)
+{
+ return metaseq->start + metaseq->startofs;
+}
-static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
+static int metaseq_end(Sequence *metaseq)
+{
+ return metaseq->start + metaseq->len - metaseq->endofs;
+}
+
+static void seq_update_sound_bounds_recursive_rec(Scene *scene, Sequence *metaseq, int start, int end)
{
Sequence *seq;
@@ -524,23 +532,28 @@ static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
* since sound is played outside of evaluating the imbufs, */
for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
if (seq->type == SEQ_META) {
- seq_update_sound_bounds_recursive(scene, seq);
+ seq_update_sound_bounds_recursive_rec(scene, seq, MAX2(start, metaseq_start(seq)), MIN2(end, metaseq_end(seq)));
}
else if (ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
if (seq->scene_sound) {
int startofs = seq->startofs;
int endofs = seq->endofs;
- if (seq->startofs + seq->start < metaseq->start + metaseq->startofs)
- startofs = metaseq->start + metaseq->startofs - seq->start;
+ if (seq->startofs + seq->start < start)
+ startofs = start - seq->start;
- if (seq->start + seq->len - seq->endofs > metaseq->start + metaseq->len - metaseq->endofs)
- endofs = seq->start + seq->len - metaseq->start - metaseq->len + metaseq->endofs;
+ if (seq->start + seq->len - seq->endofs > end)
+ endofs = seq->start + seq->len - end;
sound_move_scene_sound(scene, seq->scene_sound, seq->start + startofs, seq->start + seq->len - endofs, startofs);
}
}
}
}
+static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
+{
+ seq_update_sound_bounds_recursive_rec(scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq));
+}
+
void calc_sequence_disp(Scene *scene, Sequence *seq)
{
if (seq->startofs && seq->startstill) seq->startstill = 0;
@@ -1352,7 +1365,8 @@ static void seq_proxy_build_frame(SeqRenderData context,
IMB_freeImBuf(ibuf);
}
-struct SeqIndexBuildContext *seq_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq){
+struct SeqIndexBuildContext *seq_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq)
+{
SeqIndexBuildContext *context;
Sequence *nseq;
@@ -2191,7 +2205,7 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra)
ibuf = seq_stripelem_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF);
/* currently, we cache preprocessed images in SEQ_STRIPELEM_IBUF,
- * but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL */
+ * but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL */
if (ibuf)
use_preprocess = FALSE;
@@ -2684,10 +2698,10 @@ static void seq_start_threads(Scene *scene)
seq_last_given_monoton_cfra = monoton_cfra = 0;
/* since global structures are modified during the processing
- of one frame, only one render thread is currently possible...
-
- (but we code, in the hope, that we can remove this restriction
- soon...)
+ * of one frame, only one render thread is currently possible...
+ *
+ * (but we code, in the hope, that we can remove this restriction
+ * soon...)
*/
fprintf(stderr, "SEQ-THREAD: seq_start_threads\n");
@@ -2941,7 +2955,7 @@ void free_imbuf_seq(Scene *scene, ListBase *seqbase, int check_mem_usage,
}
if (seq->type == SEQ_SCENE) {
/* FIXME: recurs downwards,
- but do recurs protection somehow! */
+ * but do recurs protection somehow! */
}
}
@@ -3066,10 +3080,10 @@ void seq_tx_set_final_right(Sequence *seq, int val)
* since they work a bit differently to normal image seq's (during transform) */
int seq_single_check(Sequence *seq)
{
- return (seq->len == 1 && (
- seq->type == SEQ_IMAGE
- || ((seq->type & SEQ_EFFECT) &&
- get_sequence_effect_num_inputs(seq->type) == 0)));
+ return ((seq->len == 1) &&
+ (seq->type == SEQ_IMAGE ||
+ ((seq->type & SEQ_EFFECT) &&
+ get_sequence_effect_num_inputs(seq->type) == 0)));
}
/* check if the selected seq's reference unselected seq's */
@@ -3098,13 +3112,17 @@ int seqbase_isolated_sel_check(ListBase *seqbase)
if ( (seq->seq1 && (seq->seq1->flag & SELECT) == 0) ||
(seq->seq2 && (seq->seq2->flag & SELECT) == 0) ||
(seq->seq3 && (seq->seq3->flag & SELECT) == 0) )
+ {
return FALSE;
+ }
}
else {
if ( (seq->seq1 && (seq->seq1->flag & SELECT)) ||
(seq->seq2 && (seq->seq2->flag & SELECT)) ||
(seq->seq3 && (seq->seq3->flag & SELECT)) )
+ {
return FALSE;
+ }
}
}
@@ -3393,7 +3411,7 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i
int seqmute;
/* for sound we go over full meta tree to update muted state,
- * since sound is played outside of evaluating the imbufs, */
+ * since sound is played outside of evaluating the imbufs, */
for (seq = seqbasep->first; seq; seq = seq->next) {
seqmute = (mute || (seq->flag & SEQ_MUTE));
@@ -3778,7 +3796,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
sound = sound_new_file(CTX_data_main(C), seq_load->path); /* handles relative paths */
if (sound == NULL || sound->playback_handle == NULL) {
- //if(op)
+ //if (op)
// BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return NULL;
}
@@ -3787,7 +3805,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
if (info.specs.channels == AUD_CHANNELS_INVALID) {
sound_delete(bmain, sound);
- //if(op)
+ //if (op)
// BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return NULL;
}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 6513399c962..e201209ec3f 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -146,8 +146,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6));
- if (treeData.tree == NULL)
- {
+ if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
}
@@ -158,8 +157,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
#ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static)
#endif
- for (i = 0; i<calc->numVerts; ++i)
- {
+ for (i = 0; i<calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
@@ -189,8 +187,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
//Found the nearest vertex
- if (nearest.index != -1)
- {
+ if (nearest.index != -1) {
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
float dist = sasqrt(nearest.dist);
if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist;
@@ -224,8 +221,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
memcpy( &hit_tmp, hit, sizeof(hit_tmp) );
//Apply space transform (TODO readjust dist)
- if (transf)
- {
+ if (transf) {
copy_v3_v3( tmp_co, vert );
space_transform_apply( transf, tmp_co );
co = tmp_co;
@@ -298,8 +294,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
//Prepare data to retrieve the direction in which we should project each vertex
- if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL)
- {
+ if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
if (calc->vert == NULL) return;
}
else {
@@ -316,8 +311,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
return;
}
- if (calc->smd->auxTarget)
- {
+ if (calc->smd->auxTarget) {
auxMesh = object_get_derived_final(calc->smd->auxTarget);
if (!auxMesh)
return;
@@ -325,23 +319,21 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
}
//After sucessufuly build the trees, start projection vertexs
- if ( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6)
- && (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6)))
+ if (bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6) &&
+ (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6)))
{
#ifndef __APPLE__
#pragma omp parallel for private(i,hit) schedule(static)
#endif
- for (i = 0; i<calc->numVerts; ++i)
- {
+ for (i = 0; i<calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
float tmp_co[3], tmp_no[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
if (weight == 0.0f) continue;
- if (calc->vert)
- {
+ if (calc->vert) {
/* calc->vert contains verts from derivedMesh */
/* this coordinated are deformed by vertexCos only for normal projection (to get correct normals) */
/* for other cases calc->varts contains undeformed coordinates and vertexCos should be used */
@@ -364,8 +356,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that
//Project over positive direction of axis
- if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR)
- {
+ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
if (auxData.tree)
normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
@@ -374,8 +365,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
}
//Project over negative direction of axis
- if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1)
- {
+ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) {
float inv_no[3];
negate_v3_v3(inv_no, tmp_no);
@@ -386,8 +376,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
}
- if (hit.index != -1)
- {
+ if (hit.index != -1) {
madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
interp_v3_v3v3(co, co, hit.co, weight);
}
@@ -414,8 +403,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
//Create a bvh-tree of the given target
BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6));
- if (treeData.tree == NULL)
- {
+ if (treeData.tree == NULL) {
OUT_OF_MEMORY();
return;
}
@@ -429,8 +417,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
#ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
#endif
- for (i = 0; i<calc->numVerts; ++i)
- {
+ for (i = 0; i<calc->numVerts; ++i) {
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
@@ -458,10 +445,8 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData);
//Found the nearest vertex
- if (nearest.index != -1)
- {
- if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE)
- {
+ if (nearest.index != -1) {
+ if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
//Make the vertex stay on the front side of the face
madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist);
}
@@ -511,8 +496,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
}
- if (smd->target)
- {
+ if (smd->target) {
calc.target = object_get_derived_final(smd->target);
//TODO there might be several "bugs" on non-uniform scales matrixs
@@ -528,28 +512,24 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name);
- if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT)
- {
+ if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
//Setup arrays to get vertexs positions, normals and deform weights
calc.vert = dm->getVertDataArray(dm, CD_MVERT);
calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
//Using vertexs positions/normals as if a subsurface was applied
- if (smd->subsurfLevels)
- {
+ if (smd->subsurfLevels) {
SubsurfModifierData ssmd= {{NULL}};
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
ssmd.levels = smd->subsurfLevels; //levels
ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
- if (ss_mesh)
- {
+ if (ss_mesh) {
calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT);
- if (calc.vert)
- {
- //TRICKY: this code assumes subsurface will have the transformed original vertices
- //in their original order at the end of the vert array.
+ if (calc.vert) {
+ /* TRICKY: this code assumes subsurface will have the transformed original vertices
+ * in their original order at the end of the vert array. */
calc.vert = calc.vert + ss_mesh->getNumVerts(ss_mesh) - dm->getNumVerts(dm);
}
}
@@ -562,8 +542,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
//Projecting target defined - lets work!
if (calc.target) {
- switch(smd->shrinkType)
- {
+ switch (smd->shrinkType) {
case MOD_SHRINKWRAP_NEAREST_SURFACE:
BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
break;
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
index 71ea85de716..32681c3a041 100644
--- a/source/blender/blenkernel/intern/sketch.c
+++ b/source/blender/blenkernel/intern/sketch.c
@@ -44,8 +44,7 @@ void freeSketch(SK_Sketch *sketch)
{
SK_Stroke *stk, *next;
- for (stk = sketch->strokes.first; stk; stk = next)
- {
+ for (stk = sketch->strokes.first; stk; stk = next) {
next = stk->next;
sk_freeStroke(stk);
@@ -119,8 +118,7 @@ SK_Stroke* sk_createStroke(void)
void sk_shrinkStrokeBuffer(SK_Stroke *stk)
{
- if (stk->nb_points < stk->buf_size)
- {
+ if (stk->nb_points < stk->buf_size) {
SK_Point *old_points = stk->points;
stk->buf_size = stk->nb_points;
@@ -135,8 +133,7 @@ void sk_shrinkStrokeBuffer(SK_Stroke *stk)
void sk_growStrokeBuffer(SK_Stroke *stk)
{
- if (stk->nb_points == stk->buf_size)
- {
+ if (stk->nb_points == stk->buf_size) {
SK_Point *old_points = stk->points;
stk->buf_size *= 2;
@@ -151,12 +148,10 @@ void sk_growStrokeBuffer(SK_Stroke *stk)
void sk_growStrokeBufferN(SK_Stroke *stk, int n)
{
- if (stk->nb_points + n > stk->buf_size)
- {
+ if (stk->nb_points + n > stk->buf_size) {
SK_Point *old_points = stk->points;
- while (stk->nb_points + n > stk->buf_size)
- {
+ while (stk->nb_points + n > stk->buf_size) {
stk->buf_size *= 2;
}
@@ -202,8 +197,7 @@ void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, in
sk_growStrokeBufferN(stk, len - size);
- if (len != size)
- {
+ if (len != size) {
int tail_size = stk->nb_points - end + 1;
memmove(stk->points + start + len, stk->points + end + 1, tail_size * sizeof(SK_Point));
@@ -218,8 +212,7 @@ void sk_trimStroke(SK_Stroke *stk, int start, int end)
{
int size = end - start + 1;
- if (start > 0)
- {
+ if (start > 0) {
memmove(stk->points, stk->points + start, size * sizeof(SK_Point));
}
@@ -253,8 +246,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f
sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */
sk_insertStrokePoint(stk, &pt2, end + 1); /* insert before end (since end was pushed back already) */
- for (i = 1; i < total; i++)
- {
+ for (i = 1; i < total; i++) {
float delta = (float)i / (float)total;
float *p = stk->points[start + 1 + i].p;
@@ -269,30 +261,23 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
int i;
/* find first exact points outside of range */
- for (;start > 0; start--)
- {
- if (stk->points[start].type == PT_EXACT)
- {
+ for (;start > 0; start--) {
+ if (stk->points[start].type == PT_EXACT) {
break;
}
}
- for (;end < stk->nb_points - 1; end++)
- {
- if (stk->points[end].type == PT_EXACT)
- {
+ for (;end < stk->nb_points - 1; end++) {
+ if (stk->points[end].type == PT_EXACT) {
break;
}
}
offset = start + 1;
- for (i = start + 1; i < end; i++)
- {
- if (stk->points[i].type == PT_EXACT)
- {
- if (offset != i)
- {
+ for (i = start + 1; i < end; i++) {
+ if (stk->points[i].type == PT_EXACT) {
+ if (offset != i) {
memcpy(stk->points + offset, stk->points + i, sizeof(SK_Point));
}
@@ -301,8 +286,7 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
}
/* some points were removes, move end of array */
- if (offset < end)
- {
+ if (offset < end) {
int size = stk->nb_points - end;
memmove(stk->points + offset, stk->points + end, size * sizeof(SK_Point));
stk->nb_points = offset + size;
@@ -323,8 +307,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end)
project_v3_v3v3(normal, distance, normal);
limit = normalize_v3(normal);
- for (i = 1; i < total - 1; i++)
- {
+ for (i = 1; i < total - 1; i++) {
float d = limit * i / total;
float offset[3];
float *p = stk->points[start + i].p;
@@ -342,8 +325,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end)
void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk)
{
- if (sketch->active_stroke == stk)
- {
+ if (sketch->active_stroke == stk) {
sketch->active_stroke = NULL;
}
@@ -358,8 +340,7 @@ void sk_reverseStroke(SK_Stroke *stk)
sk_allocStrokeBuffer(stk);
- for (i = 0; i < stk->nb_points; i++)
- {
+ for (i = 0; i < stk->nb_points; i++) {
sk_copyPoint(stk->points + i, old_points + stk->nb_points - 1 - i);
}
@@ -376,8 +357,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
char work;
int i;
- if (start == -1)
- {
+ if (start == -1) {
start = 0;
end = stk->nb_points - 1;
}
@@ -386,8 +366,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
stk->nb_points = 0;
/* adding points before range */
- for (i = 0; i < start; i++)
- {
+ for (i = 0; i < start; i++) {
sk_appendStrokePoint(stk, old_points + i);
}
@@ -398,8 +377,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
work = 1;
/* while still reducing */
- while (work)
- {
+ while (work) {
int ls, le;
work = 0;
@@ -407,15 +385,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
le = start+1;
/* while not over interval */
- while (ls < end)
- {
+ while (ls < end) {
int max_i = 0;
short v1[2];
float max_dist = 16; /* more than 4 pixels */
/* find the next marked point */
- while (marked[le] == 0)
- {
+ while (marked[le] == 0) {
le++;
}
@@ -424,8 +400,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
v1[0] = old_points[ls].p2d[1] - old_points[le].p2d[1];
- for ( i = ls + 1; i < le; i++ )
- {
+ for ( i = ls + 1; i < le; i++ ) {
float mul;
float dist;
short v2[2];
@@ -433,8 +408,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
v2[0] = old_points[i].p2d[0] - old_points[ls].p2d[0];
v2[1] = old_points[i].p2d[1] - old_points[ls].p2d[1];
- if (v2[0] == 0 && v2[1] == 0)
- {
+ if (v2[0] == 0 && v2[1] == 0) {
continue;
}
@@ -442,15 +416,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
dist = mul * mul * (v2[0]*v2[0] + v2[1]*v2[1]);
- if (dist > max_dist)
- {
+ if (dist > max_dist) {
max_dist = dist;
max_i = i;
}
}
- if (max_i != 0)
- {
+ if (max_i != 0) {
work = 1;
marked[max_i] = 1;
}
@@ -462,10 +434,8 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
/* adding points after range */
- for (i = start; i <= end; i++)
- {
- if (marked[i])
- {
+ for (i = start; i <= end; i++) {
+ if (marked[i]) {
sk_appendStrokePoint(stk, old_points + i);
}
}
@@ -473,8 +443,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
MEM_freeN(marked);
/* adding points after range */
- for (i = end + 1; i < nb_points; i++)
- {
+ for (i = end + 1; i < nb_points; i++) {
sk_appendStrokePoint(stk, old_points + i);
}
@@ -490,13 +459,11 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk)
end = stk->nb_points -1;
- for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--)
- {
+ for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) {
/* nothing to do here*/
}
- if (end - start > 1)
- {
+ if (end - start > 1) {
sk_filterStroke(stk, start, end);
}
}
@@ -505,8 +472,7 @@ SK_Point *sk_lastStrokePoint(SK_Stroke *stk)
{
SK_Point *pt = NULL;
- if (stk->nb_points > 0)
- {
+ if (stk->nb_points > 0) {
pt = stk->points + (stk->nb_points - 1);
}
@@ -520,8 +486,7 @@ void sk_endContinuousStroke(SK_Stroke *stk)
void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
{
- if (stk)
- {
+ if (stk) {
memcpy(&sketch->next_point, stk->points[stk->nb_points - 1].p, sizeof(SK_Point));
}
}
@@ -529,8 +494,7 @@ void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
int sk_stroke_filtermval(SK_DrawData *dd)
{
int retval = 0;
- if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist)
- {
+ if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) {
retval = 1;
}
@@ -551,12 +515,10 @@ void sk_deleteSelectedStrokes(SK_Sketch *sketch)
{
SK_Stroke *stk, *next;
- for (stk = sketch->strokes.first; stk; stk = next)
- {
+ for (stk = sketch->strokes.first; stk; stk = next) {
next = stk->next;
- if (stk->selected == 1)
- {
+ if (stk->selected == 1) {
sk_removeStroke(sketch, stk);
}
}
@@ -566,31 +528,26 @@ void sk_selectAllSketch(SK_Sketch *sketch, int mode)
{
SK_Stroke *stk = NULL;
- if (mode == -1)
- {
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
+ if (mode == -1) {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
stk->selected = 0;
}
}
else if (mode == 0) {
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
stk->selected = 1;
}
}
else if (mode == 1) {
int selected = 1;
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
selected &= stk->selected;
}
selected ^= 1;
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
stk->selected = selected;
}
}
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index dc7a211a3c1..5d8a4955e58 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -78,6 +78,7 @@ variables on the UI for now
#include "BKE_DerivedMesh.h"
#include "BKE_pointcache.h"
#include "BKE_deform.h"
+#include "BKE_mesh.h"
//XXX #include "BIF_editdeform.h"
//XXX #include "BIF_graphics.h"
#include "PIL_time.h"
@@ -113,7 +114,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*/
@@ -125,7 +126,7 @@ typedef struct SBScratch {
int totface;
float aabbmin[3],aabbmax[3];
ReferenceState Ref;
-}SBScratch;
+} SBScratch;
typedef struct SB_thread_context {
Scene *scene;
@@ -140,7 +141,7 @@ typedef struct SB_thread_context {
float windfactor;
int nr;
int tot;
-}SB_thread_context;
+} SB_thread_context;
#define NLF_BUILD 1
#define NLF_SOLVE 2
@@ -267,9 +268,9 @@ float operations still
*/
static const int CCD_SAVETY = 190561;
-typedef struct ccdf_minmax{
-float minx,miny,minz,maxx,maxy,maxz;
-}ccdf_minmax;
+typedef struct ccdf_minmax {
+ float minx, miny, minz, maxx, maxy, maxz;
+} ccdf_minmax;
@@ -283,7 +284,7 @@ typedef struct ccd_Mesh {
/* Axis Aligned Bounding Box AABB */
float bbmin[3];
float bbmax[3];
-}ccd_Mesh;
+} ccd_Mesh;
@@ -401,7 +402,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
if (!cmd->numverts || !cmd->numfaces) return;
if ((pccd_M->totvert != cmd->numverts) ||
- (pccd_M->totface != cmd->numfaces)) return;
+ (pccd_M->totface != cmd->numfaces))
+ {
+ return;
+ }
pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
@@ -1358,7 +1362,7 @@ 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;
@@ -1387,8 +1391,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow)
}
bf = sb->scratch->bodyface;
for (a=0; a<sb->scratch->totface; a++, bf++) {
- if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT))
- {
+ if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) {
sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke);
sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke);
sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke);
@@ -1934,8 +1937,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
}
}
- if ((deflected < 2)&& (G.rt != 444)) // we did not hit a face until now
- { // see if 'outer' hits an edge
+ if ((deflected < 2)&& (G.rt != 444)) { /* we did not hit a face until now */
+ /* see if 'outer' hits an edge */
float dist;
closest_to_line_segment_v3(ve, opco, nv1, nv2);
@@ -2190,7 +2193,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
}
/* debugerin */
- if (sb->totpoint < ifirst) {
+ if (sb->totpoint < ifirst) {
printf("Aye 998");
return (998);
}
@@ -2830,8 +2833,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
nlEnd(NL_MATRIX);
nlEnd(NL_SYSTEM);
- if ((G.rt == 32) && (nl_flags & NLF_BUILD))
- {
+ if ((G.rt == 32) && (nl_flags & NLF_BUILD)) {
printf("####MEE#####\n");
nlPrintMatrix();
}
@@ -2960,7 +2962,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 {
@@ -3229,8 +3231,7 @@ static void springs_from_mesh(Object *ob)
float scale =1.0f;
sb= ob->soft;
- if (me && sb)
- {
+ if (me && sb) {
/* using bp->origS as a container for spring calcualtions here
** will be overwritten sbObjectStep() to receive
** actual modifier stack positions
@@ -3267,6 +3268,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
BodyPoint *bp;
BodySpring *bs;
int a, totedge;
+ BKE_mesh_tessface_ensure(me);
if (ob->softflag & OB_SB_EDGES) totedge= me->totedge;
else totedge= 0;
@@ -3305,8 +3307,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
this enables per vertex *mass painting*
*/
- if (sb->namedVG_Mass[0])
- {
+ if (sb->namedVG_Mass[0]) {
int grp= defgroup_name_index (ob,sb->namedVG_Mass);
/* printf("VGN %s %d\n",sb->namedVG_Mass,grp); */
if (grp > -1) {
@@ -3319,8 +3320,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
/* first set the default */
bp->springweight = 1.0f;
- if (sb->namedVG_Spring_K[0])
- {
+ if (sb->namedVG_Spring_K[0]) {
int grp= defgroup_name_index (ob,sb->namedVG_Spring_K);
//printf("VGN %s %d\n",sb->namedVG_Spring_K,grp);
if (grp > -1) {
@@ -3559,7 +3559,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
int a, curindex=0;
int totvert, totspring = 0, setgoal=0;
- totvert= count_curveverts(&cu->nurb);
+ totvert= BKE_nurbList_verts_count(&cu->nurb);
if (ob->softflag & OB_SB_EDGES) {
if (ob->type==OB_CURVE) {
@@ -3637,8 +3637,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
}
}
- if (totspring)
- {
+ if (totspring) {
build_bps_springlist(ob); /* link bps to springs */
if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);}
}
@@ -3894,7 +3893,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
SB_estimate_transform(ob,NULL,NULL,NULL);
SB_estimate_transform(ob,NULL,NULL,NULL);
}
- switch(ob->type) {
+ switch (ob->type) {
case OB_MESH:
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
break;
@@ -3950,8 +3949,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
if (sb->solver_ID>0) mid_flags |= MID_PRESERVE;
forcetime = forcetimemax; /* hope for integrating in one step */
- while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) )
- {
+ while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) {
/* set goals in time */
interpolate_exciter(ob,200,(int)(200.0f*(timedone/dtime)));
@@ -4019,12 +4017,11 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
}
}
- else if (sb->solver_ID == 2)
- {/* do semi "fake" implicit euler */
+ else if (sb->solver_ID == 2) {
+ /* do semi "fake" implicit euler */
//removed
}/*SOLVER SELECT*/
- else if (sb->solver_ID == 4)
- {
+ else if (sb->solver_ID == 4) {
/* do semi "fake" implicit euler */
}/*SOLVER SELECT*/
else if (sb->solver_ID == 3) {
@@ -4081,7 +4078,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
if (sb->bpoint == NULL ||
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) {
- switch(ob->type) {
+ switch (ob->type) {
case OB_MESH:
mesh_to_softbody(scene, ob);
break;
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index c2dbb518837..28ce95ea8d1 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -95,8 +95,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
sound_load(bmain, sound);
- if (!sound->playback_handle)
- {
+ if (!sound->playback_handle) {
free_libblock(&bmain->sound, sound);
sound = NULL;
}
@@ -106,22 +105,19 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
void sound_free(struct bSound* sound)
{
- if (sound->packedfile)
- {
+ if (sound->packedfile) {
freePackedFile(sound->packedfile);
sound->packedfile = NULL;
}
#ifdef WITH_AUDASPACE
- if (sound->handle)
- {
+ if (sound->handle) {
AUD_unload(sound->handle);
sound->handle = NULL;
sound->playback_handle = NULL;
}
- if (sound->cache)
- {
+ if (sound->cache) {
AUD_unload(sound->cache);
sound->cache = NULL;
}
@@ -141,10 +137,8 @@ static void sound_sync_callback(void* data, int mode, float time)
struct Scene* scene;
scene = bmain->scene.first;
- while (scene)
- {
- if (scene->audio.flag & AUDIO_SYNC)
- {
+ while (scene) {
+ if (scene->audio.flag & AUDIO_SYNC) {
if (mode)
sound_play_scene(scene);
else
@@ -282,8 +276,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa
void sound_delete(struct Main *bmain, struct bSound* sound)
{
- if (sound)
- {
+ if (sound) {
sound_free(sound);
free_libblock(&bmain->sound, sound);
@@ -312,8 +305,7 @@ void sound_cache_notifying(struct Main* main, struct bSound* sound)
void sound_delete_cache(struct bSound* sound)
{
sound->flags &= ~SOUND_FLAGS_CACHING;
- if (sound->cache)
- {
+ if (sound->cache) {
AUD_unload(sound->cache);
sound->cache = NULL;
sound->playback_handle = sound->handle;
@@ -322,16 +314,13 @@ void sound_delete_cache(struct bSound* sound)
void sound_load(struct Main *bmain, struct bSound* sound)
{
- if (sound)
- {
- if (sound->cache)
- {
+ if (sound) {
+ if (sound->cache) {
AUD_unload(sound->cache);
sound->cache = NULL;
}
- if (sound->handle)
- {
+ if (sound->handle) {
AUD_unload(sound->handle);
sound->handle = NULL;
sound->playback_handle = NULL;
@@ -341,7 +330,7 @@ void sound_load(struct Main *bmain, struct bSound* sound)
// XXX unused currently
#if 0
- switch(sound->type)
+ switch (sound->type)
{
case SOUND_TYPE_FILE:
#endif
@@ -376,15 +365,13 @@ void sound_load(struct Main *bmain, struct bSound* sound)
break;
}
#endif
- if (sound->flags & SOUND_FLAGS_MONO)
- {
+ if (sound->flags & SOUND_FLAGS_MONO) {
void* handle = AUD_monoSound(sound->handle);
AUD_unload(sound->handle);
sound->handle = handle;
}
- if (sound->flags & SOUND_FLAGS_CACHING)
- {
+ if (sound->flags & SOUND_FLAGS_CACHING) {
sound->cache = AUD_bufferSound(sound->handle);
}
@@ -557,14 +544,12 @@ void sound_play_scene(struct Scene *scene)
if (status == AUD_STATUS_INVALID)
sound_start_play_scene(scene);
- if (!scene->sound_scene_handle)
- {
+ if (!scene->sound_scene_handle) {
AUD_unlock();
return;
}
- if (status != AUD_STATUS_PLAYING)
- {
+ if (status != AUD_STATUS_PLAYING) {
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_resume(scene->sound_scene_handle);
}
@@ -577,8 +562,7 @@ void sound_play_scene(struct Scene *scene)
void sound_stop_scene(struct Scene *scene)
{
- if (scene->sound_scene_handle)
- {
+ if (scene->sound_scene_handle) {
AUD_pause(scene->sound_scene_handle);
if (scene->audio.flag & AUDIO_SYNC)
@@ -596,12 +580,10 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
- if (status == AUD_STATUS_INVALID)
- {
+ if (status == AUD_STATUS_INVALID) {
sound_start_play_scene(scene);
- if (!scene->sound_scene_handle)
- {
+ if (!scene->sound_scene_handle) {
AUD_unlock();
return;
}
@@ -616,10 +598,8 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
}
- if (scene->audio.flag & AUDIO_SCRUB && !animation_playing)
- {
- if (scene->audio.flag & AUDIO_SYNC)
- {
+ if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
+ if (scene->audio.flag & AUDIO_SYNC) {
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
}
@@ -648,8 +628,7 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
float sound_sync_scene(struct Scene *scene)
{
- if (scene->sound_scene_handle)
- {
+ if (scene->sound_scene_handle) {
if (scene->audio.flag & AUDIO_SYNC)
return AUD_getSequencerPosition(scene->sound_scene_handle);
else
@@ -668,8 +647,7 @@ int sound_scene_playing(struct Scene *scene)
void sound_free_waveform(struct bSound* sound)
{
- if (sound->waveform)
- {
+ if (sound->waveform) {
MEM_freeN(((SoundWaveform*)sound->waveform)->data);
MEM_freeN(sound->waveform);
}
@@ -683,8 +661,7 @@ void sound_read_waveform(struct bSound* sound)
info = AUD_getInfo(sound->playback_handle);
- if (info.length > 0)
- {
+ if (info.length > 0) {
SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
@@ -709,23 +686,16 @@ void sound_update_scene(struct Scene* scene)
void* handle;
float quat[4];
- for (SETLOOPER(scene, sce_it, base))
- {
+ for (SETLOOPER(scene, sce_it, base)) {
ob = base->object;
- if (ob->type == OB_SPEAKER)
- {
- if (ob->adt)
- {
- for (track = ob->adt->nla_tracks.first; track; track = track->next)
- {
- for (strip = track->strips.first; strip; strip = strip->next)
- {
- if (strip->type == NLASTRIP_TYPE_SOUND)
- {
+ if (ob->type == OB_SPEAKER) {
+ if (ob->adt) {
+ for (track = ob->adt->nla_tracks.first; track; track = track->next) {
+ for (strip = track->strips.first; strip; strip = strip->next) {
+ if (strip->type == NLASTRIP_TYPE_SOUND) {
speaker = (Speaker*)ob->data;
- if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle))
- {
+ if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
if (speaker->sound)
AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
else {
@@ -734,15 +704,13 @@ void sound_update_scene(struct Scene* scene)
}
}
else {
- if (speaker->sound)
- {
+ if (speaker->sound) {
strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0);
AUD_setRelativeSequence(strip->speaker_handle, 0);
}
}
- if (strip->speaker_handle)
- {
+ if (strip->speaker_handle) {
AUD_addSet(new_set, strip->speaker_handle);
AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
speaker->volume_min, speaker->distance_max,
@@ -765,13 +733,11 @@ void sound_update_scene(struct Scene* scene)
}
}
- while ((handle = AUD_getSet(scene->speaker_handles)))
- {
+ while ((handle = AUD_getSet(scene->speaker_handles))) {
AUD_removeSequence(scene->sound_scene, handle);
}
- if (scene->camera)
- {
+ if (scene->camera) {
mat4_to_quat(quat, scene->camera->obmat);
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1);
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 8a809c836c0..3de5cf9677e 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -120,7 +120,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
int useAging = !!(flags & CCG_USE_AGING);
int useArena = flags & CCG_USE_ARENA;
- /* subdivLevels==0 is not allowed */
+ /* subdivLevels==0 is not allowed */
subdivLevels = MAX2(subdivLevels, 1);
if (prevSS) {
@@ -128,7 +128,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
ccgSubSurf_getUseAgeCounts(prevSS, &oldUseAging, NULL, NULL, NULL);
- if (oldUseAging!=useAging) {
+ if (oldUseAging != useAging) {
ccgSubSurf_free(prevSS);
}
else {
@@ -148,7 +148,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
if (useArena) {
CCGAllocatorIFC allocatorIFC;
- CCGAllocatorHDL allocator = BLI_memarena_new((1<<16), "subsurf arena");
+ CCGAllocatorHDL allocator = BLI_memarena_new((1 << 16), "subsurf arena");
allocatorIFC.alloc = arena_alloc;
allocatorIFC.realloc = arena_realloc;
@@ -177,81 +177,81 @@ static int getEdgeIndex(CCGSubSurf *ss, CCGEdge *e, int x, int edgeSize)
{
CCGVert *v0 = ccgSubSurf_getEdgeVert0(e);
CCGVert *v1 = ccgSubSurf_getEdgeVert1(e);
- int v0idx = *((int*) ccgSubSurf_getVertUserData(ss, v0));
- int v1idx = *((int*) ccgSubSurf_getVertUserData(ss, v1));
- int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
+ int v0idx = *((int *) ccgSubSurf_getVertUserData(ss, v0));
+ int v1idx = *((int *) ccgSubSurf_getVertUserData(ss, v1));
+ int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e));
- if (x==0) {
+ if (x == 0) {
return v0idx;
}
- else if (x==edgeSize-1) {
+ else if (x == edgeSize - 1) {
return v1idx;
}
else {
- return edgeBase + x-1;
+ return edgeBase + x - 1;
}
}
static int getFaceIndex(CCGSubSurf *ss, CCGFace *f, int S, int x, int y, int edgeSize, int gridSize)
{
- int faceBase = *((int*) ccgSubSurf_getFaceUserData(ss, f));
+ int faceBase = *((int *) ccgSubSurf_getFaceUserData(ss, f));
int numVerts = ccgSubSurf_getFaceNumVerts(f);
- if (x==gridSize-1 && y==gridSize-1) {
+ if (x == gridSize - 1 && y == gridSize - 1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
- return *((int*) ccgSubSurf_getVertUserData(ss, v));
+ return *((int *) ccgSubSurf_getVertUserData(ss, v));
}
- else if (x==gridSize-1) {
+ else if (x == gridSize - 1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
CCGEdge *e = ccgSubSurf_getFaceEdge(f, S);
- int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
- if (v==ccgSubSurf_getEdgeVert0(e)) {
- return edgeBase + (gridSize-1-y)-1;
+ int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e));
+ if (v == ccgSubSurf_getEdgeVert0(e)) {
+ return edgeBase + (gridSize - 1 - y) - 1;
}
else {
- return edgeBase + (edgeSize-2-1)-((gridSize-1-y)-1);
+ return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - y) - 1);
}
}
- else if (y==gridSize-1) {
+ else if (y == gridSize - 1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
- CCGEdge *e = ccgSubSurf_getFaceEdge(f, (S+numVerts-1)%numVerts);
- int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
- if (v==ccgSubSurf_getEdgeVert0(e)) {
- return edgeBase + (gridSize-1-x)-1;
+ CCGEdge *e = ccgSubSurf_getFaceEdge(f, (S + numVerts - 1) % numVerts);
+ int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e));
+ if (v == ccgSubSurf_getEdgeVert0(e)) {
+ return edgeBase + (gridSize - 1 - x) - 1;
}
else {
- return edgeBase + (edgeSize-2-1)-((gridSize-1-x)-1);
+ return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - x) - 1);
}
}
- else if (x==0 && y==0) {
+ else if (x == 0 && y == 0) {
return faceBase;
}
- else if (x==0) {
- S = (S+numVerts-1)%numVerts;
- return faceBase + 1 + (gridSize-2)*S + (y-1);
+ else if (x == 0) {
+ S = (S + numVerts - 1) % numVerts;
+ return faceBase + 1 + (gridSize - 2) * S + (y - 1);
}
- else if (y==0) {
- return faceBase + 1 + (gridSize-2)*S + (x-1);
+ else if (y == 0) {
+ return faceBase + 1 + (gridSize - 2) * S + (x - 1);
}
else {
- return faceBase + 1 + (gridSize-2)*numVerts + S*(gridSize-2)*(gridSize-2) + (y-1)*(gridSize-2) + (x-1);
+ return faceBase + 1 + (gridSize - 2) * numVerts + S * (gridSize - 2) * (gridSize - 2) + (y - 1) * (gridSize - 2) + (x - 1);
}
}
static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct MLoop *ml, int fi, CCGVertHDL *fverts)
{
UvMapVert *v, *nv;
- int j, nverts= mpoly[fi].totloop;
+ int j, nverts = mpoly[fi].totloop;
- for (j=0; j<nverts; j++) {
- for (nv=v=get_uv_map_vert(vmap, ml[j].v); v; v=v->next) {
+ for (j = 0; j < nverts; j++) {
+ for (nv = v = get_uv_map_vert(vmap, ml[j].v); v; v = v->next) {
if (v->separate)
- nv= v;
+ nv = v;
if (v->f == fi)
break;
}
- fverts[j]= SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex);
+ fverts[j] = SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex);
}
}
@@ -266,31 +266,31 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
UvMapVert *v;
UvVertMap *vmap;
float limit[2];
- CCGVertHDL *fverts= NULL;
+ CCGVertHDL *fverts = NULL;
BLI_array_declare(fverts);
EdgeHash *ehash;
float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss);
- float uv[3]= {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
+ float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
- limit[0]= limit[1]= STD_UV_CONNECT_LIMIT;
- vmap= make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit);
+ limit[0] = limit[1] = STD_UV_CONNECT_LIMIT;
+ vmap = make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit);
if (!vmap)
return 0;
ccgSubSurf_initFullSync(ss);
/* create vertices */
- for (i=0; i<totvert; i++) {
+ for (i = 0; i < totvert; i++) {
if (!get_uv_map_vert(vmap, i))
continue;
- for (v=get_uv_map_vert(vmap, i)->next; v; v=v->next)
+ for (v = get_uv_map_vert(vmap, i)->next; v; v = v->next)
if (v->separate)
break;
- seam = (v != NULL) || ((mvert+i)->flag & ME_VERT_MERGED);
+ seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED);
- for (v=get_uv_map_vert(vmap, i); v; v=v->next) {
+ for (v = get_uv_map_vert(vmap, i); v; v = v->next) {
if (v->separate) {
CCGVert *ssv;
int loopid = mpoly[v->f].loopstart + v->tfindex;
@@ -306,35 +306,35 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
/* create edges */
ehash = BLI_edgehash_new();
- for (i=0; i<totface; i++) {
- MPoly *mp = &((MPoly*) mpoly)[i];
- int nverts= mp->totloop;
- CCGFace *origf= ccgSubSurf_getFace(origss, SET_INT_IN_POINTER(i));
+ for (i = 0; i < totface; i++) {
+ MPoly *mp = &((MPoly *) mpoly)[i];
+ int nverts = mp->totloop;
+ CCGFace *origf = ccgSubSurf_getFace(origss, SET_INT_IN_POINTER(i));
/* unsigned int *fv = &mp->v1; */
- MLoop *ml= mloop + mp->loopstart;
+ MLoop *ml = mloop + mp->loopstart;
BLI_array_empty(fverts);
- BLI_array_growitems(fverts, nverts);
+ BLI_array_grow_items(fverts, nverts);
get_face_uv_map_vert(vmap, mpoly, ml, i, fverts);
- for (j=0; j<nverts; j++) {
+ for (j = 0; j < nverts; j++) {
int v0 = GET_INT_FROM_POINTER(fverts[j]);
- int v1 = GET_INT_FROM_POINTER(fverts[(j+1)%nverts]);
- MVert *mv0 = mvert + (ml[ j ]. v);
- MVert *mv1 = mvert + (ml[ ((j+1)%nverts) ].v);
+ int v1 = GET_INT_FROM_POINTER(fverts[(j + 1) % nverts]);
+ MVert *mv0 = mvert + (ml[j].v);
+ MVert *mv1 = mvert + (ml[((j + 1) % nverts)].v);
if (!BLI_edgehash_haskey(ehash, v0, v1)) {
- CCGEdge *e, *orige= ccgSubSurf_getFaceEdge(origf, j);
- CCGEdgeHDL ehdl= SET_INT_IN_POINTER(mp->loopstart + j);
+ CCGEdge *e, *orige = ccgSubSurf_getFaceEdge(origf, j);
+ CCGEdgeHDL ehdl = SET_INT_IN_POINTER(mp->loopstart + j);
float crease;
- if ((mv0->flag&mv1->flag) & ME_VERT_MERGED)
+ if ((mv0->flag & mv1->flag) & ME_VERT_MERGED)
crease = creaseFactor;
else
crease = ccgSubSurf_getEdgeCrease(orige);
- ccgSubSurf_syncEdge(ss, ehdl, fverts[j], fverts[(j+1)%nverts], crease, &e);
+ ccgSubSurf_syncEdge(ss, ehdl, fverts[j], fverts[(j + 1) % nverts], crease, &e);
BLI_edgehash_insert(ehash, v0, v1, NULL);
}
}
@@ -343,14 +343,14 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
BLI_edgehash_free(ehash, NULL);
/* create faces */
- for (i=0; i<totface; i++) {
+ for (i = 0; i < totface; i++) {
MPoly *mp = &mpoly[i];
- MLoop *ml= &mloop[mp->loopstart];
- int nverts= mp->totloop;
+ MLoop *ml = &mloop[mp->loopstart];
+ int nverts = mp->totloop;
CCGFace *f;
BLI_array_empty(fverts);
- BLI_array_growitems(fverts, nverts);
+ BLI_array_grow_items(fverts, nverts);
get_face_uv_map_vert(vmap, mpoly, ml, i, fverts);
ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), nverts, fverts, &f);
@@ -396,7 +396,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
gridFaces = gridSize - 1;
/* make a map from original faces to CCGFaces */
- faceMap = MEM_mallocN(totface*sizeof(*faceMap), "facemapuv");
+ faceMap = MEM_mallocN(totface * sizeof(*faceMap), "facemapuv");
fi = ccgSubSurf_getFaceIterator(uvss);
for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
@@ -406,22 +406,22 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
ccgFaceIterator_free(fi);
/* load coordinates from uvss into tface */
- tf= tface;
- mluv= mloopuv;
+ tf = tface;
+ mluv = mloopuv;
for (index = 0; index < totface; index++) {
CCGFace *f = faceMap[index];
int numVerts = ccgSubSurf_getFaceNumVerts(f);
- for (S=0; S<numVerts; S++) {
- float (*faceGridData)[3]= ccgSubSurf_getFaceGridDataArray(uvss, f, S);
+ for (S = 0; S < numVerts; S++) {
+ float (*faceGridData)[3] = ccgSubSurf_getFaceGridDataArray(uvss, f, S);
for (y = 0; y < gridFaces; y++) {
for (x = 0; x < gridFaces; x++) {
- float *a = faceGridData[(y + 0)*gridSize + x + 0];
- float *b = faceGridData[(y + 0)*gridSize + x + 1];
- float *c = faceGridData[(y + 1)*gridSize + x + 1];
- float *d = faceGridData[(y + 1)*gridSize + x + 0];
+ float *a = faceGridData[(y + 0) * gridSize + x + 0];
+ float *b = faceGridData[(y + 0) * gridSize + x + 1];
+ float *c = faceGridData[(y + 1) * gridSize + x + 1];
+ float *d = faceGridData[(y + 1) * gridSize + x + 0];
if (tf) {
copy_v2_v2(tf->uv[0], a);
@@ -466,41 +466,41 @@ static float *get_ss_weights(WeightTable *wtable, int gridCuts, int faceLen)
float *w, w1, w2, w4, fac, fac2, fx, fy;
if (wtable->len <= faceLen) {
- void *tmp = MEM_callocN(sizeof(FaceVertWeightEntry)*(faceLen+1), "weight table alloc 2");
+ void *tmp = MEM_callocN(sizeof(FaceVertWeightEntry) * (faceLen + 1), "weight table alloc 2");
if (wtable->len) {
- memcpy(tmp, wtable->weight_table, sizeof(FaceVertWeightEntry)*wtable->len);
+ memcpy(tmp, wtable->weight_table, sizeof(FaceVertWeightEntry) * wtable->len);
MEM_freeN(wtable->weight_table);
}
wtable->weight_table = tmp;
- wtable->len = faceLen+1;
+ wtable->len = faceLen + 1;
}
if (!wtable->weight_table[faceLen].valid) {
wtable->weight_table[faceLen].valid = 1;
- wtable->weight_table[faceLen].w = w = MEM_callocN(sizeof(float)*faceLen*faceLen*(gridCuts+2)*(gridCuts+2), "weight table alloc");
+ wtable->weight_table[faceLen].w = w = MEM_callocN(sizeof(float) * faceLen * faceLen * (gridCuts + 2) * (gridCuts + 2), "weight table alloc");
fac = 1.0f / (float)faceLen;
- for (i=0; i<faceLen; i++) {
- for (x=0; x<gridCuts+2; x++) {
- for (y=0; y<gridCuts+2; y++) {
- fx = 0.5f - (float)x / (float)(gridCuts+1) / 2.0f;
- fy = 0.5f - (float)y / (float)(gridCuts+1) / 2.0f;
+ for (i = 0; i < faceLen; i++) {
+ for (x = 0; x < gridCuts + 2; x++) {
+ for (y = 0; y < gridCuts + 2; y++) {
+ fx = 0.5f - (float)x / (float)(gridCuts + 1) / 2.0f;
+ fy = 0.5f - (float)y / (float)(gridCuts + 1) / 2.0f;
fac2 = faceLen - 4;
- w1 = (1.0f - fx) * (1.0f - fy) + (-fac2*fx*fy*fac);
- w2 = (1.0f - fx + fac2*fx*-fac) * (fy);
- w4 = (fx) * (1.0f - fy + -fac2*fy*fac);
-
- fac2 = 1.0f - (w1+w2+w4);
- fac2 = fac2 / (float)(faceLen-3);
- for (j=0; j<faceLen; j++)
+ w1 = (1.0f - fx) * (1.0f - fy) + (-fac2 * fx * fy * fac);
+ w2 = (1.0f - fx + fac2 * fx * -fac) * (fy);
+ w4 = (fx) * (1.0f - fy + -fac2 * fy * fac);
+
+ fac2 = 1.0f - (w1 + w2 + w4);
+ fac2 = fac2 / (float)(faceLen - 3);
+ for (j = 0; j < faceLen; j++)
w[j] = fac2;
w[i] = w1;
- w[(i-1+faceLen)%faceLen] = w2;
- w[(i+1)%faceLen] = w4;
+ w[(i - 1 + faceLen) % faceLen] = w2;
+ w[(i + 1) % faceLen] = w4;
w += faceLen;
}
@@ -515,7 +515,7 @@ static void free_ss_weights(WeightTable *wtable)
{
int i;
- for (i=0; i<wtable->len; i++) {
+ for (i = 0; i < wtable->len; i++) {
if (wtable->weight_table[i].valid)
MEM_freeN(wtable->weight_table[i].w);
}
@@ -525,7 +525,7 @@ static void free_ss_weights(WeightTable *wtable)
}
static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
- float (*vertexCos)[3], int useFlatSubdiv)
+ float (*vertexCos)[3], int useFlatSubdiv)
{
float creaseFactor = (float) ccgSubSurf_getSubdivisionLevels(ss);
CCGVertHDL *fVerts = NULL;
@@ -559,7 +559,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), mv->co, 0, &v);
}
- ((int*)ccgSubSurf_getVertUserData(ss, v))[1] = (index)? *index++: i;
+ ((int *)ccgSubSurf_getVertUserData(ss, v))[1] = (index) ? *index++ : i;
}
me = medge;
@@ -569,24 +569,24 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
float crease;
crease = useFlatSubdiv ? creaseFactor :
- me->crease * creaseFactor / 255.0f;
+ me->crease * creaseFactor / 255.0f;
ccgSubSurf_syncEdge(ss, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(me->v1),
- SET_INT_IN_POINTER(me->v2), crease, &e);
+ SET_INT_IN_POINTER(me->v2), crease, &e);
- ((int*)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index)? *index++: i;
+ ((int *)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index) ? *index++ : i;
}
mp = mpoly;
index = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
- for (i=0; i<dm->numPolyData; i++, mp++) {
+ for (i = 0; i < dm->numPolyData; i++, mp++) {
CCGFace *f;
BLI_array_empty(fVerts);
- BLI_array_growitems(fVerts, mp->totloop);
+ BLI_array_grow_items(fVerts, mp->totloop);
ml = mloop + mp->loopstart;
- for (j=0; j<mp->totloop; j++, ml++) {
+ for (j = 0; j < mp->totloop; j++, ml++) {
fVerts[j] = SET_INT_IN_POINTER(ml->v);
}
@@ -595,7 +595,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
* other parts of code significantly to handle missing faces.
* since this really shouldn't even be possible we just bail.*/
if (ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), mp->totloop,
- fVerts, &f) == eCCGError_InvalidValue) {
+ fVerts, &f) == eCCGError_InvalidValue) {
static int hasGivenError = 0;
if (!hasGivenError) {
@@ -608,7 +608,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
return;
}
- ((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = (index)? *index++: i;
+ ((int *)ccgSubSurf_getFaceUserData(ss, f))[1] = (index) ? *index++ : i;
}
ccgSubSurf_processSync(ss);
@@ -620,22 +620,22 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v)
{
- return ((int*) ccgSubSurf_getVertUserData(ss, v))[1];
+ return ((int *) ccgSubSurf_getVertUserData(ss, v))[1];
}
static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e)
{
- return ((int*) ccgSubSurf_getEdgeUserData(ss, e))[1];
+ return ((int *) ccgSubSurf_getEdgeUserData(ss, e))[1];
}
static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f)
{
- return ((int*) ccgSubSurf_getFaceUserData(ss, f))[1];
+ return ((int *) ccgSubSurf_getFaceUserData(ss, f))[1];
}
static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGVertIterator *vi = ccgSubSurf_getVertIterator(ss);
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
@@ -657,7 +657,7 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
- for (i=0; i<edgeSize; i++)
+ for (i = 0; i < edgeSize; i++)
DO_MINMAX(edgeData[i].co, min_r, max_r);
}
@@ -665,12 +665,12 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
CCGFace *f = ccgFaceIterator_getCurrent(fi);
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- for (S=0; S<numVerts; S++) {
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- for (y=0; y<gridSize; y++)
- for (x=0; x<gridSize; x++)
- DO_MINMAX(faceGridData[y*gridSize + x].co, min_r, max_r);
+ for (y = 0; y < gridSize; y++)
+ for (x = 0; x < gridSize; x++)
+ DO_MINMAX(faceGridData[y * gridSize + x].co, min_r, max_r);
}
}
@@ -681,28 +681,28 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
static int ccgDM_getNumVerts(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
return ccgSubSurf_getNumFinalVerts(ccgdm->ss);
}
static int ccgDM_getNumEdges(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
return ccgSubSurf_getNumFinalEdges(ccgdm->ss);
}
static int ccgDM_getNumTessFaces(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
return ccgSubSurf_getNumFinalFaces(ccgdm->ss);
}
static int ccgDM_getNumLoops(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
/* All subsurf faces are quads */
return 4 * ccgSubSurf_getNumFinalFaces(ccgdm->ss);
@@ -710,7 +710,7 @@ static int ccgDM_getNumLoops(DerivedMesh *dm)
static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
DMGridData *vd;
int i;
@@ -814,7 +814,7 @@ static void ccgDM_getFinalVertNo(DerivedMesh *dm, int vertNum, float no_r[3])
static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int i;
@@ -833,39 +833,39 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
/* code added in bmesh but works correctly without, commenting - campbell */
#if 0
- int lasti, previ;
- i = lastface;
- lasti = 0;
- while (1) {
- previ = i;
- if (ccgdm->faceMap[i].startEdge >= edgeNum) {
- i -= fabsf(i-lasti)/2.0f;
- }
- else if (ccgdm->faceMap[i].startEdge < edgeNum) {
- i += fabsf(i-lasti)/2.0f;
- }
- else {
- break;
- }
+ int lasti, previ;
+ i = lastface;
+ lasti = 0;
+ while (1) {
+ previ = i;
+ if (ccgdm->faceMap[i].startEdge >= edgeNum) {
+ i -= fabsf(i - lasti) / 2.0f;
+ }
+ else if (ccgdm->faceMap[i].startEdge < edgeNum) {
+ i += fabsf(i - lasti) / 2.0f;
+ }
+ else {
+ break;
+ }
- if (i < 0) {
- i = 0;
- break;
- }
+ if (i < 0) {
+ i = 0;
+ break;
+ }
- if (i > lastface) {
- i = lastface;
- break;
+ if (i > lastface) {
+ i = lastface;
+ break;
- }
+ }
- if (i == lasti)
- break;
+ if (i == lasti)
+ break;
- lasti = previ;
- }
+ lasti = previ;
+ }
- i = i > 0 ? i - 1 : i;
+ i = i > 0 ? i - 1 : i;
#endif
i = 0;
@@ -885,7 +885,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
if (offset < gridSideEdges) {
x = offset;
med->v1 = getFaceIndex(ss, f, grid, x, 0, edgeSize, gridSize);
- med->v2 = getFaceIndex(ss, f, grid, x+1, 0, edgeSize, gridSize);
+ med->v2 = getFaceIndex(ss, f, grid, x + 1, 0, edgeSize, gridSize);
}
else {
offset -= gridSideEdges;
@@ -893,11 +893,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
y = (offset / 2) % gridSideEdges;
if (offset % 2 == 0) {
med->v1 = getFaceIndex(ss, f, grid, x, y, edgeSize, gridSize);
- med->v2 = getFaceIndex(ss, f, grid, x, y+1, edgeSize, gridSize);
+ med->v2 = getFaceIndex(ss, f, grid, x, y + 1, edgeSize, gridSize);
}
else {
med->v1 = getFaceIndex(ss, f, grid, y, x, edgeSize, gridSize);
- med->v2 = getFaceIndex(ss, f, grid, y+1, x, edgeSize, gridSize);
+ med->v2 = getFaceIndex(ss, f, grid, y + 1, x, edgeSize, gridSize);
}
}
}
@@ -918,12 +918,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
x = edgeNum - ccgdm->edgeMap[i].startEdge;
med->v1 = getEdgeIndex(ss, e, x, edgeSize);
- med->v2 = getEdgeIndex(ss, e, x+1, edgeSize);
+ med->v2 = getEdgeIndex(ss, e, x + 1, edgeSize);
- edgeFlag = (ccgdm->edgeFlags)? &ccgdm->edgeFlags[i]: NULL;
+ edgeFlag = (ccgdm->edgeFlags) ? &ccgdm->edgeFlags[i] : NULL;
if (edgeFlag)
- flags |= (*edgeFlag & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE))
- | ME_EDGEDRAW | ME_EDGERENDER;
+ flags |= (*edgeFlag & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE)) | ME_EDGEDRAW | ME_EDGERENDER;
else
flags |= ME_EDGEDRAW | ME_EDGERENDER;
@@ -933,7 +932,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int gridSize = ccgSubSurf_getGridSize(ss);
int edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -963,10 +962,10 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
y = offset / gridSideEdges;
x = offset % gridSideEdges;
- mf->v1 = getFaceIndex(ss, f, grid, x+0, y+0, edgeSize, gridSize);
- mf->v2 = getFaceIndex(ss, f, grid, x+0, y+1, edgeSize, gridSize);
- mf->v3 = getFaceIndex(ss, f, grid, x+1, y+1, edgeSize, gridSize);
- mf->v4 = getFaceIndex(ss, f, grid, x+1, y+0, edgeSize, gridSize);
+ mf->v1 = getFaceIndex(ss, f, grid, x + 0, y + 0, edgeSize, gridSize);
+ mf->v2 = getFaceIndex(ss, f, grid, x + 0, y + 1, edgeSize, gridSize);
+ mf->v3 = getFaceIndex(ss, f, grid, x + 1, y + 1, edgeSize, gridSize);
+ mf->v4 = getFaceIndex(ss, f, grid, x + 1, y + 0, edgeSize, gridSize);
if (faceFlags) {
mf->flag = faceFlags[i].flag;
@@ -976,11 +975,11 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
}
/* Translate GridHidden into the ME_HIDE flag for MVerts. Assumes
- vertices are in the order output by ccgDM_copyFinalVertArray. */
+ * vertices are in the order output by ccgDM_copyFinalVertArray. */
void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
- MVert *mvert, const MDisps *mdisps)
+ MVert *mvert, const MDisps *mdisps)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
CCGSubSurf *ss = ccgdm->ss;
int level = ccgSubSurf_getSubdivisionLevels(ss);
int gridSize = ccgSubSurf_getGridSize(ss);
@@ -1004,7 +1003,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
int vndx, offset;
vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize);
- offset = (y*factor) * hidden_gridsize + (x*factor);
+ offset = (y * factor) * hidden_gridsize + (x * factor);
if (BLI_BITMAP_GET(md->hidden, offset))
mvert[vndx].flag |= ME_HIDE;
}
@@ -1015,7 +1014,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
DMGridData *vd;
int index;
@@ -1029,14 +1028,14 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
- vd= ccgSubSurf_getFaceCenterData(f);
+ vd = ccgSubSurf_getFaceCenterData(f);
copy_v3_v3(mvert[i].co, vd->co);
normal_float_to_short_v3(mvert[i].no, vd->no);
i++;
for (S = 0; S < numVerts; S++) {
for (x = 1; x < gridSize - 1; x++, i++) {
- vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
+ vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
copy_v3_v3(mvert[i].co, vd->co);
normal_float_to_short_v3(mvert[i].no, vd->no);
}
@@ -1045,7 +1044,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
for (S = 0; S < numVerts; S++) {
for (y = 1; y < gridSize - 1; y++) {
for (x = 1; x < gridSize - 1; x++, i++) {
- vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y);
+ vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y);
copy_v3_v3(mvert[i].co, vd->co);
normal_float_to_short_v3(mvert[i].no, vd->no);
}
@@ -1059,7 +1058,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
int x;
for (x = 1; x < edgeSize - 1; x++, i++) {
- vd= ccgSubSurf_getEdgeData(ss, e, x);
+ vd = ccgSubSurf_getEdgeData(ss, e, x);
copy_v3_v3(mvert[i].co, vd->co);
/* This gives errors with -debug-fpe
* the normals don't seem to be unit length.
@@ -1074,7 +1073,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
for (index = 0; index < totvert; index++) {
CCGVert *v = ccgdm->vertMap[index].vert;
- vd= ccgSubSurf_getVertData(ss, v);
+ vd = ccgSubSurf_getVertData(ss, v);
copy_v3_v3(mvert[i].co, vd->co);
normal_float_to_short_v3(mvert[i].no, vd->no);
i++;
@@ -1083,7 +1082,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int index;
int totedge, totface;
@@ -1116,18 +1115,18 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
if (ccgdm->drawInteriorEdges)
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
med->v1 = getFaceIndex(ss, f, S, x, y,
- edgeSize, gridSize);
+ edgeSize, gridSize);
med->v2 = getFaceIndex(ss, f, S, x, y + 1,
- edgeSize, gridSize);
+ edgeSize, gridSize);
i++;
med = &medge[i];
if (ccgdm->drawInteriorEdges)
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
med->v1 = getFaceIndex(ss, f, S, y, x,
- edgeSize, gridSize);
+ edgeSize, gridSize);
med->v2 = getFaceIndex(ss, f, S, y + 1, x,
- edgeSize, gridSize);
+ edgeSize, gridSize);
i++;
}
}
@@ -1146,7 +1145,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
if (edgeFlags) {
if (edgeIdx != -1) {
flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE))
- | ME_EDGEDRAW | ME_EDGERENDER;
+ | ME_EDGEDRAW | ME_EDGERENDER;
}
}
else {
@@ -1165,7 +1164,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int index;
int totface;
@@ -1179,21 +1178,21 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
/* keep types in sync with MFace, avoid many conversions */
- char flag = (faceFlags)? faceFlags[index].flag: ME_SMOOTH;
- short mat_nr = (faceFlags)? faceFlags[index].mat_nr: 0;
+ char flag = (faceFlags) ? faceFlags[index].flag : ME_SMOOTH;
+ short mat_nr = (faceFlags) ? faceFlags[index].mat_nr : 0;
for (S = 0; S < numVerts; S++) {
for (y = 0; y < gridSize - 1; y++) {
for (x = 0; x < gridSize - 1; x++) {
MFace *mf = &mface[i];
mf->v1 = getFaceIndex(ss, f, S, x + 0, y + 0,
- edgeSize, gridSize);
+ edgeSize, gridSize);
mf->v2 = getFaceIndex(ss, f, S, x + 0, y + 1,
- edgeSize, gridSize);
+ edgeSize, gridSize);
mf->v3 = getFaceIndex(ss, f, S, x + 1, y + 1,
- edgeSize, gridSize);
+ edgeSize, gridSize);
mf->v4 = getFaceIndex(ss, f, S, x + 1, y + 0,
- edgeSize, gridSize);
+ edgeSize, gridSize);
mf->mat_nr = mat_nr;
mf->flag = flag;
@@ -1206,7 +1205,7 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int index;
int totface;
@@ -1220,9 +1219,9 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
MEdge *medge;
ccgdm->ehash = BLI_edgehash_new();
- medge = ccgdm->dm.getEdgeArray((DerivedMesh*)ccgdm);
+ medge = ccgdm->dm.getEdgeArray((DerivedMesh *)ccgdm);
- for (i=0; i<ccgdm->dm.numEdgeData; i++) {
+ for (i = 0; i < ccgdm->dm.numEdgeData; i++) {
BLI_edgehash_insert(ccgdm->ehash, medge[i].v1, medge[i].v2, SET_INT_IN_POINTER(i));
}
}
@@ -1241,14 +1240,14 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
int v1, v2, v3, v4;
v1 = getFaceIndex(ss, f, S, x + 0, y + 0,
- edgeSize, gridSize);
+ edgeSize, gridSize);
v2 = getFaceIndex(ss, f, S, x + 0, y + 1,
- edgeSize, gridSize);
+ edgeSize, gridSize);
v3 = getFaceIndex(ss, f, S, x + 1, y + 1,
- edgeSize, gridSize);
+ edgeSize, gridSize);
v4 = getFaceIndex(ss, f, S, x + 1, y + 0,
- edgeSize, gridSize);
+ edgeSize, gridSize);
mv->v = v1;
mv->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(ccgdm->ehash, v1, v2));
@@ -1273,7 +1272,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int index;
int totface;
@@ -1286,8 +1285,8 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
- int flag = (faceFlags)? faceFlags[index].flag: ME_SMOOTH;
- int mat_nr = (faceFlags)? faceFlags[index].mat_nr: 0;
+ int flag = (faceFlags) ? faceFlags[index].flag : ME_SMOOTH;
+ int mat_nr = (faceFlags) ? faceFlags[index].mat_nr : 0;
for (S = 0; S < numVerts; S++) {
for (y = 0; y < gridSize - 1; y++) {
@@ -1309,7 +1308,7 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
int gridSize = ccgSubSurf_getGridSize(ss);
@@ -1323,7 +1322,7 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
int index, totvert, totedge, totface;
totvert = ccgSubSurf_getNumVerts(ss);
- vertMap2 = MEM_mallocN(totvert*sizeof(*vertMap2), "vertmap");
+ vertMap2 = MEM_mallocN(totvert * sizeof(*vertMap2), "vertmap");
vi = ccgSubSurf_getVertIterator(ss);
for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
CCGVert *v = ccgVertIterator_getCurrent(vi);
@@ -1333,16 +1332,16 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
ccgVertIterator_free(vi);
totedge = ccgSubSurf_getNumEdges(ss);
- edgeMap2 = MEM_mallocN(totedge*sizeof(*edgeMap2), "edgemap");
+ edgeMap2 = MEM_mallocN(totedge * sizeof(*edgeMap2), "edgemap");
ei = ccgSubSurf_getEdgeIterator(ss);
- for (i=0; !ccgEdgeIterator_isStopped(ei); i++,ccgEdgeIterator_next(ei)) {
+ for (i = 0; !ccgEdgeIterator_isStopped(ei); i++, ccgEdgeIterator_next(ei)) {
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
edgeMap2[GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e))] = e;
}
totface = ccgSubSurf_getNumFaces(ss);
- faceMap2 = MEM_mallocN(totface*sizeof(*faceMap2), "facemap");
+ faceMap2 = MEM_mallocN(totface * sizeof(*faceMap2), "facemap");
fi = ccgSubSurf_getFaceIterator(ss);
for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
CCGFace *f = ccgFaceIterator_getCurrent(fi);
@@ -1352,37 +1351,37 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
ccgFaceIterator_free(fi);
i = 0;
- for (index=0; index<totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = faceMap2[index];
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
copy_v3_v3(cos[i++], ccgSubSurf_getFaceCenterData(f));
- for (S=0; S<numVerts; S++) {
- for (x=1; x<gridSize-1; x++) {
+ for (S = 0; S < numVerts; S++) {
+ for (x = 1; x < gridSize - 1; x++) {
copy_v3_v3(cos[i++], ccgSubSurf_getFaceGridEdgeData(ss, f, S, x));
}
}
- for (S=0; S<numVerts; S++) {
- for (y=1; y<gridSize-1; y++) {
- for (x=1; x<gridSize-1; x++) {
+ for (S = 0; S < numVerts; S++) {
+ for (y = 1; y < gridSize - 1; y++) {
+ for (x = 1; x < gridSize - 1; x++) {
copy_v3_v3(cos[i++], ccgSubSurf_getFaceGridData(ss, f, S, x, y));
}
}
}
}
- for (index=0; index<totedge; index++) {
- CCGEdge *e= edgeMap2[index];
+ for (index = 0; index < totedge; index++) {
+ CCGEdge *e = edgeMap2[index];
int x;
- for (x=1; x<edgeSize-1; x++) {
+ for (x = 1; x < edgeSize - 1; x++) {
copy_v3_v3(cos[i++], ccgSubSurf_getEdgeData(ss, e, x));
}
}
- for (index=0; index<totvert; index++) {
+ for (index = 0; index < totvert; index++) {
CCGVert *v = vertMap2[index];
copy_v3_v3(cos[i++], ccgSubSurf_getVertData(ss, v));
}
@@ -1393,11 +1392,11 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
}
static void ccgDM_foreachMappedVert(
- DerivedMesh *dm,
- void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
- void *userData)
+ DerivedMesh *dm,
+ void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGVertIterator *vi = ccgSubSurf_getVertIterator(ccgdm->ss);
for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
@@ -1405,7 +1404,7 @@ static void ccgDM_foreachMappedVert(
DMGridData *vd = ccgSubSurf_getVertData(ccgdm->ss, v);
int index = ccgDM_getVertMapIndex(ccgdm->ss, v);
- if (index!=-1)
+ if (index != -1)
func(userData, index, vd->co, vd->no, NULL);
}
@@ -1413,11 +1412,11 @@ static void ccgDM_foreachMappedVert(
}
static void ccgDM_foreachMappedEdge(
- DerivedMesh *dm,
- void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]),
- void *userData)
+ DerivedMesh *dm,
+ void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]),
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -1427,9 +1426,9 @@ static void ccgDM_foreachMappedEdge(
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
int index = ccgDM_getEdgeMapIndex(ss, e);
- if (index!=-1) {
- for (i=0; i<edgeSize-1; i++)
- func(userData, index, edgeData[i].co, edgeData[i+1].co);
+ if (index != -1) {
+ for (i = 0; i < edgeSize - 1; i++)
+ func(userData, index, edgeData[i].co, edgeData[i + 1].co);
}
}
@@ -1438,7 +1437,7 @@ static void ccgDM_foreachMappedEdge(
static void ccgDM_drawVerts(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
int gridSize = ccgSubSurf_getGridSize(ss);
@@ -1459,7 +1458,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm)
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
int x;
- for (x=1; x<edgeSize-1; x++)
+ for (x = 1; x < edgeSize - 1; x++)
glVertex3fv(ccgSubSurf_getEdgeData(ss, e, x));
}
ccgEdgeIterator_free(ei);
@@ -1470,12 +1469,12 @@ static void ccgDM_drawVerts(DerivedMesh *dm)
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
glVertex3fv(ccgSubSurf_getFaceCenterData(f));
- for (S=0; S<numVerts; S++)
- for (x=1; x<gridSize-1; x++)
+ for (S = 0; S < numVerts; S++)
+ for (x = 1; x < gridSize - 1; x++)
glVertex3fv(ccgSubSurf_getFaceGridEdgeData(ss, f, S, x));
- for (S=0; S<numVerts; S++)
- for (y=1; y<gridSize-1; y++)
- for (x=1; x<gridSize-1; x++)
+ for (S = 0; S < numVerts; S++)
+ for (y = 1; y < gridSize - 1; y++)
+ for (x = 1; x < gridSize - 1; x++)
glVertex3fv(ccgSubSurf_getFaceGridData(ss, f, S, x, y));
}
ccgFaceIterator_free(fi);
@@ -1488,7 +1487,7 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
CCGFace **faces;
int totface;
- BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface);
+ BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void ***)&faces, &totface);
if (totface) {
ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface);
ccgSubSurf_updateNormals(ccgdm->ss, faces, totface);
@@ -1499,7 +1498,7 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
int totedge = ccgSubSurf_getNumEdges(ss);
@@ -1510,7 +1509,7 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
- for (j=0; j< totedge; j++) {
+ for (j = 0; j < totedge; j++) {
CCGEdge *e = ccgdm->edgeMap[j].edge;
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
@@ -1520,20 +1519,20 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
if (!drawAllEdges && ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW))
continue;
- if (useAging && !(G.f&G_BACKBUFSEL)) {
- int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
- glColor3ub(0, ageCol>0?ageCol:0, 0);
+ if (useAging && !(G.f & G_BACKBUFSEL)) {
+ int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
+ glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
}
glBegin(GL_LINE_STRIP);
- for (i=0; i<edgeSize-1; i++) {
+ for (i = 0; i < edgeSize - 1; i++) {
glVertex3fv(edgeData[i].co);
- glVertex3fv(edgeData[i+1].co);
+ glVertex3fv(edgeData[i + 1].co);
}
glEnd();
}
- if (useAging && !(G.f&G_BACKBUFSEL)) {
+ if (useAging && !(G.f & G_BACKBUFSEL)) {
glColor3ub(0, 0, 0);
}
@@ -1544,23 +1543,23 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
CCGFace *f = ccgdm->faceMap[j].face;
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- for (S=0; S<numVerts; S++) {
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
glBegin(GL_LINE_STRIP);
- for (x=0; x<gridSize; x++)
+ for (x = 0; x < gridSize; x++)
glVertex3fv(faceGridData[x].co);
glEnd();
- for (y=1; y<gridSize-1; y++) {
+ for (y = 1; y < gridSize - 1; y++) {
glBegin(GL_LINE_STRIP);
- for (x=0; x<gridSize; x++)
- glVertex3fv(faceGridData[y*gridSize + x].co);
+ for (x = 0; x < gridSize; x++)
+ glVertex3fv(faceGridData[y * gridSize + x].co);
glEnd();
}
- for (x=1; x<gridSize-1; x++) {
+ for (x = 1; x < gridSize - 1; x++) {
glBegin(GL_LINE_STRIP);
- for (y=0; y<gridSize; y++)
- glVertex3fv(faceGridData[y*gridSize + x].co);
+ for (y = 0; y < gridSize; y++)
+ glVertex3fv(faceGridData[y * gridSize + x].co);
glEnd();
}
}
@@ -1570,20 +1569,20 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
static void ccgDM_drawLooseEdges(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int totedge = ccgSubSurf_getNumEdges(ss);
int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
- for (j=0; j< totedge; j++) {
+ for (j = 0; j < totedge; j++) {
CCGEdge *e = ccgdm->edgeMap[j].edge;
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
if (!ccgSubSurf_getEdgeNumFaces(e)) {
glBegin(GL_LINE_STRIP);
- for (i=0; i<edgeSize-1; i++) {
+ for (i = 0; i < edgeSize - 1; i++) {
glVertex3fv(edgeData[i].co);
- glVertex3fv(edgeData[i+1].co);
+ glVertex3fv(edgeData[i + 1].co);
}
glEnd();
}
@@ -1592,26 +1591,26 @@ static void ccgDM_drawLooseEdges(DerivedMesh *dm)
static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
{
- float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
- float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
+ float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
+ float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
float no[3];
- no[0] = b_dY*a_cZ - b_dZ*a_cY;
- no[1] = b_dZ*a_cX - b_dX*a_cZ;
- no[2] = b_dX*a_cY - b_dY*a_cX;
+ no[0] = b_dY * a_cZ - b_dZ * a_cY;
+ no[1] = b_dZ * a_cX - b_dX * a_cZ;
+ no[2] = b_dX * a_cY - b_dY * a_cX;
/* don't normalize, GL_NORMALIZE is enabled */
glNormal3fv(no);
}
- /* Only used by non-editmesh types */
+/* Only used by non-editmesh types */
static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, DMSetMaterial setMaterial)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
int gridSize = ccgSubSurf_getGridSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
- int step = (fast)? gridSize-1: 1;
+ int step = (fast) ? gridSize - 1 : 1;
int i, totface = ccgSubSurf_getNumFaces(ss);
int drawcurrent = 0, matnr = -1, shademodel = -1;
@@ -1633,19 +1632,19 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
int new_matnr, new_shademodel;
if (faceFlags) {
- new_shademodel = (faceFlags[index].flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT;
- new_matnr= faceFlags[index].mat_nr;
+ new_shademodel = (faceFlags[index].flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT;
+ new_matnr = faceFlags[index].mat_nr;
}
else {
new_shademodel = GL_SMOOTH;
- new_matnr= 0;
+ new_matnr = 0;
}
if (shademodel != new_shademodel || matnr != new_matnr) {
- matnr= new_matnr;
- shademodel= new_shademodel;
+ matnr = new_matnr;
+ shademodel = new_shademodel;
- drawcurrent= setMaterial(matnr+1, NULL);
+ drawcurrent = setMaterial(matnr + 1, NULL);
glShadeModel(shademodel);
}
@@ -1653,15 +1652,15 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
if (!drawcurrent)
continue;
- for (S=0; S<numVerts; S++) {
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
if (shademodel == GL_SMOOTH) {
- for (y=0; y<gridSize-1; y+=step) {
+ for (y = 0; y < gridSize - 1; y += step) {
glBegin(GL_QUAD_STRIP);
- for (x=0; x<gridSize; x+=step) {
- DMGridData *a = &faceGridData[(y+0)*gridSize + x];
- DMGridData *b = &faceGridData[(y+step)*gridSize + x];
+ for (x = 0; x < gridSize; x += step) {
+ DMGridData *a = &faceGridData[(y + 0) * gridSize + x];
+ DMGridData *b = &faceGridData[(y + step) * gridSize + x];
glNormal3fv(a->no);
glVertex3fv(a->co);
@@ -1673,12 +1672,12 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
}
else {
glBegin(GL_QUADS);
- for (y=0; y<gridSize-1; y+=step) {
- for (x=0; x<gridSize-1; x+=step) {
- float *a = faceGridData[(y+0)*gridSize + x].co;
- float *b = faceGridData[(y+0)*gridSize + x + step].co;
- float *c = faceGridData[(y+step)*gridSize + x + step].co;
- float *d = faceGridData[(y+step)*gridSize + x].co;
+ for (y = 0; y < gridSize - 1; y += step) {
+ for (x = 0; x < gridSize - 1; x += step) {
+ float *a = faceGridData[(y + 0) * gridSize + x].co;
+ float *b = faceGridData[(y + 0) * gridSize + x + step].co;
+ float *c = faceGridData[(y + step) * gridSize + x + step].co;
+ float *d = faceGridData[(y + step) * gridSize + x].co;
ccgDM_glNormalFast(a, b, c, d);
@@ -1694,16 +1693,16 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
}
}
- /* Only used by non-editmesh types */
+/* Only used by non-editmesh types */
static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
- DMSetMaterial setMaterial,
- DMSetDrawOptions setDrawOptions,
- void *userData)
+ DMSetMaterial setMaterial,
+ DMSetDrawOptions setDrawOptions,
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
GPUVertexAttribs gattribs;
- DMVertexAttribs attribs= {{{NULL}}};
+ DMVertexAttribs attribs = {{{NULL}}};
/* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
int gridSize = ccgSubSurf_getGridSize(ss);
int gridFaces = gridSize - 1;
@@ -1716,25 +1715,25 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
doDraw = 0;
matnr = -1;
-#define PASSATTRIB(dx, dy, vert) { \
- if (attribs.totorco) { \
- index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \
- glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
- } \
- for (b = 0; b < attribs.tottface; b++) { \
- MTFace *tf = &attribs.tface[b].array[a]; \
- glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
- } \
- for (b = 0; b < attribs.totmcol; b++) { \
- MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
- GLubyte col[4]; \
- col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
- glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
- } \
- if (attribs.tottang) { \
- float *tang = attribs.tang.array[a*4 + vert]; \
- glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
- } \
+#define PASSATTRIB(dx, dy, vert) { \
+ if (attribs.totorco) { \
+ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
+ glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
+ } \
+ for (b = 0; b < attribs.tottface; b++) { \
+ MTFace *tf = &attribs.tface[b].array[a]; \
+ glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
+ } \
+ for (b = 0; b < attribs.totmcol; b++) { \
+ MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \
+ GLubyte col[4]; \
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \
+ glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
+ } \
+ if (attribs.tottang) { \
+ float *tang = attribs.tang.array[a * 4 + vert]; \
+ glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
+ } \
}
totface = ccgSubSurf_getNumFaces(ss);
@@ -1748,11 +1747,11 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
if (faceFlags) {
drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
- new_matnr= faceFlags[index].mat_nr + 1;
+ new_matnr = faceFlags[index].mat_nr + 1;
}
else {
drawSmooth = 1;
- new_matnr= 1;
+ new_matnr = 1;
}
if (new_matnr != matnr) {
@@ -1762,22 +1761,23 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
if (!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) &&
- (setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP))) {
- a += gridFaces*gridFaces*numVerts;
+ (setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP)))
+ {
+ a += gridFaces * gridFaces * numVerts;
continue;
}
- glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
- for (S=0; S<numVerts; S++) {
+ glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
DMGridData *vda, *vdb;
if (drawSmooth) {
- for (y=0; y<gridFaces; y++) {
+ for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP);
- for (x=0; x<gridFaces; x++) {
- vda = &faceGridData[(y+0)*gridSize + x];
- vdb = &faceGridData[(y+1)*gridSize + x];
+ for (x = 0; x < gridFaces; x++) {
+ vda = &faceGridData[(y + 0) * gridSize + x];
+ vdb = &faceGridData[(y + 1) * gridSize + x];
PASSATTRIB(0, 0, 0);
glNormal3fv(vda->no);
@@ -1787,12 +1787,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
glNormal3fv(vdb->no);
glVertex3fv(vdb->co);
- if (x != gridFaces-1)
+ if (x != gridFaces - 1)
a++;
}
- vda = &faceGridData[(y+0)*gridSize + x];
- vdb = &faceGridData[(y+1)*gridSize + x];
+ vda = &faceGridData[(y + 0) * gridSize + x];
+ vdb = &faceGridData[(y + 1) * gridSize + x];
PASSATTRIB(0, 0, 3);
glNormal3fv(vda->no);
@@ -1809,12 +1809,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
else {
glBegin(GL_QUADS);
- for (y=0; y<gridFaces; y++) {
- for (x=0; x<gridFaces; x++) {
- float *aco = faceGridData[(y+0)*gridSize + x].co;
- float *bco = faceGridData[(y+0)*gridSize + x + 1].co;
- float *cco = faceGridData[(y+1)*gridSize + x + 1].co;
- float *dco = faceGridData[(y+1)*gridSize + x].co;
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *aco = faceGridData[(y + 0) * gridSize + x].co;
+ float *bco = faceGridData[(y + 0) * gridSize + x + 1].co;
+ float *cco = faceGridData[(y + 1) * gridSize + x + 1].co;
+ float *dco = faceGridData[(y + 1) * gridSize + x].co;
ccgDM_glNormalFast(aco, bco, cco, dco);
@@ -1843,13 +1843,13 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
}
- /* Only used by non-editmesh types */
+/* Only used by non-editmesh types */
static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
GPUVertexAttribs gattribs;
- DMVertexAttribs attribs= {{{NULL}}};
+ DMVertexAttribs attribs = {{{NULL}}};
int gridSize = ccgSubSurf_getGridSize(ss);
int gridFaces = gridSize - 1;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -1860,31 +1860,31 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
matnr = -1;
-#define PASSATTRIB(dx, dy, vert) { \
- if (attribs.totorco) { \
- index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \
- if (attribs.orco.glTexco) \
- glTexCoord3fv(attribs.orco.array[index]); \
- else \
- glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
- } \
- for (b = 0; b < attribs.tottface; b++) { \
- MTFace *tf = &attribs.tface[b].array[a]; \
- if (attribs.tface[b].glTexco) \
- glTexCoord2fv(tf->uv[vert]); \
- else \
- glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
- } \
- for (b = 0; b < attribs.totmcol; b++) { \
- MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
- GLubyte col[4]; \
- col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
- glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
- } \
- if (attribs.tottang) { \
- float *tang = attribs.tang.array[a*4 + vert]; \
- glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
- } \
+#define PASSATTRIB(dx, dy, vert) { \
+ if (attribs.totorco) { \
+ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
+ if (attribs.orco.glTexco) \
+ glTexCoord3fv(attribs.orco.array[index]); \
+ else \
+ glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
+ } \
+ for (b = 0; b < attribs.tottface; b++) { \
+ MTFace *tf = &attribs.tface[b].array[a]; \
+ if (attribs.tface[b].glTexco) \
+ glTexCoord2fv(tf->uv[vert]); \
+ else \
+ glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
+ } \
+ for (b = 0; b < attribs.totmcol; b++) { \
+ MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \
+ GLubyte col[4]; \
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \
+ glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
+ } \
+ if (attribs.tottang) { \
+ float *tang = attribs.tang.array[a * 4 + vert]; \
+ glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
+ } \
}
totface = ccgSubSurf_getNumFaces(ss);
@@ -1899,11 +1899,11 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
/* get flags */
if (faceFlags) {
drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
- new_matnr= faceFlags[index].mat_nr + 1;
+ new_matnr = faceFlags[index].mat_nr + 1;
}
else {
drawSmooth = 1;
- new_matnr= 1;
+ new_matnr = 1;
}
/* material */
@@ -1914,22 +1914,22 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
/* face hiding */
if ((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
- a += gridFaces*gridFaces*numVerts;
+ a += gridFaces * gridFaces * numVerts;
continue;
}
/* draw face*/
- glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
- for (S=0; S<numVerts; S++) {
+ glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
DMGridData *vda, *vdb;
if (drawSmooth) {
- for (y=0; y<gridFaces; y++) {
+ for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP);
- for (x=0; x<gridFaces; x++) {
- vda = &faceGridData[(y+0)*gridSize + x];
- vdb = &faceGridData[(y+1)*gridSize + x];
+ for (x = 0; x < gridFaces; x++) {
+ vda = &faceGridData[(y + 0) * gridSize + x];
+ vdb = &faceGridData[(y + 1) * gridSize + x];
PASSATTRIB(0, 0, 0);
glNormal3fv(vda->no);
@@ -1939,12 +1939,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
glNormal3fv(vdb->no);
glVertex3fv(vdb->co);
- if (x != gridFaces-1)
+ if (x != gridFaces - 1)
a++;
}
- vda = &faceGridData[(y+0)*gridSize + x];
- vdb = &faceGridData[(y+1)*gridSize + x];
+ vda = &faceGridData[(y + 0) * gridSize + x];
+ vdb = &faceGridData[(y + 1) * gridSize + x];
PASSATTRIB(0, 0, 3);
glNormal3fv(vda->no);
@@ -1961,12 +1961,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
}
else {
glBegin(GL_QUADS);
- for (y=0; y<gridFaces; y++) {
- for (x=0; x<gridFaces; x++) {
- float *aco = faceGridData[(y+0)*gridSize + x].co;
- float *bco = faceGridData[(y+0)*gridSize + x + 1].co;
- float *cco = faceGridData[(y+1)*gridSize + x + 1].co;
- float *dco = faceGridData[(y+1)*gridSize + x].co;
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *aco = faceGridData[(y + 0) * gridSize + x].co;
+ float *bco = faceGridData[(y + 0) * gridSize + x + 1].co;
+ float *cco = faceGridData[(y + 1) * gridSize + x + 1].co;
+ float *dco = faceGridData[(y + 1) * gridSize + x].co;
ccgDM_glNormalFast(aco, bco, cco, dco);
@@ -1991,12 +1991,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
}
static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
- DMSetDrawOptionsTex drawParams,
- DMSetDrawOptions drawParamsMapped,
- DMCompareDrawOptions compareDrawOptions,
- void *userData)
+ DMSetDrawOptionsTex drawParams,
+ DMSetDrawOptions drawParamsMapped,
+ DMCompareDrawOptions compareDrawOptions,
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
@@ -2021,50 +2021,50 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- unsigned char *cp= NULL;
+ unsigned char *cp = NULL;
int mat_nr;
if (faceFlags) {
drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
- mat_nr= faceFlags[origIndex].mat_nr;
+ mat_nr = faceFlags[origIndex].mat_nr;
}
else {
drawSmooth = 1;
- mat_nr= 0;
+ mat_nr = 0;
}
if (drawParams)
draw_option = drawParams(tf, (mcol != NULL), mat_nr);
else if (index != ORIGINDEX_NONE)
- draw_option= (drawParamsMapped)? drawParamsMapped(userData, index): DM_DRAW_OPTION_NORMAL;
+ draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index) : DM_DRAW_OPTION_NORMAL;
else
- draw_option= GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
+ draw_option = GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
if (draw_option == DM_DRAW_OPTION_SKIP) {
- if (tf) tf += gridFaces*gridFaces*numVerts;
- if (mcol) mcol += gridFaces*gridFaces*numVerts*4;
+ if (tf) tf += gridFaces * gridFaces * numVerts;
+ if (mcol) mcol += gridFaces * gridFaces * numVerts * 4;
continue;
}
/* flag 1 == use vertex colors */
if (mcol) {
if (draw_option != DM_DRAW_OPTION_NO_MCOL)
- cp= (unsigned char*)mcol;
- mcol += gridFaces*gridFaces*numVerts*4;
+ cp = (unsigned char *)mcol;
+ mcol += gridFaces * gridFaces * numVerts * 4;
}
- for (S=0; S<numVerts; S++) {
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
DMGridData *a, *b;
if (drawSmooth) {
glShadeModel(GL_SMOOTH);
- for (y=0; y<gridFaces; y++) {
+ for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP);
- for (x=0; x<gridFaces; x++) {
- a = &faceGridData[(y+0)*gridSize + x];
- b = &faceGridData[(y+1)*gridSize + x];
+ for (x = 0; x < gridFaces; x++) {
+ a = &faceGridData[(y + 0) * gridSize + x];
+ b = &faceGridData[(y + 1) * gridSize + x];
if (tf) glTexCoord2fv(tf->uv[0]);
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
@@ -2076,14 +2076,14 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
glNormal3fv(b->no);
glVertex3fv(b->co);
- if (x != gridFaces-1) {
+ if (x != gridFaces - 1) {
if (tf) tf++;
if (cp) cp += 16;
}
}
- a = &faceGridData[(y+0)*gridSize + x];
- b = &faceGridData[(y+1)*gridSize + x];
+ a = &faceGridData[(y + 0) * gridSize + x];
+ b = &faceGridData[(y + 1) * gridSize + x];
if (tf) glTexCoord2fv(tf->uv[3]);
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
@@ -2104,12 +2104,12 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
else {
glShadeModel(GL_FLAT);
glBegin(GL_QUADS);
- for (y=0; y<gridFaces; y++) {
- for (x=0; x<gridFaces; x++) {
- float *a_co = faceGridData[(y+0)*gridSize + x].co;
- float *b_co = faceGridData[(y+0)*gridSize + x + 1].co;
- float *c_co = faceGridData[(y+1)*gridSize + x + 1].co;
- float *d_co = faceGridData[(y+1)*gridSize + x].co;
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *a_co = faceGridData[(y + 0) * gridSize + x].co;
+ float *b_co = faceGridData[(y + 0) * gridSize + x + 1].co;
+ float *c_co = faceGridData[(y + 1) * gridSize + x + 1].co;
+ float *d_co = faceGridData[(y + 1) * gridSize + x].co;
ccgDM_glNormalFast(a_co, b_co, c_co, d_co);
@@ -2140,17 +2140,17 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
}
static void ccgDM_drawFacesTex(DerivedMesh *dm,
- DMSetDrawOptionsTex setDrawOptions,
- DMCompareDrawOptions compareDrawOptions,
- void *userData)
+ DMSetDrawOptionsTex setDrawOptions,
+ DMCompareDrawOptions compareDrawOptions,
+ void *userData)
{
ccgDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
}
static void ccgDM_drawMappedFacesTex(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMCompareDrawOptions compareDrawOptions,
- void *userData)
+ DMSetDrawOptions setDrawOptions,
+ DMCompareDrawOptions compareDrawOptions,
+ void *userData)
{
ccgDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
}
@@ -2165,7 +2165,7 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
if (tf) {
glBegin(GL_LINES);
for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
- if (!(mf->flag&ME_HIDE)) {
+ if (!(mf->flag & ME_HIDE)) {
glVertex2fv(tf->uv[0]);
glVertex2fv(tf->uv[1]);
@@ -2190,14 +2190,14 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
}
static void ccgDM_drawMappedFaces(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetMaterial setMaterial,
- DMCompareDrawOptions compareDrawOptions,
- void *userData, DMDrawFlag flag)
+ DMSetDrawOptions setDrawOptions,
+ DMSetMaterial setMaterial,
+ DMCompareDrawOptions compareDrawOptions,
+ void *userData, DMDrawFlag flag)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
- MCol *mcol= NULL;
+ MCol *mcol = NULL;
int i, gridSize = ccgSubSurf_getGridSize(ss);
DMFlagMat *faceFlags = ccgdm->faceFlags;
int useColors = flag & DM_DRAW_USE_COLORS;
@@ -2218,7 +2218,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
int origIndex;
- unsigned char *cp= NULL;
+ unsigned char *cp = NULL;
origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
@@ -2227,37 +2227,37 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
else drawSmooth = 1;
if (mcol) {
- cp= (unsigned char*)mcol;
- mcol += gridFaces*gridFaces*numVerts*4;
+ cp = (unsigned char *)mcol;
+ mcol += gridFaces * gridFaces * numVerts * 4;
}
{
- DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL;
+ DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
if (index == ORIGINDEX_NONE)
- draw_option= setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1: 1, NULL); /* XXX, no faceFlags no material */
+ draw_option = setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1 : 1, NULL); /* XXX, no faceFlags no material */
else if (setDrawOptions)
- draw_option= setDrawOptions(userData, index);
+ draw_option = setDrawOptions(userData, index);
if (draw_option != DM_DRAW_OPTION_SKIP) {
if (draw_option == DM_DRAW_OPTION_STIPPLE) {
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(stipple_quarttone);
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(stipple_quarttone);
}
/* no need to set shading mode to flat because
* normals are already used to change shading */
glShadeModel(GL_SMOOTH);
- for (S=0; S<numVerts; S++) {
+ for (S = 0; S < numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
if (drawSmooth) {
- for (y=0; y<gridFaces; y++) {
+ for (y = 0; y < gridFaces; y++) {
DMGridData *a, *b;
glBegin(GL_QUAD_STRIP);
- for (x=0; x<gridFaces; x++) {
- a = &faceGridData[(y+0)*gridSize + x];
- b = &faceGridData[(y+1)*gridSize + x];
+ for (x = 0; x < gridFaces; x++) {
+ a = &faceGridData[(y + 0) * gridSize + x];
+ b = &faceGridData[(y + 1) * gridSize + x];
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glNormal3fv(a->no);
@@ -2266,13 +2266,13 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
glNormal3fv(b->no);
glVertex3fv(b->co);
- if (x != gridFaces-1) {
+ if (x != gridFaces - 1) {
if (cp) cp += 16;
}
}
- a = &faceGridData[(y+0)*gridSize + x];
- b = &faceGridData[(y+1)*gridSize + x];
+ a = &faceGridData[(y + 0) * gridSize + x];
+ b = &faceGridData[(y + 1) * gridSize + x];
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glNormal3fv(a->no);
@@ -2288,12 +2288,12 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
}
else {
glBegin(GL_QUADS);
- for (y=0; y<gridFaces; y++) {
- for (x=0; x<gridFaces; x++) {
- float *a = faceGridData[(y+0)*gridSize + x].co;
- float *b = faceGridData[(y+0)*gridSize + x + 1].co;
- float *c = faceGridData[(y+1)*gridSize + x + 1].co;
- float *d = faceGridData[(y+1)*gridSize + x].co;
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ float *a = faceGridData[(y + 0) * gridSize + x].co;
+ float *b = faceGridData[(y + 0) * gridSize + x + 1].co;
+ float *c = faceGridData[(y + 1) * gridSize + x + 1].co;
+ float *d = faceGridData[(y + 1) * gridSize + x].co;
ccgDM_glNormalFast(a, b, c, d);
@@ -2320,10 +2320,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
}
static void ccgDM_drawMappedEdges(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- void *userData)
+ DMSetDrawOptions setDrawOptions,
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -2336,15 +2336,15 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm,
int index = ccgDM_getEdgeMapIndex(ss, e);
glBegin(GL_LINE_STRIP);
- if (index!=-1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
- if (useAging && !(G.f&G_BACKBUFSEL)) {
- int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
- glColor3ub(0, ageCol>0?ageCol:0, 0);
+ if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
+ if (useAging && !(G.f & G_BACKBUFSEL)) {
+ int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
+ glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
}
- for (i=0; i<edgeSize-1; i++) {
+ for (i = 0; i < edgeSize - 1; i++) {
glVertex3fv(edgeData[i].co);
- glVertex3fv(edgeData[i+1].co);
+ glVertex3fv(edgeData[i + 1].co);
}
}
glEnd();
@@ -2354,11 +2354,11 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm,
}
static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetDrawInterpOptions setDrawInterpOptions,
- void *userData)
+ DMSetDrawOptions setDrawOptions,
+ DMSetDrawInterpOptions setDrawInterpOptions,
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -2371,13 +2371,13 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
int index = ccgDM_getEdgeMapIndex(ss, e);
glBegin(GL_LINE_STRIP);
- if (index!=-1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
- for (i=0; i<edgeSize; i++) {
- setDrawInterpOptions(userData, index, (float) i/(edgeSize-1));
+ if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
+ for (i = 0; i < edgeSize; i++) {
+ setDrawInterpOptions(userData, index, (float) i / (edgeSize - 1));
- if (useAging && !(G.f&G_BACKBUFSEL)) {
- int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
- glColor3ub(0, ageCol>0?ageCol:0, 0);
+ if (useAging && !(G.f & G_BACKBUFSEL)) {
+ int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
+ glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
}
glVertex3fv(edgeData[i].co);
@@ -2390,11 +2390,11 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
}
static void ccgDM_foreachMappedFaceCenter(
- DerivedMesh *dm,
- void (*func)(void *userData, int index, const float co[3], const float no[3]),
- void *userData)
+ DerivedMesh *dm,
+ void (*func)(void *userData, int index, const float co[3], const float no[3]),
+ void *userData)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
@@ -2402,8 +2402,8 @@ static void ccgDM_foreachMappedFaceCenter(
CCGFace *f = ccgFaceIterator_getCurrent(fi);
int index = ccgDM_getFaceMapIndex(ss, f);
- if (index!=-1) {
- /* Face center data normal isn't updated atm. */
+ if (index != -1) {
+ /* Face center data normal isn't updated atm. */
DMGridData *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0);
func(userData, index, vd->co, vd->no);
@@ -2415,15 +2415,17 @@ static void ccgDM_foreachMappedFaceCenter(
static void ccgDM_release(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
if (DM_release(dm)) {
/* Before freeing, need to update the displacement map */
if (ccgdm->multires.modified_flags) {
/* Check that mmd still exists */
if (!ccgdm->multires.local_mmd &&
- BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
+ BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
+ {
ccgdm->multires.mmd = NULL;
+ }
if (ccgdm->multires.mmd) {
if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED)
@@ -2473,23 +2475,23 @@ 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);
ME_MTEXFACE_CPY(texface, texpoly);
mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i);
- for (j=0; j<4; j++, mloopuv++) {
+ for (j = 0; j < 4; j++, mloopuv++) {
copy_v2_v2(texface->uv[j], mloopuv->uv);
}
}
- 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);
- for (j=0; j<4; j++, mloopcol++) {
+ for (j = 0; j < 4; j++, mloopcol++) {
MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
}
}
@@ -2498,7 +2500,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
mloopcol = CustomData_get(ldata, loopstart, CD_PREVIEW_MLOOPCOL);
mcol = CustomData_get(fdata, findex, CD_PREVIEW_MCOL);
- for (j=0; j<4; j++, mloopcol++) {
+ for (j = 0; j < 4; j++, mloopcol++) {
MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
}
}
@@ -2508,7 +2510,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
OrigSpaceLoop *lof;
lof = CustomData_get(ldata, loopstart, CD_ORIGSPACE_MLOOP);
- for (j=0; j<4; j++, lof++) {
+ for (j = 0; j < 4; j++, lof++) {
copy_v2_v2(of->uv[j], lof->uv);
}
}
@@ -2518,8 +2520,8 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
{
if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- CCGSubSurf *ss= ccgdm->ss;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
+ CCGSubSurf *ss = ccgdm->ss;
int *origindex;
int a, index, totnone, totorig;
@@ -2530,16 +2532,16 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
}
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
- origindex= DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+ origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
totorig = ccgSubSurf_getNumVerts(ss);
- totnone= dm->numVertData - totorig;
+ totnone = dm->numVertData - totorig;
/* original vertices are at the end */
- for (a=0; a<totnone; a++)
- origindex[a]= ORIGINDEX_NONE;
+ for (a = 0; a < totnone; a++)
+ origindex[a] = ORIGINDEX_NONE;
- for (index=0; index<totorig; index++, a++) {
+ for (index = 0; index < totorig; index++, a++) {
CCGVert *v = ccgdm->vertMap[index].vert;
origindex[a] = ccgDM_getVertMapIndex(ccgdm->ss, v);
}
@@ -2554,11 +2556,11 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
{
if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- CCGSubSurf *ss= ccgdm->ss;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
+ CCGSubSurf *ss = ccgdm->ss;
int *origindex;
int a, i, index, totnone, totorig, totedge;
- int edgeSize= ccgSubSurf_getEdgeSize(ss);
+ int edgeSize = ccgSubSurf_getEdgeSize(ss);
/* Avoid re-creation if the layer exists already */
origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
@@ -2567,22 +2569,22 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
}
DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
- origindex= DM_get_edge_data_layer(dm, CD_ORIGINDEX);
+ origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
- totedge= ccgSubSurf_getNumEdges(ss);
- totorig= totedge*(edgeSize - 1);
- totnone= dm->numEdgeData - totorig;
+ totedge = ccgSubSurf_getNumEdges(ss);
+ totorig = totedge * (edgeSize - 1);
+ totnone = dm->numEdgeData - totorig;
/* original edges are at the end */
- for (a=0; a<totnone; a++)
- origindex[a]= ORIGINDEX_NONE;
+ for (a = 0; a < totnone; a++)
+ origindex[a] = ORIGINDEX_NONE;
- for (index=0; index<totedge; index++) {
- CCGEdge *e= ccgdm->edgeMap[index].edge;
- int mapIndex= ccgDM_getEdgeMapIndex(ss, e);
+ for (index = 0; index < totedge; index++) {
+ CCGEdge *e = ccgdm->edgeMap[index].edge;
+ int mapIndex = ccgDM_getEdgeMapIndex(ss, e);
for (i = 0; i < edgeSize - 1; i++, a++)
- origindex[a]= mapIndex;
+ origindex[a] = mapIndex;
}
return origindex;
@@ -2595,8 +2597,8 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
{
if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- CCGSubSurf *ss= ccgdm->ss;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
+ CCGSubSurf *ss = ccgdm->ss;
int *origindex;
int a, i, index, totface;
int gridFaces = ccgSubSurf_getGridSize(ss) - 1;
@@ -2608,17 +2610,17 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
}
DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
- origindex= DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
- totface= ccgSubSurf_getNumFaces(ss);
+ totface = ccgSubSurf_getNumFaces(ss);
- for (a=0, index=0; index<totface; index++) {
+ for (a = 0, index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int numVerts = ccgSubSurf_getFaceNumVerts(f);
int mapIndex = ccgDM_getFaceMapIndex(ss, f);
- for (i=0; i<gridFaces*gridFaces*numVerts; i++, a++)
- origindex[a]= mapIndex;
+ for (i = 0; i < gridFaces * gridFaces * numVerts; i++, a++)
+ origindex[a] = mapIndex;
}
return origindex;
@@ -2659,13 +2661,13 @@ static void *ccgDM_get_tessface_data(DerivedMesh *dm, int index, int type)
static int ccgDM_getNumGrids(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
int index, numFaces, numGrids;
- numFaces= ccgSubSurf_getNumFaces(ccgdm->ss);
- numGrids= 0;
+ numFaces = ccgSubSurf_getNumFaces(ccgdm->ss);
+ numGrids = 0;
- for (index=0; index<numFaces; index++) {
+ for (index = 0; index < numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
numGrids += ccgSubSurf_getFaceNumVerts(f);
}
@@ -2675,7 +2677,7 @@ static int ccgDM_getNumGrids(DerivedMesh *dm)
static int ccgDM_getGridSize(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
return ccgSubSurf_getGridSize(ccgdm->ss);
}
@@ -2683,7 +2685,7 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset)
{
CCGFace *adjf;
CCGEdge *e;
- int i, j= 0, numFaces, fIndex, numEdges= 0;
+ int i, j = 0, numFaces, fIndex, numEdges = 0;
e = ccgSubSurf_getFaceEdge(f, S);
numFaces = ccgSubSurf_getEdgeNumFaces(e);
@@ -2710,13 +2712,13 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset)
fIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(adjf));
- return gridOffset[fIndex] + (j + offset)%numEdges;
+ return gridOffset[fIndex] + (j + offset) % numEdges;
}
static void ccgdm_create_grids(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- CCGSubSurf *ss= ccgdm->ss;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
+ CCGSubSurf *ss = ccgdm->ss;
DMGridData **gridData;
DMGridAdjacency *gridAdjacency, *adj;
DMFlagMat *gridFlagMats;
@@ -2732,7 +2734,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
/*gridSize = ccgDM_getGridSize(dm);*/ /*UNUSED*/
/* compute offset into grid array for each face */
- gridOffset = MEM_mallocN(sizeof(int)*numFaces, "ccgdm.gridOffset");
+ gridOffset = MEM_mallocN(sizeof(int) * numFaces, "ccgdm.gridOffset");
for (gIndex = 0, index = 0; index < numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
@@ -2743,12 +2745,12 @@ static void ccgdm_create_grids(DerivedMesh *dm)
}
/* compute grid data */
- gridData = MEM_mallocN(sizeof(DMGridData*)*numGrids, "ccgdm.gridData");
- gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency)*numGrids, "ccgdm.gridAdjacency");
- gridFaces = MEM_mallocN(sizeof(CCGFace*)*numGrids, "ccgdm.gridFaces");
- gridFlagMats = MEM_mallocN(sizeof(DMFlagMat)*numGrids, "ccgdm.gridFlagMats");
+ gridData = MEM_mallocN(sizeof(DMGridData *) * numGrids, "ccgdm.gridData");
+ gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency) * numGrids, "ccgdm.gridAdjacency");
+ gridFaces = MEM_mallocN(sizeof(CCGFace *) * numGrids, "ccgdm.gridFaces");
+ gridFlagMats = MEM_mallocN(sizeof(DMFlagMat) * numGrids, "ccgdm.gridFlagMats");
- ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap)*numGrids, "ccgdm.gridHidden");
+ ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap) * numGrids, "ccgdm.gridHidden");
for (gIndex = 0, index = 0; index < numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
@@ -2784,7 +2786,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
static DMGridData **ccgDM_getGridData(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
ccgdm_create_grids(dm);
return ccgdm->gridData;
@@ -2792,7 +2794,7 @@ static DMGridData **ccgDM_getGridData(DerivedMesh *dm)
static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
ccgdm_create_grids(dm);
return ccgdm->gridAdjacency;
@@ -2800,7 +2802,7 @@ static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm)
static int *ccgDM_getGridOffset(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
ccgdm_create_grids(dm);
return ccgdm->gridOffset;
@@ -2808,7 +2810,7 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm)
static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
ccgdm_create_grids(dm);
return ccgdm->gridFlagMats;
@@ -2816,7 +2818,7 @@ static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm)
static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
ccgdm_create_grids(dm);
return ccgdm->gridHidden;
@@ -2824,10 +2826,10 @@ static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm)
static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
if (!ccgdm->multires.mmd && !ccgdm->pmap && ob->type == OB_MESH) {
- Mesh *me= ob->data;
+ Mesh *me = ob->data;
create_vert_poly_map(&ccgdm->pmap, &ccgdm->pmap_mem,
me->mpoly, me->mloop,
@@ -2839,7 +2841,7 @@ static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm)
static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
{
- MultiresModifierData *mmd= ccgdm->multires.mmd;
+ MultiresModifierData *mmd = ccgdm->multires.mmd;
/* both of multires and subsurf modifiers are CCG, but
* grids should only be used when sculpting on multires */
@@ -2851,18 +2853,18 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
{
- CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
int gridSize, numGrids, grid_pbvh;
if (!ob) {
- ccgdm->pbvh= NULL;
+ ccgdm->pbvh = NULL;
return NULL;
}
if (!ob->sculpt)
return NULL;
- grid_pbvh= ccgDM_use_grid_pbvh(ccgdm);
+ grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
if (ob->sculpt->pbvh) {
if (grid_pbvh) {
@@ -2871,7 +2873,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
* when the ccgdm gets remade, the assumption is that the topology
* does not change. */
ccgdm_create_grids(dm);
- BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces);
+ BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void **)ccgdm->gridFaces);
}
ccgdm->pbvh = ob->sculpt->pbvh;
@@ -2889,16 +2891,16 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
gridSize = ccgDM_getGridSize(dm);
numGrids = ccgDM_getNumGrids(dm);
- ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
+ ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new();
BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
- numGrids, gridSize, (void**)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
+ numGrids, gridSize, (void **)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
}
else if (ob->type == OB_MESH) {
- Mesh *me= ob->data;
- ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
+ Mesh *me = ob->data;
+ ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new();
BLI_assert(!(me->mface == NULL && me->mpoly != NULL)); /* BMESH ONLY complain if mpoly is valid but not mface */
BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
- me->totface, me->totvert);
+ me->totface, me->totvert);
}
return ccgdm->pbvh;
@@ -2915,9 +2917,9 @@ static void ccgDM_calcNormals(DerivedMesh *UNUSED(dm))
}
static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
- int drawInteriorEdges,
- int useSubsurfUv,
- DerivedMesh *dm)
+ int drawInteriorEdges,
+ int useSubsurfUv,
+ DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = MEM_callocN(sizeof(*ccgdm), "ccgdm");
CCGVertIterator *vi;
@@ -2949,14 +2951,14 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
MPoly *mpoly = NULL;
DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM,
- ccgSubSurf_getNumFinalVerts(ss),
- ccgSubSurf_getNumFinalEdges(ss),
- ccgSubSurf_getNumFinalFaces(ss),
- ccgSubSurf_getNumFinalFaces(ss)*4,
- ccgSubSurf_getNumFinalFaces(ss));
+ ccgSubSurf_getNumFinalVerts(ss),
+ ccgSubSurf_getNumFinalEdges(ss),
+ ccgSubSurf_getNumFinalFaces(ss),
+ ccgSubSurf_getNumFinalFaces(ss) * 4,
+ ccgSubSurf_getNumFinalFaces(ss));
CustomData_free_layer_active(&ccgdm->dm.polyData, CD_NORMAL,
- ccgdm->dm.numPolyData);
+ ccgdm->dm.numPolyData);
numTex = CustomData_number_of_layers(&ccgdm->dm.loopData, CD_MLOOPUV);
numCol = CustomData_number_of_layers(&ccgdm->dm.loopData, CD_MLOOPCOL);
@@ -2964,10 +2966,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
hasOrigSpace = CustomData_has_layer(&ccgdm->dm.loopData, CD_ORIGSPACE_MLOOP);
if (
- (numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) ||
- (numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) ||
- (hasPCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_PREVIEW_MCOL)) ||
- (hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) )
+ (numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) ||
+ (numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) ||
+ (hasPCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_PREVIEW_MCOL)) ||
+ (hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) )
{
CustomData_from_bmeshpoly(&ccgdm->dm.faceData,
&ccgdm->dm.polyData,
@@ -3080,7 +3082,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
}
ccgFaceIterator_free(fi);
- ccgdm->reverseFaceMap = MEM_callocN(sizeof(int)*ccgSubSurf_getNumFinalFaces(ss), "reverseFaceMap");
+ ccgdm->reverseFaceMap = MEM_callocN(sizeof(int) * ccgSubSurf_getNumFinalFaces(ss), "reverseFaceMap");
edgeSize = ccgSubSurf_getEdgeSize(ss);
gridSize = ccgSubSurf_getGridSize(ss);
@@ -3102,8 +3104,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
base_polyOrigIndex = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
/*CDDM hack*/
- edgeFlags = ccgdm->edgeFlags = MEM_callocN(sizeof(short)*totedge, "edgeFlags");
- faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat)*totface, "faceFlags");
+ edgeFlags = ccgdm->edgeFlags = MEM_callocN(sizeof(short) * totedge, "edgeFlags");
+ faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat) * totface, "faceFlags");
vertOrigIndex = DM_get_vert_data_layer(&ccgdm->dm, CD_ORIGINDEX);
/*edgeOrigIndex = DM_get_edge_data_layer(&ccgdm->dm, CD_ORIGINDEX);*/
@@ -3128,7 +3130,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
int numVerts = ccgSubSurf_getFaceNumVerts(f);
int numFinalEdges = numVerts * (gridSideEdges + gridInternalEdges);
int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- int g2_wid = gridCuts+2;
+ int g2_wid = gridCuts + 2;
float *w2;
int s, x, y;
@@ -3145,16 +3147,16 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
faceFlags++;
/* set the face base vert */
- *((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
+ *((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
BLI_array_empty(loopidx);
- BLI_array_growitems(loopidx, numVerts);
+ BLI_array_grow_items(loopidx, numVerts);
for (s = 0; s < numVerts; s++) {
loopidx[s] = loopindex++;
}
BLI_array_empty(vertidx);
- BLI_array_growitems(vertidx, numVerts);
+ BLI_array_grow_items(vertidx, numVerts);
for (s = 0; s < numVerts; s++) {
CCGVert *v = ccgSubSurf_getFaceVert(f, s);
vertidx[s] = GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v));
@@ -3175,9 +3177,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
/*interpolate per-vert data*/
for (s = 0; s < numVerts; s++) {
for (x = 1; x < gridFaces; x++) {
- w2 = w + s*numVerts*g2_wid*g2_wid + x*numVerts;
+ w2 = w + s * numVerts * g2_wid * g2_wid + x * numVerts;
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
- numVerts, vertNum);
+ numVerts, vertNum);
if (vertOrigIndex) {
*vertOrigIndex = ORIGINDEX_NONE;
@@ -3192,9 +3194,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
for (s = 0; s < numVerts; s++) {
for (y = 1; y < gridFaces; y++) {
for (x = 1; x < gridFaces; x++) {
- w2 = w + s*numVerts*g2_wid*g2_wid + (y*g2_wid+x)*numVerts;
+ w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts;
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
- numVerts, vertNum);
+ numVerts, vertNum);
if (vertOrigIndex) {
*vertOrigIndex = ORIGINDEX_NONE;
@@ -3209,29 +3211,29 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
if (has_edge_origindex) {
for (i = 0; i < numFinalEdges; ++i)
*(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
- CD_ORIGINDEX) = ORIGINDEX_NONE;
+ CD_ORIGINDEX) = ORIGINDEX_NONE;
}
- for (s=0; s<numVerts; s++) {
+ for (s = 0; s < numVerts; s++) {
/*interpolate per-face data*/
- for (y=0; y<gridFaces; y++) {
- for (x=0; x<gridFaces; x++) {
- w2 = w + s*numVerts*g2_wid*g2_wid + (y*g2_wid+x)*numVerts;
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
+ w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts;
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
loopidx, w2, NULL, numVerts, loopindex2);
loopindex2++;
- w2 = w + s*numVerts*g2_wid*g2_wid + ((y+1)*g2_wid+(x))*numVerts;
+ w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x)) * numVerts;
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
loopidx, w2, NULL, numVerts, loopindex2);
loopindex2++;
- w2 = w + s*numVerts*g2_wid*g2_wid + ((y+1)*g2_wid+(x+1))*numVerts;
+ w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x + 1)) * numVerts;
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
loopidx, w2, NULL, numVerts, loopindex2);
loopindex2++;
- w2 = w + s*numVerts*g2_wid*g2_wid + ((y)*g2_wid+(x+1))*numVerts;
+ w2 = w + s * numVerts * g2_wid * g2_wid + ((y) * g2_wid + (x + 1)) * numVerts;
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
loopidx, w2, NULL, numVerts, loopindex2);
loopindex2++;
@@ -3241,7 +3243,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
/*generate tessellated face data used for drawing*/
ccg_loops_to_corners(&ccgdm->dm.faceData, &ccgdm->dm.loopData,
- &ccgdm->dm.polyData, loopindex2-4, faceNum, faceNum,
+ &ccgdm->dm.polyData, loopindex2 - 4, faceNum, faceNum,
numTex, numCol, hasPCol, hasOrigSpace);
/*set original index data*/
@@ -3288,7 +3290,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
edgeFlags[edgeIdx] = medge[edgeIdx].flag;
/* set the edge base vert */
- *((int*)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum;
+ *((int *)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum;
for (x = 1; x < edgeSize - 1; x++) {
float w[2];
@@ -3304,8 +3306,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
for (i = 0; i < numFinalEdges; ++i) {
if (has_edge_origindex) {
- *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
- CD_ORIGINDEX) = mapIndex;
+ *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, CD_ORIGINDEX) = mapIndex;
}
}
@@ -3318,7 +3319,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV);
int dmnumlayer = CustomData_number_of_layers(dmldata, CD_MLOOPUV);
- for (i=0; i<numlayer && i<dmnumlayer; i++)
+ for (i = 0; i < numlayer && i < dmnumlayer; i++)
set_subsurf_uv(ss, dm, &ccgdm->dm, i);
}
@@ -3332,7 +3333,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->vertMap[index].startVert = vertNum;
/* set the vert base vert */
- *((int*) ccgSubSurf_getVertUserData(ss, v)) = vertNum;
+ *((int *) ccgSubSurf_getVertUserData(ss, v)) = vertNum;
DM_copy_vert_data(dm, &ccgdm->dm, vertIdx, vertNum, 1);
@@ -3362,10 +3363,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
/***/
struct DerivedMesh *subsurf_make_derived_from_derived(
- struct DerivedMesh *dm,
- struct SubsurfModifierData *smd,
- int useRenderParams, float (*vertCos)[3],
- int isFinalCalc, int forEditMode, int inEditMode)
+ struct DerivedMesh *dm,
+ struct SubsurfModifierData *smd,
+ int useRenderParams, float (*vertCos)[3],
+ int isFinalCalc, int forEditMode, int inEditMode)
{
int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF;
CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0;
@@ -3374,35 +3375,35 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
CCGDerivedMesh *result;
if (forEditMode) {
- int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
+ int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels;
- smd->emCache = _getSubSurf(smd->emCache, levels, useAging|CCG_CALC_NORMALS);
+ smd->emCache = _getSubSurf(smd->emCache, levels, useAging | CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple);
result = getCCGDerivedMesh(smd->emCache,
- drawInteriorEdges,
- useSubsurfUv, dm);
+ drawInteriorEdges,
+ useSubsurfUv, dm);
}
else if (useRenderParams) {
/* Do not use cache in render mode. */
CCGSubSurf *ss;
- int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels): smd->renderLevels;
+ int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels) : smd->renderLevels;
if (levels == 0)
return dm;
- ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
+ ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
result = getCCGDerivedMesh(ss,
- drawInteriorEdges, useSubsurfUv, dm);
+ drawInteriorEdges, useSubsurfUv, dm);
result->freeSS = 1;
}
else {
int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental);
- int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
+ int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels;
CCGSubSurf *ss;
/* It is quite possible there is a much better place to do this. It
@@ -3422,13 +3423,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
}
if (useIncremental && isFinalCalc) {
- smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging|CCG_CALC_NORMALS);
+ smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging | CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
result = getCCGDerivedMesh(smd->mCache,
- drawInteriorEdges,
- useSubsurfUv, dm);
+ drawInteriorEdges,
+ useSubsurfUv, dm);
}
else {
if (smd->mCache && isFinalCalc) {
@@ -3436,7 +3437,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
smd->mCache = NULL;
}
- ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
+ ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm);
@@ -3448,7 +3449,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
}
}
- return (DerivedMesh*)result;
+ return (DerivedMesh *)result;
}
void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
@@ -3474,14 +3475,14 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
float *co;
int i;
- edge_sum[0]= edge_sum[1]= edge_sum[2]= 0.0;
- face_sum[0]= face_sum[1]= face_sum[2]= 0.0;
+ edge_sum[0] = edge_sum[1] = edge_sum[2] = 0.0;
+ face_sum[0] = face_sum[1] = face_sum[2] = 0.0;
- for (i=0; i<N; i++) {
+ for (i = 0; i < N; i++) {
CCGEdge *e = ccgSubSurf_getVertEdge(v, i);
add_v3_v3v3(edge_sum, edge_sum, ccgSubSurf_getEdgeData(ss, e, 1));
}
- for (i=0; i<numFaces; i++) {
+ for (i = 0; i < numFaces; i++) {
CCGFace *f = ccgSubSurf_getVertFace(v, i);
add_v3_v3(face_sum, ccgSubSurf_getFaceCenterData(f));
}
@@ -3489,12 +3490,12 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
/* ad-hoc correction for boundary vertices, to at least avoid them
* moving completely out of place (brecht) */
if (numFaces && numFaces != N)
- mul_v3_fl(face_sum, (float)N/(float)numFaces);
+ mul_v3_fl(face_sum, (float)N / (float)numFaces);
co = ccgSubSurf_getVertData(ss, v);
- positions_r[idx][0] = (co[0]*N*N + edge_sum[0]*4 + face_sum[0])/(N*(N+5));
- positions_r[idx][1] = (co[1]*N*N + edge_sum[1]*4 + face_sum[1])/(N*(N+5));
- positions_r[idx][2] = (co[2]*N*N + edge_sum[2]*4 + face_sum[2])/(N*(N+5));
+ positions_r[idx][0] = (co[0] * N * N + edge_sum[0] * 4 + face_sum[0]) / (N * (N + 5));
+ positions_r[idx][1] = (co[1] * N * N + edge_sum[1] * 4 + face_sum[1]) / (N * (N + 5));
+ positions_r[idx][2] = (co[2] * N * N + edge_sum[2] * 4 + face_sum[2]) / (N * (N + 5));
}
ccgVertIterator_free(vi);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index a7e49dd7fc8..cb7369476c0 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1193,9 +1193,11 @@ void txt_order_cursors(Text *text)
if (!text->sell) return;
/* Flip so text->curl is before text->sell */
- if (txt_get_span(text->curl, text->sell)<0 ||
- (text->curl==text->sell && text->curc>text->selc))
+ if ((txt_get_span(text->curl, text->sell) < 0) ||
+ (text->curl == text->sell && text->curc > text->selc))
+ {
txt_curs_swap(text);
+ }
}
int txt_has_sel(Text *text)
@@ -2018,7 +2020,7 @@ void txt_do_undo(Text *text)
undoing= 1;
- switch(op) {
+ switch (op) {
case UNDO_CLEFT:
txt_move_right(text, 0);
break;
@@ -2245,7 +2247,7 @@ void txt_do_redo(Text *text)
undoing= 1;
- switch(op) {
+ switch (op) {
case UNDO_CLEFT:
txt_move_left(text, 0);
break;
@@ -2652,7 +2654,10 @@ void txt_backspace_char (Text *text)
} while (mrk && mrk->lineno==lineno);
}
- memcpy(text->curl->line + text->curc - c_len, text->curl->line + text->curc, text->curl->len-text->curc+1);
+ /* source and destination overlap, don't use memcpy() */
+ memmove(text->curl->line + text->curc - c_len,
+ text->curl->line + text->curc,
+ text->curl->len - text->curc + 1);
text->curl->len-= c_len;
text->curc-= c_len;
@@ -2829,8 +2834,7 @@ void txt_indent(Text *text)
}
num = 0;
- while (TRUE)
- {
+ while (TRUE) {
tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string");
text->curc = 0;
@@ -2848,8 +2852,7 @@ void txt_indent(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if (text->curl == text->sell)
- {
+ if (text->curl == text->sell) {
text->selc = text->sell->len;
break;
}
@@ -2859,14 +2862,12 @@ void txt_indent(Text *text)
}
}
text->curc = 0;
- while ( num > 0 )
- {
+ while ( num > 0 ) {
text->curl = text->curl->prev;
num--;
}
- if (!undoing)
- {
+ if (!undoing) {
txt_undo_add_toop(text, UNDO_INDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
}
@@ -2890,12 +2891,10 @@ void txt_unindent(Text *text)
indent = spaceslen;
}
- while (TRUE)
- {
+ while (TRUE) {
int i = 0;
- if (BLI_strncasecmp(text->curl->line, remove, indent) == 0)
- {
+ if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) {
while (i< text->curl->len) {
text->curl->line[i]= text->curl->line[i+indent];
i++;
@@ -2906,8 +2905,7 @@ void txt_unindent(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if (text->curl == text->sell)
- {
+ if (text->curl == text->sell) {
text->selc = text->sell->len;
break;
}
@@ -2918,14 +2916,12 @@ void txt_unindent(Text *text)
}
text->curc = 0;
- while ( num > 0 )
- {
+ while ( num > 0 ) {
text->curl = text->curl->prev;
num--;
}
- if (!undoing)
- {
+ if (!undoing) {
txt_undo_add_toop(text, UNDO_UNINDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
}
@@ -2941,8 +2937,7 @@ void txt_comment(Text *text)
if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one
num = 0;
- while (TRUE)
- {
+ while (TRUE) {
tmp= MEM_mallocN(text->curl->len+2, "textline_string");
text->curc = 0;
@@ -2960,8 +2955,7 @@ void txt_comment(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if (text->curl == text->sell)
- {
+ if (text->curl == text->sell) {
text->selc = text->sell->len;
break;
}
@@ -2971,14 +2965,12 @@ void txt_comment(Text *text)
}
}
text->curc = 0;
- while ( num > 0 )
- {
+ while ( num > 0 ) {
text->curl = text->curl->prev;
num--;
}
- if (!undoing)
- {
+ if (!undoing) {
txt_undo_add_toop(text, UNDO_COMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
}
@@ -2992,12 +2984,10 @@ void txt_uncomment(Text *text)
if (!text->curl) return;
if (!text->sell) return;
- while (TRUE)
- {
+ while (TRUE) {
int i = 0;
- if (text->curl->line[i] == remove)
- {
+ if (text->curl->line[i] == remove) {
while (i< text->curl->len) {
text->curl->line[i]= text->curl->line[i+1];
i++;
@@ -3009,8 +2999,7 @@ void txt_uncomment(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if (text->curl == text->sell)
- {
+ if (text->curl == text->sell) {
text->selc = text->sell->len;
break;
}
@@ -3021,14 +3010,12 @@ void txt_uncomment(Text *text)
}
text->curc = 0;
- while ( num > 0 )
- {
+ while ( num > 0 ) {
text->curl = text->curl->prev;
num--;
}
- if (!undoing)
- {
+ if (!undoing) {
txt_undo_add_toop(text, UNDO_UNCOMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
}
@@ -3044,27 +3031,23 @@ int setcurr_tab_spaces (Text *text, int space)
if (!text) return 0;
if (!text->curl) return 0;
- while (text->curl->line[i] == indent)
- {
+ while (text->curl->line[i] == indent) {
//we only count those tabs/spaces that are before any text or before the curs;
- if (i == text->curc)
- {
+ if (i == text->curc) {
return i;
}
else {
i++;
}
}
- if (strstr(text->curl->line, word))
- {
+ if (strstr(text->curl->line, word)) {
/* if we find a ':' on this line, then add a tab but not if it is:
* 1) in a comment
* 2) within an identifier
* 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414]
*/
int a, is_indent = 0;
- for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++)
- {
+ for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) {
char ch= text->curl->line[a];
if (ch=='#') {
break;
@@ -3081,13 +3064,10 @@ int setcurr_tab_spaces (Text *text, int space)
}
}
- for (test=0; back_words[test]; test++)
- {
+ for (test=0; back_words[test]; test++) {
/* if there are these key words then remove a tab because we are done with the block */
- if (strstr(text->curl->line, back_words[test]) && i > 0)
- {
- if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm))
- {
+ if (strstr(text->curl->line, back_words[test]) && i > 0) {
+ if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) {
i -= space;
}
}
@@ -3136,14 +3116,16 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en
for (marker=text->markers.first; marker; marker=next) {
next= marker->next;
- if (group && marker->group != group) continue;
+ if (group && marker->group != group) continue;
else if ((marker->flags & flags) != flags) continue;
- else if (marker->lineno < lineno) continue;
+ else if (marker->lineno < lineno) continue;
else if (marker->lineno > lineno) break;
if ((marker->start==marker->end && start<=marker->start && marker->start<=end) ||
- (marker->start<end && marker->end>start))
+ (marker->start<end && marker->end>start))
+ {
return marker;
+ }
}
return NULL;
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 3f40c2bd429..29b9505f449 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -663,7 +663,7 @@ void default_tex(Tex *tex)
void tex_set_type(Tex *tex, int type)
{
- switch(type) {
+ switch (type) {
case TEX_VOXELDATA:
if (tex->vd == NULL)
@@ -1052,7 +1052,7 @@ void make_local_texture(Tex *tex)
}
/* ------------------------------------------------------------------------- */
-
+#if 0 /* UNUSED */
void autotexname(Tex *tex)
{
Main *bmain= G.main;
@@ -1082,6 +1082,7 @@ void autotexname(Tex *tex)
else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
}
}
+#endif
/* ------------------------------------------------------------------------- */
@@ -1179,7 +1180,7 @@ Tex *give_current_material_texture(Material *ma)
int give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
{
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_MA:
*mtex_ar= ((Material *)id)->mtex;
if (act) *act= (((Material *)id)->texact);
@@ -1210,7 +1211,7 @@ void set_active_mtex(ID *id, short act)
if (act<0) act= 0;
else if (act>=MAX_MTEX) act= MAX_MTEX-1;
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_MA:
((Material *)id)->texact= act;
break;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 7654c361d14..e511cd362de 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1523,6 +1523,7 @@ typedef struct MovieReconstructContext {
#endif
char object_name[MAX_NAME];
int is_camera;
+ short motion_flag;
float focal_length;
float principal_point[2];
@@ -1752,7 +1753,11 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o
#if WITH_LIBMV
ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
- if (count_tracks_on_both_keyframes(tracking, tracksbase)<8) {
+ if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) {
+ /* TODO: check for number of tracks? */
+ return TRUE;
+ }
+ else if (count_tracks_on_both_keyframes(tracking, tracksbase) < 8) {
BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size);
return FALSE;
@@ -1781,7 +1786,8 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
MovieTrackingTrack *track;
BLI_strncpy(context->object_name, object->name, sizeof(context->object_name));
- context->is_camera = object->flag&TRACKING_OBJECT_CAMERA;
+ context->is_camera = object->flag & TRACKING_OBJECT_CAMERA;
+ context->motion_flag = tracking->settings.motion_flag;
context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
@@ -1894,13 +1900,22 @@ void BKE_tracking_solve_reconstruction(MovieReconstructContext *context, short *
progressdata.stats_message = stats_message;
progressdata.message_size = message_size;
- context->reconstruction = libmv_solveReconstruction(context->tracks,
- context->keyframe1, context->keyframe2,
- context->refine_flags,
- context->focal_length,
- context->principal_point[0], context->principal_point[1],
- context->k1, context->k2, context->k3,
- solve_reconstruction_update_cb, &progressdata);
+ if (context->motion_flag & TRACKING_MOTION_MODAL) {
+ context->reconstruction = libmv_solveModal(context->tracks,
+ context->focal_length,
+ context->principal_point[0], context->principal_point[1],
+ context->k1, context->k2, context->k3,
+ solve_reconstruction_update_cb, &progressdata);
+ }
+ else {
+ context->reconstruction = libmv_solveReconstruction(context->tracks,
+ context->keyframe1, context->keyframe2,
+ context->refine_flags,
+ context->focal_length,
+ context->principal_point[0], context->principal_point[1],
+ context->k1, context->k2, context->k3,
+ solve_reconstruction_update_cb, &progressdata);
+ }
error = libmv_reprojectionError(context->reconstruction);
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 740deb5c7db..079bde0afec 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -120,19 +120,17 @@ static int write_audio_frame(void)
audio_time += (double) audio_input_samples / (double) c->sample_rate;
pkt.size = avcodec_encode_audio(c, audio_output_buffer,
- audio_outbuf_size,
- (short*) audio_input_buffer);
+ audio_outbuf_size,
+ (short *)audio_input_buffer);
- if (pkt.size < 0)
- {
+ if (pkt.size < 0) {
// XXX error("Error writing audio packet");
return -1;
}
pkt.data = audio_output_buffer;
- if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
- {
+ if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) {
pkt.pts = av_rescale_q(c->coded_frame->pts,
c->time_base, audio_stream->time_base);
fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
@@ -172,10 +170,10 @@ static AVFrame* alloc_picture(int pix_fmt, int width, int height)
}
/* Get the correct file extensions for the requested format,
- first is always desired guess_format parameter */
+ * first is always desired guess_format parameter */
static const char** get_file_extensions(int format)
{
- switch(format) {
+ switch (format) {
case FFMPEG_DV: {
static const char * rv[] = { ".dv", NULL };
return rv;
@@ -308,7 +306,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
rendered_frame = pixels;
/* Do RGBA-conversion and flipping in one step depending
- on CPU-Endianess */
+ * on CPU-Endianess */
if (ENDIAN_ORDER == L_ENDIAN) {
int y;
@@ -372,7 +370,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
*param++ = 0;
}
- switch(prop->type) {
+ switch (prop->type) {
case IDP_STRING:
fprintf(stderr, "%s.\n", IDP_String(prop));
av_set_string3(c, prop->name, IDP_String(prop), 1, &rv);
@@ -628,7 +626,7 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
}
/* need to prevent floating point exception when using vorbis audio codec,
- initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */
+ * initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */
st->codec->time_base.num= 1;
st->codec->time_base.den= st->codec->sample_rate;
@@ -717,7 +715,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
BLI_snprintf(of->filename, sizeof(of->filename), "%s", name);
/* set the codec to the user's selection */
- switch(ffmpeg_type) {
+ switch (ffmpeg_type) {
case FFMPEG_AVI:
case FFMPEG_MOV:
case FFMPEG_MKV:
@@ -876,8 +874,8 @@ void flush_ffmpeg(void)
}
/* **********************************************************************
- * public interface
- ********************************************************************** */
+ * * public interface
+ * ********************************************************************** */
/* Get the output filename-- similar to the other output formats */
void filepath_ffmpeg(char* string, RenderData* rd)
@@ -929,8 +927,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
success = start_ffmpeg_impl(rd, rectx, recty, reports);
#ifdef WITH_AUDASPACE
- if (audio_stream)
- {
+ if (audio_stream) {
AVCodecContext* c = audio_stream->codec;
AUD_DeviceSpecs specs;
specs.channels = c->channels;
@@ -974,8 +971,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r
// why is this done before writing the video frame and again at end_ffmpeg?
// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
- if (video_stream)
- {
+ if (video_stream) {
avframe= generate_video_frame((unsigned char*) pixels, reports);
success= (avframe && write_video_frame(rd, frame - start_frame, avframe, reports));
@@ -1172,10 +1168,12 @@ static const AVOption *my_av_find_opt(void *v, const char *name,
const AVOption *o= c->option;
for (;o && o->name; o++) {
- if (!strcmp(o->name, name) &&
- (!unit || (o->unit && !strcmp(o->unit, unit))) &&
- (o->flags & mask) == flags )
+ if (!strcmp(o->name, name) &&
+ (!unit || (o->unit && !strcmp(o->unit, unit))) &&
+ (o->flags & mask) == flags)
+ {
return o;
+ }
}
return NULL;
}
diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c
index 4bb9c497980..62e921f3311 100644
--- a/source/blender/blenkernel/intern/writeframeserver.c
+++ b/source/blender/blenkernel/intern/writeframeserver.c
@@ -206,8 +206,7 @@ static int handle_request(RenderData *rd, char * req)
*p = 0;
- if (strcmp(path, "/index.html") == 0
- || strcmp(path, "/") == 0) {
+ if (strcmp(path, "/index.html") == 0 || strcmp(path, "/") == 0) {
safe_puts(index_page);
return -1;
}