diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-13 03:19:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-13 03:19:52 +0400 |
commit | 1a625d1416e5caaaa21a2dcc1fb00e66a1911758 (patch) | |
tree | 5ccb34b18d0444d5011a6140e478a577359b6733 /source | |
parent | b0038ae4996993f1dd808babe402e2e390933330 (diff) |
code cleanup: use const float's where possible and specify vector size.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_shrinkwrap.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_bvh.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_bvh.h | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 2 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_simpledeform.c | 76 | ||||
-rw-r--r-- | source/blender/render/intern/source/occlusion.c | 13 |
10 files changed, 58 insertions, 56 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index ef664f8fc4f..e8f863fbbfd 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -339,7 +339,7 @@ struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode *node void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock); void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node); -void nodeAddToPreview(struct bNode *, float *, int, int, int); +void nodeAddToPreview(struct bNode *node, float col[4], int x, int y, int do_manage); struct bNode *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp); void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node); diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 5b09f8fdf3d..a7b03cef933 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -72,8 +72,8 @@ typedef struct SpaceTransform { } SpaceTransform; void space_transform_from_matrixs(struct SpaceTransform *data, float local[4][4], float target[4][4]); -void space_transform_apply(const struct SpaceTransform *data, float *co); -void space_transform_invert(const struct SpaceTransform *data, float *co); +void space_transform_apply(const struct SpaceTransform *data, float co[3]); +void space_transform_invert(const struct SpaceTransform *data, float co[3]); #define space_transform_setup(data, local, target) space_transform_from_matrixs(data, (local)->obmat, (target)->obmat) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 924e6a354ef..c48c0231aa0 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -802,7 +802,7 @@ void ntreeClearPreview(bNodeTree *ntree) /* hack warning! this function is only used for shader previews, and * since it gets called multiple times per pixel for Ztransp we only * add the color once. Preview gets cleared before it starts render though */ -void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage) +void nodeAddToPreview(bNode *node, float col[4], int x, int y, int do_manage) { bNodePreview *preview= node->preview; if (preview) { diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index c5f8494836b..2cb03104874 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -308,7 +308,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co } } -BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, float *co, float maxdist) +BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist) { BVHTreeNearest hit; @@ -370,7 +370,7 @@ int BMBVH_VertVisible(BMBVHTree *tree, BMEdge *e, RegionView3D *r3d) } #endif -static BMFace *edge_ray_cast(BMBVHTree *tree, float *co, float *dir, float *hitout, BMEdge *e) +static BMFace *edge_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float *hitout, BMEdge *e) { BMFace *f = BMBVH_RayCast(tree, co, dir, hitout, NULL); diff --git a/source/blender/editors/mesh/editmesh_bvh.h b/source/blender/editors/mesh/editmesh_bvh.h index 6512f054c1b..53d1c36119e 100644 --- a/source/blender/editors/mesh/editmesh_bvh.h +++ b/source/blender/editors/mesh/editmesh_bvh.h @@ -57,8 +57,8 @@ int BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e, struct ARegion *ar, struct View3D *v3d, struct Object *obedit); /*find a vert closest to co in a sphere of radius maxdist*/ -struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, float *co, float maxdist); - +struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, const float co[3], const float maxdist); + /* BMBVH_NewBVH flag parameter */ enum { BMBVH_USE_CAGE = 1, /* project geometry onto modifier cage */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 989f1a36f99..59a0475ebb5 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -690,7 +690,8 @@ static void mesh_octree_free_node(MocNode **bt) /* temporal define, just to make nicer code below */ #define MOC_INDEX(vx, vy, vz) (((vx) * MOC_RES * MOC_RES) + (vy) * MOC_RES + (vz)) -static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, intptr_t index) +static void mesh_octree_add_nodes(MocNode **basetable, const float co[3], const float offs[3], + const float div[3], intptr_t index) { float fx, fy, fz; int vx, vy, vz; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index e02ad00ac7f..b3ccf004810 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -108,7 +108,7 @@ #define MAN_MOVECOL 2 /* transform widget center calc helper for below */ -static void calc_tw_center(Scene *scene, float *co) +static void calc_tw_center(Scene *scene, const float co[3]) { float *twcent = scene->twcent; float *min = scene->twmin; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 16cd95a2f70..87ff36ebf27 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -706,7 +706,7 @@ static void p_face_restore_uvs(PFace *f) /* Construction (use only during construction, relies on u.key being set */ -static PVert *p_vert_add(PHandle *handle, PHashKey key, float *co, PEdge *e) +static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge *e) { PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof *v); copy_v3_v3(v->co, co); @@ -719,7 +719,7 @@ static PVert *p_vert_add(PHandle *handle, PHashKey key, float *co, PEdge *e) return v; } -static PVert *p_vert_lookup(PHandle *handle, PHashKey key, float *co, PEdge *e) +static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PEdge *e) { PVert *v = (PVert *)phash_lookup(handle->hash_verts, key); diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 36c052440b6..14735810cad 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -51,8 +51,6 @@ #include "MOD_util.h" - - /* Clamps/Limits the given coordinate to: limits[0] <= co[axis] <= limits[1] * The amount of clamp is saved on dcut */ static void axis_limit(int axis, const float limits[2], float co[3], float dcut[3]) @@ -65,79 +63,79 @@ static void axis_limit(int axis, const float limits[2], float co[3], float dcut[ co[axis] = val; } -static void simpleDeform_taper(const float factor, const float dcut[3], float *co) +static void simpleDeform_taper(const float factor, const float dcut[3], float r_co[3]) { - float x = co[0], y = co[1], z = co[2]; + float x = r_co[0], y = r_co[1], z = r_co[2]; float scale = z * factor; - co[0] = x + x * scale; - co[1] = y + y * scale; - co[2] = z; + r_co[0] = x + x * scale; + r_co[1] = y + y * scale; + r_co[2] = z; if (dcut) { - co[0] += dcut[0]; - co[1] += dcut[1]; - co[2] += dcut[2]; + r_co[0] += dcut[0]; + r_co[1] += dcut[1]; + r_co[2] += dcut[2]; } } -static void simpleDeform_stretch(const float factor, const float dcut[3], float *co) +static void simpleDeform_stretch(const float factor, const float dcut[3], float r_co[3]) { - float x = co[0], y = co[1], z = co[2]; + float x = r_co[0], y = r_co[1], z = r_co[2]; float scale; scale = (z * z * factor - factor + 1.0f); - co[0] = x * scale; - co[1] = y * scale; - co[2] = z * (1.0f + factor); + r_co[0] = x * scale; + r_co[1] = y * scale; + r_co[2] = z * (1.0f + factor); if (dcut) { - co[0] += dcut[0]; - co[1] += dcut[1]; - co[2] += dcut[2]; + r_co[0] += dcut[0]; + r_co[1] += dcut[1]; + r_co[2] += dcut[2]; } } -static void simpleDeform_twist(const float factor, const float *dcut, float *co) +static void simpleDeform_twist(const float factor, const float *dcut, float r_co[3]) { - float x = co[0], y = co[1], z = co[2]; + float x = r_co[0], y = r_co[1], z = r_co[2]; float theta, sint, cost; theta = z * factor; - sint = sin(theta); - cost = cos(theta); + sint = sinf(theta); + cost = cosf(theta); - co[0] = x * cost - y * sint; - co[1] = x * sint + y * cost; - co[2] = z; + r_co[0] = x * cost - y * sint; + r_co[1] = x * sint + y * cost; + r_co[2] = z; if (dcut) { - co[0] += dcut[0]; - co[1] += dcut[1]; - co[2] += dcut[2]; + r_co[0] += dcut[0]; + r_co[1] += dcut[1]; + r_co[2] += dcut[2]; } } -static void simpleDeform_bend(const float factor, const float dcut[3], float *co) +static void simpleDeform_bend(const float factor, const float dcut[3], float r_co[3]) { - float x = co[0], y = co[1], z = co[2]; + float x = r_co[0], y = r_co[1], z = r_co[2]; float theta, sint, cost; theta = x * factor; - sint = sin(theta); - cost = cos(theta); + sint = sinf(theta); + cost = cosf(theta); if (fabsf(factor) > 1e-7f) { - co[0] = -(y - 1.0f / factor) * sint; - co[1] = (y - 1.0f / factor) * cost + 1.0f / factor; - co[2] = z; + r_co[0] = -(y - 1.0f / factor) * sint; + r_co[1] = (y - 1.0f / factor) * cost + 1.0f / factor; + r_co[2] = z; } if (dcut) { - co[0] += cost * dcut[0]; - co[1] += sint * dcut[0]; - co[2] += dcut[2]; + r_co[0] += cost * dcut[0]; + r_co[1] += sint * dcut[0]; + r_co[2] += dcut[2]; } } @@ -153,7 +151,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object int limit_axis = 0; float smd_limit[2], smd_factor; SpaceTransform *transf = NULL, tmp_transf; - void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; /* Mode callback */ + void (*simpleDeform_callback)(const float factor, const float dcut[3], float co[3]) = NULL; /* Mode callback */ int vgroup; MDeformVert *dvert; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 21e4e216063..b3eb8c0fd5c 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1197,7 +1197,8 @@ static float occ_form_factor(OccFace *face, float *p, float *n) return contrib; } -static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float *pp, float *pn, float *occ, float rad[3], float bentn[3]) +static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, + const float pp[3], const float pn[3], float *occ, float rad[3], float bentn[3]) { OccNode *node, **stack; OccFace *face; @@ -1391,7 +1392,9 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) MEM_freeN(occ); } -static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, float *co, float *n, int thread, int onlyshadow, float *ao, float *env, float *indirect) +static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, + const float co[3], const float n[3], int thread, int onlyshadow, + float *ao, float *env, float *indirect) { float nn[3], bn[3], fac, occ, occlusion, correction, rad[3]; int envcolor; @@ -1415,9 +1418,9 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f /* sky shading using bent normal */ if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); - env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr; - env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng; - env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb; + env[0] = (1.0f - fac) * re->wrld.horr + fac * re->wrld.zenr; + env[1] = (1.0f - fac) * re->wrld.horg + fac * re->wrld.zeng; + env[2] = (1.0f - fac) * re->wrld.horb + fac * re->wrld.zenb; mul_v3_fl(env, occlusion); } |