code cleanup: use const float's where possible and specify vector size.

This commit is contained in:
Campbell Barton 2012-06-12 23:19:52 +00:00
parent b0038ae499
commit 1a625d1416
10 changed files with 58 additions and 56 deletions

@ -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);

@ -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)

@ -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) {

@ -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);

@ -57,7 +57,7 @@ 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 {

@ -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;

@ -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;

@ -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);

@ -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;

@ -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;