diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-11 06:50:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-11 06:50:01 +0400 |
commit | 599cd56f535946726bc30e66e7ac483ec91ab6fd (patch) | |
tree | c0c09962558535a0a3435f1eed2669deb3b91094 /source/blender/editors | |
parent | 3a5f2272adc4ec821db16de95781b9ce653dda73 (diff) |
minor edits / cleanup - no functional changes.
- use 'const float *' and array size in some function declarations.
- replace macros for BLI_math functions INPF, VECCOPY, VECADD etc.
- remove unused VertRen.clip struct member.
- remove static squared_dist() from 2 files, replace with BLI_math function len_squared_v3v3().
- use vertex arrays for drawing clipping background in the 3D viewport.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 14 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_lib.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawvolume.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 36 |
8 files changed, 66 insertions, 64 deletions
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index b99605e65c1..48ca6d6fd72 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -518,7 +518,7 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) dist= normalize_v3(d); /* if the vertex normal does not point along the bone, increase distance */ - cosine= INPR(d, sys->heat.vnors[vertex]); + cosine= dot_v3v3(d, sys->heat.vnors[vertex]); return dist/(0.5f*(cosine + 1.001f)); } @@ -1120,7 +1120,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], cross_v3_v3v3(pvec, dir, edge2); /* if determinant is near zero, ray lies in plane of triangle */ - det = INPR(edge1, pvec); + det = dot_v3v3(edge1, pvec); if (det == 0.0f) return 0; @@ -1130,7 +1130,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], sub_v3_v3v3(tvec, orig, vert0); /* calculate U parameter and test bounds */ - u = INPR(tvec, pvec) * inv_det; + u = dot_v3v3(tvec, pvec) * inv_det; if (u < -EPSILON || u > 1.0f+EPSILON) return 0; @@ -1138,7 +1138,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], cross_v3_v3v3(qvec, tvec, edge1); /* calculate V parameter and test bounds */ - v = INPR(dir, qvec) * inv_det; + v = dot_v3v3(dir, qvec) * inv_det; if (v < -EPSILON || u + v > 1.0f+EPSILON) return 0; @@ -1153,10 +1153,10 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* check if it is within the length of the line segment */ sub_v3_v3v3(isectdir, isectco, orig); - if(INPR(dir, isectdir) < -EPSILON) + if(dot_v3v3(dir, isectdir) < -EPSILON) return 0; - if(INPR(dir, dir) + EPSILON < INPR(isectdir, isectdir)) + if(dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir)) return 0; return 1; @@ -1202,7 +1202,7 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) if(len < isec->labda) { isec->labda= len; isec->face = mface; - isec->isect= (INPR(isec->vec, nor) <= 0.0f); + isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f); is= 1; } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 45bd3b49fd1..8194528490a 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -210,7 +210,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) copy_v3_v3(vec, min); normalize_v3(vec); - dot= INPR(vec, nor); + dot= dot_v3v3(vec, nor); if( fabs(dot)<0.999) { float cross[3], si, q1[4]; diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index 0afa2d01702..a7bfa6fc16c 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -1002,7 +1002,7 @@ void EM_free_data_layer(EditMesh *em, CustomData *data, int type) static void add_normal_aligned(float *nor, float *add) { - if( INPR(nor, add) < -0.9999f) + if(dot_v3v3(nor, add) < -0.9999f) sub_v3_v3(nor, add); else add_v3_v3(nor, add); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 623855485d7..897de290752 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -305,7 +305,7 @@ static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA if(_sample_col) { cumap->flag |= CUMA_DRAW_SAMPLE; - VECCOPY(cumap->sample, _sample_col); + copy_v3_v3(cumap->sample, _sample_col); } else cumap->flag &= ~CUMA_DRAW_SAMPLE; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 4aec1a8e61c..fc35ab93f70 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -827,7 +827,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], int armflag, if (0.0f != normalize_v3(dirvec)) { float norvech[3], norvect[3], vec[3]; - VECCOPY(vec, dirvec); + copy_v3_v3(vec, dirvec); mul_v3_fl(dirvec, head); cross_v3_v3v3(norvech, dirvec, imat[2]); @@ -1544,7 +1544,7 @@ static void draw_pose_dofs(Object *ob) /* in parent-bone pose, but own restspace */ glPushMatrix(); - VECCOPY(posetrans, pchan->pose_mat[3]); + copy_v3_v3(posetrans, pchan->pose_mat[3]); glTranslatef(posetrans[0], posetrans[1], posetrans[2]); if (pchan->parent) { @@ -1642,7 +1642,7 @@ static void bone_matrix_translate_y(float mat[][4], float y) { float trans[3]; - VECCOPY(trans, mat[1]); + copy_v3_v3(trans, mat[1]); mul_v3_fl(trans, y); add_v3_v3(mat[3], trans); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index d573198aa10..2b1d6d091cf 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -139,7 +139,7 @@ static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) /* ************* only use while object drawing ************** * or after running ED_view3d_init_mats_rv3d * */ -static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int local) +static void view3d_project_short_clip(ARegion *ar, const float vec[3], short *adr, int local) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -174,7 +174,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l } /* only use while object drawing */ -static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr) +static void view3d_project_short_noclip(ARegion *ar, const float vec[3], short *adr) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -837,7 +837,7 @@ static void drawcube_size(float size) /* this is an unused (old) cube-drawing function based on a given size */ #if 0 -static void drawcube_size(float *size) +static void drawcube_size(const float size[3]) { glPushMatrix(); @@ -891,7 +891,7 @@ static void drawshadbuflimits(Lamp *la, float mat[][4]) -static void spotvolume(float *lvec, float *vvec, float inp) +static void spotvolume(float lvec[3], float vvec[3], const float inp) { /* camera is at 0,0,0 */ float temp[3],plane[3],mat1[3][3],mat2[3][3],mat3[3][3],mat4[3][3],q[4],co,si,angle; @@ -920,8 +920,8 @@ static void spotvolume(float *lvec, float *vvec, float inp) normalize_v3(&q[1]); angle = saacos(plane[2])/2.0f; - co = cos(angle); - si = sqrt(1-co*co); + co = cosf(angle); + si = sqrtf(1-co*co); q[0] = co; q[1] *= si; @@ -935,7 +935,7 @@ static void spotvolume(float *lvec, float *vvec, float inp) unit_m3(mat2); co = inp; - si = sqrt(1-inp*inp); + si = sqrtf(1.0f-inp*inp); mat2[0][0] = co; mat2[1][0] = -si; @@ -5035,7 +5035,7 @@ static void draw_textcurs(float textcurs[][2]) set_inverted_drawing(0); } -static void drawspiral(float *cent, float rad, float tmat[][4], int start) +static void drawspiral(const float cent[3], float rad, float tmat[][4], int start) { float vec[3], vx[3], vy[3]; int a, tot=32; @@ -5106,7 +5106,7 @@ static void drawcircle_size(float size) } /* needs fixing if non-identity matrice used */ -static void drawtube(float *vec, float radius, float height, float tmat[][4]) +static void drawtube(const float vec[3], float radius, float height, float tmat[][4]) { float cur[3]; drawcircball(GL_LINE_LOOP, vec, radius, tmat); @@ -5128,7 +5128,7 @@ static void drawtube(float *vec, float radius, float height, float tmat[][4]) glEnd(); } /* needs fixing if non-identity matrice used */ -static void drawcone(float *vec, float radius, float height, float tmat[][4]) +static void drawcone(const float vec[3], float radius, float height, float tmat[][4]) { float cur[3]; @@ -5404,7 +5404,7 @@ static void draw_box(float vec[8][3]) /* uses boundbox, function used by Ketsji */ #if 0 -static void get_local_bounds(Object *ob, float *center, float *size) +static void get_local_bounds(Object *ob, float center[3], float size[3]) { BoundBox *bb= object_get_boundbox(ob); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index acdbcb0d06d..8da6f49e089 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -154,10 +154,10 @@ static int convex(float *p0, float *up, float *a, float *b) { // Vec3 va = a-p0, vb = b-p0; float va[3], vb[3], tmp[3]; - VECSUB(va, a, p0); - VECSUB(vb, b, p0); + sub_v3_v3v3(va, a, p0); + sub_v3_v3v3(vb, b, p0); cross_v3_v3v3(tmp, va, vb); - return INPR(up, tmp) >= 0; + return dot_v3v3(up, tmp) >= 0; } // copied from gpu_extension.c @@ -280,20 +280,20 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 cv[7][1] = min[1]; cv[7][2] = min[2]; - VECCOPY(edges[0][0], cv[4]); // maxx, maxy, minz - VECCOPY(edges[1][0], cv[5]); // minx, maxy, minz - VECCOPY(edges[2][0], cv[6]); // minx, miny, minz - VECCOPY(edges[3][0], cv[7]); // maxx, miny, minz + copy_v3_v3(edges[0][0], cv[4]); // maxx, maxy, minz + copy_v3_v3(edges[1][0], cv[5]); // minx, maxy, minz + copy_v3_v3(edges[2][0], cv[6]); // minx, miny, minz + copy_v3_v3(edges[3][0], cv[7]); // maxx, miny, minz - VECCOPY(edges[4][0], cv[3]); // maxx, miny, maxz - VECCOPY(edges[5][0], cv[2]); // minx, miny, maxz - VECCOPY(edges[6][0], cv[6]); // minx, miny, minz - VECCOPY(edges[7][0], cv[7]); // maxx, miny, minz + copy_v3_v3(edges[4][0], cv[3]); // maxx, miny, maxz + copy_v3_v3(edges[5][0], cv[2]); // minx, miny, maxz + copy_v3_v3(edges[6][0], cv[6]); // minx, miny, minz + copy_v3_v3(edges[7][0], cv[7]); // maxx, miny, minz - VECCOPY(edges[8][0], cv[1]); // minx, maxy, maxz - VECCOPY(edges[9][0], cv[2]); // minx, miny, maxz - VECCOPY(edges[10][0], cv[6]); // minx, miny, minz - VECCOPY(edges[11][0], cv[5]); // minx, maxy, minz + copy_v3_v3(edges[8][0], cv[1]); // minx, maxy, maxz + copy_v3_v3(edges[9][0], cv[2]); // minx, miny, maxz + copy_v3_v3(edges[10][0], cv[6]); // minx, miny, minz + copy_v3_v3(edges[11][0], cv[5]); // minx, maxy, minz // printf("size x: %f, y: %f, z: %f\n", size[0], size[1], size[2]); // printf("min[2]: %f, max[2]: %f\n", min[2], max[2]); @@ -332,7 +332,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 */ // get view vector - VECCOPY(viewnormal, rv3d->viewinv[2]); + copy_v3_v3(viewnormal, rv3d->viewinv[2]); normalize_v3(viewnormal); // find cube vertex that is closest to the viewer @@ -407,10 +407,10 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 if(dd*(float)n > ds) break; - VECCOPY(tmp_point, viewnormal); + copy_v3_v3(tmp_point, viewnormal); mul_v3_fl(tmp_point, -dd*((ds/dd)-(float)n)); - VECADD(tmp_point2, cv[good_index], tmp_point); - d = INPR(tmp_point2, viewnormal); + add_v3_v3v3(tmp_point2, cv[good_index], tmp_point); + d = dot_v3v3(tmp_point2, viewnormal); // printf("my d: %f\n", d); @@ -421,7 +421,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 // printf("points: %d\n", numpoints); if (numpoints > 2) { - VECCOPY(p0, points); + copy_v3_v3(p0, points); // sort points to get a convex polygon for(i = 1; i < numpoints - 1; i++) @@ -431,9 +431,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3 if(!convex(p0, viewnormal, &points[j * 3], &points[i * 3])) { float tmp2[3]; - VECCOPY(tmp2, &points[j * 3]); - VECCOPY(&points[j * 3], &points[i * 3]); - VECCOPY(&points[i * 3], tmp2); + copy_v3_v3(tmp2, &points[j * 3]); + copy_v3_v3(&points[j * 3], &points[i * 3]); + copy_v3_v3(&points[i * 3], tmp2); } } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 98768e369cb..7c3aeaba55c 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -150,20 +150,22 @@ void circ(float x, float y, float rad) static void view3d_draw_clipping(RegionView3D *rv3d) { BoundBox *bb= rv3d->clipbb; - + if(bb) { + static unsigned int clipping_index[6][4]= {{0, 1, 2, 3}, + {0, 4, 5, 1}, + {4, 7, 6, 5}, + {7, 3, 2, 6}, + {1, 5, 6, 2}, + {7, 4, 0, 3}}; + UI_ThemeColorShade(TH_BACK, -8); - - glBegin(GL_QUADS); - - glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[3]); - glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[1]); - glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[5]); - glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[3]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[6]); - glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[2]); - glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[3]); - - glEnd(); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, bb->vec); + glDrawElements(GL_QUADS, sizeof(clipping_index)/sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index); + glDisableClientState(GL_VERTEX_ARRAY); + } } @@ -194,11 +196,11 @@ static int test_clipping(const float vec[3], float clip[][4]) { float view[3]; copy_v3_v3(view, vec); - - if(0.0f < clip[0][3] + INPR(view, clip[0])) - if(0.0f < clip[1][3] + INPR(view, clip[1])) - if(0.0f < clip[2][3] + INPR(view, clip[2])) - if(0.0f < clip[3][3] + INPR(view, clip[3])) + + if(0.0f < clip[0][3] + dot_v3v3(view, clip[0])) + if(0.0f < clip[1][3] + dot_v3v3(view, clip[1])) + if(0.0f < clip[2][3] + dot_v3v3(view, clip[2])) + if(0.0f < clip[3][3] + dot_v3v3(view, clip[3])) return 0; return 1; |