Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / blender / src / editparticle.c
index 95a4abe1f9d282a0a31b3a1a96b90cacb224347c..f420d46c82734d064ec5f4ee116f3d6931d48e9c 100644 (file)
@@ -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);