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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-22 14:10:24 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-22 14:10:24 +0300
commit8ec59c7c687b9e50c48a9d455b31ff4c01df69d2 (patch)
tree32bf65aad65475c5dd9aeefa9067eba21e7324fb /source/blender/blenlib/intern/math_geom.c
parent2d2339a70992b819a23e8c71f68027022b395f46 (diff)
Math Lib:
* inline some more functions, from math_base and math_vector * also made some changes to the way inline is done so it can work for more than one file * reflect_v3_v3v3 requires input vectors to be normalized now. * added rgb_to_grayscale * added zero_v4, copy_v4_v4, swap_v4_v4, is_one_v3 * added box_clip_bounds_m4 to clip a bounding box against a projection matrix
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index a80f999cdbb..8fb7a0e1a55 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1730,6 +1730,43 @@ void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py,
translate_m4(mat,-vx,-vy,-vz); /* translate viewpoint to origin */
}
+int box_clip_bounds_m4(float boundbox[2][3], float bounds[4], float winmat[4][4])
+{
+ float mat[4][4], vec[4];
+ int a, fl, flag= -1;
+
+ copy_m4_m4(mat, winmat);
+
+ for(a=0; a<8; a++) {
+ vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0];
+ vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1];
+ vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2];
+ vec[3]= 1.0;
+ mul_m4_v4(mat, vec);
+
+ fl= 0;
+ if(bounds) {
+ if(vec[0] > bounds[1]*vec[3]) fl |= 1;
+ if(vec[0]< bounds[0]*vec[3]) fl |= 2;
+ if(vec[1] > bounds[3]*vec[3]) fl |= 4;
+ if(vec[1]< bounds[2]*vec[3]) fl |= 8;
+ }
+ else {
+ if(vec[0] < -vec[3]) fl |= 1;
+ if(vec[0] > vec[3]) fl |= 2;
+ if(vec[1] < -vec[3]) fl |= 4;
+ if(vec[1] > vec[3]) fl |= 8;
+ }
+ if(vec[2] < -vec[3]) fl |= 16;
+ if(vec[2] > vec[3]) fl |= 32;
+
+ flag &= fl;
+ if(flag==0) return 0;
+ }
+
+ return flag;
+}
+
/********************************** Mapping **********************************/
void map_to_tube(float *u, float *v,float x, float y, float z)