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
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')
-rw-r--r--source/blender/src/editparticle.c36
-rw-r--r--source/blender/src/view.c42
2 files changed, 47 insertions, 31 deletions
diff --git a/source/blender/src/editparticle.c b/source/blender/src/editparticle.c
index 95a4abe1f9d..f420d46c827 100644
--- a/source/blender/src/editparticle.c
+++ b/source/blender/src/editparticle.c
@@ -2273,9 +2273,9 @@ static void brush_add(Object *ob, ParticleSystem *psys, short *mval, short numbe
ParticleEditSettings *pset= PE_settings();
ParticleEdit *edit = psys->edit;
int i, k, n = 0, totpart = psys->totpart;
+ short mco[2];
short dmx = 0, dmy = 0;
- short mx = mval[0] - curarea->winx / 2, my = mval[1] - curarea->winy / 2;
- float co1[3], co2[3], vec[4], min_d, imat[4][4];
+ float co1[3], co2[3], min_d, imat[4][4];
float framestep, timestep = psys_get_timestep(psys->part);
short size = pset->brush[PE_BRUSH_ADD].size;
short size2 = size*size;
@@ -2302,35 +2302,9 @@ static void brush_add(Object *ob, ParticleSystem *psys, short *mval, short numbe
}
}
- /* create intersection coordinates in view Z direction at mouse coordinates */
- /* Thanks to who ever wrote the "Mouse Location 3D Space" tutorial in "Blender 3D: Blending Into Python/Cookbook". */
- if(G.vd->persp != V3D_ORTHO){
- vec[0]= (2.0f*(mx+dmx)/curarea->winx);
- vec[1]= (2.0f*(my+dmy)/curarea->winy);
- vec[2]= -1.0f;
- vec[3]= 1.0f;
-
- Mat4MulVec4fl(G.vd->persinv, vec);
- VecMulf(vec, 1.0f/vec[3]);
-
- VECCOPY(co1, G.vd->viewinv[3]);
- VECSUB(vec, vec, co1);
- Normalize(vec);
-
- VECADDFAC(co1, G.vd->viewinv[3], vec, G.vd->near);
- VECADDFAC(co2, G.vd->viewinv[3], vec, G.vd->far);
- }
- else {
- vec[0] = 2.0f*(mx+dmx)/curarea->winx;
- vec[1] = 2.0f*(my+dmy)/curarea->winy;
- vec[2] = 0.0f;
- vec[3] = 1.0f;
-
- Mat4MulVec4fl(G.vd->persinv,vec);
-
- VECADDFAC(co1,vec,G.vd->viewinv[2],1000.0f);
- VECADDFAC(co2,vec,G.vd->viewinv[2],-1000.0f);
- }
+ mco[0] = mval[0] + dmx;
+ mco[1] = mval[1] + dmy;
+ viewline(mco, co1, co2);
Mat4MulVecfl(imat,co1);
Mat4MulVecfl(imat,co2);
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)
{