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:
authorMartin Poirier <theeth@yahoo.com>2008-06-09 21:16:20 +0400
committerMartin Poirier <theeth@yahoo.com>2008-06-09 21:16:20 +0400
commitac0a91920af0c9de9f6dfbbf493ecb9e2509c15e (patch)
tree076b67eff10128d117a5580fe0cc7ae99758bb33 /source/blender/src/view.c
parent83af2c1757d7ce76842dd13d92395d4bf5f0c410 (diff)
Revision 14894 merged from apricot
---------------------------------- Arith: - axis angle to quat conversion function - short to float / float to short normals conversion function (eventually, we could go over the go and replace copy/pasted code everywhere) - ray triangle intersection (to complement the line triangle intersection function) View: - viewray / viewline (get near plane point under mouse and ray normal/far point) Particles: - extract viewline from brush_add function
Diffstat (limited to 'source/blender/src/view.c')
-rw-r--r--source/blender/src/view.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index f53bcb3a9f7..835aeb9bb30 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -144,6 +144,48 @@ void persp(int a)
}
}
+/* create intersection ray in view Z direction at mouse coordinates */
+void viewray(short mval[2], float ray_start[3], float ray_normal[3])
+{
+ float ray_end[3];
+ viewline(mval, ray_start, ray_end);
+ VecSubf(ray_normal, ray_end, ray_start);
+ Normalize(ray_normal);
+}
+
+/* create intersection coordinates in view Z direction at mouse coordinates */
+void viewline(short mval[2], float ray_start[3], float ray_end[3])
+{
+ float vec[3];
+
+ if(G.vd->persp != V3D_ORTHO){
+ vec[0]= 2.0f * mval[0] / curarea->winx - 1;
+ vec[1]= 2.0f * mval[1] / curarea->winy - 1;
+ vec[2]= -1.0f;
+ vec[3]= 1.0f;
+
+ Mat4MulVec4fl(G.vd->persinv, vec);
+ VecMulf(vec, 1.0f / vec[3]);
+
+ VECCOPY(ray_start, G.vd->viewinv[3]);
+ VECSUB(vec, vec, ray_start);
+ Normalize(vec);
+
+ VECADDFAC(ray_start, G.vd->viewinv[3], vec, G.vd->near);
+ VECADDFAC(ray_end, G.vd->viewinv[3], vec, G.vd->far);
+ }
+ else {
+ vec[0] = 2.0f * mval[0] / curarea->winx - 1;
+ vec[1] = 2.0f * mval[1] / curarea->winy - 1;
+ vec[2] = 0.0f;
+ vec[3] = 1.0f;
+
+ Mat4MulVec4fl(G.vd->persinv, vec);
+
+ VECADDFAC(ray_start, vec, G.vd->viewinv[2], 1000.0f);
+ VECADDFAC(ray_end, vec, G.vd->viewinv[2], -1000.0f);
+ }
+}
void initgrabz(float x, float y, float z)
{