function rename to give clearer meaning that they change from window to 3d coordinates.
some functions had vague names, I even ended up re-writing some of these functions by accident! also added doxy comments. * ED_view3d_win_to_3d (was window_to_3d) * ED_view3d_win_to_delta (was window_to_3d_delta) * ED_view3d_win_to_vector (was window_to_3d_vector / viewvector) * ED_view3d_win_to_segment_clip (was viewline) * ED_view3d_win_to_ray (was viewray)
This commit is contained in:
@@ -2501,7 +2501,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
|
||||
|
||||
copy_v3_v3(oldcurs, fp);
|
||||
|
||||
window_to_3d(ar, tvec, fp, event->mval[0], event->mval[1]);
|
||||
ED_view3d_win_to_3d(ar, fp, event->mval[0], event->mval[1], tvec);
|
||||
copy_v3_v3(fp, tvec);
|
||||
|
||||
/* extrude to the where new cursor is and store the operation result */
|
||||
|
||||
@@ -1005,7 +1005,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
|
||||
float pval[2];
|
||||
|
||||
project_float(ar, stk->points[i].p, pval);
|
||||
viewray(ar, v3d, pval, ray_start, ray_normal);
|
||||
ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal);
|
||||
|
||||
mul_v3_fl(ray_normal, distance * progress / length);
|
||||
add_v3_v3(stk->points[i].p, ray_normal);
|
||||
@@ -1032,7 +1032,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
|
||||
|
||||
/* method taken from editview.c - mouse_cursor() */
|
||||
project_short_noclip(ar, fp, cval);
|
||||
window_to_3d_delta(ar, dvec, cval[0] - dd->mval[0], cval[1] - dd->mval[1]);
|
||||
ED_view3d_win_to_delta(ar, cval[0] - dd->mval[0], cval[1] - dd->mval[1], dvec);
|
||||
sub_v3_v3v3(vec, fp, dvec);
|
||||
}
|
||||
|
||||
@@ -1721,7 +1721,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
|
||||
|
||||
mval[0] = vi[0];
|
||||
mval[1] = vi[1];
|
||||
viewline(ar, v3d, mval, ray_start, ray_end);
|
||||
ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
|
||||
|
||||
isect_line_line_v3( stk->points[s_i].p,
|
||||
stk->points[s_i + 1].p,
|
||||
|
||||
@@ -401,7 +401,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi
|
||||
/* convert screen coordinate to 3d coordinates
|
||||
* - method taken from editview.c - mouse_cursor()
|
||||
*/
|
||||
window_to_3d(ar, p3d, fp, mx, my);
|
||||
ED_view3d_win_to_3d(ar, fp, mx, my, p3d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo
|
||||
|
||||
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
|
||||
if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) {
|
||||
if (gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out, 0, depth))) {
|
||||
if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
|
||||
/* projecting onto 3D-Geometry
|
||||
* - nothing more needs to be done here, since view_autodist_simple() has already done it
|
||||
*/
|
||||
@@ -267,7 +267,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo
|
||||
|
||||
/* method taken from editview.c - mouse_cursor() */
|
||||
project_int_noclip(p->ar, rvec, mval);
|
||||
window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my);
|
||||
ED_view3d_win_to_delta(p->ar, mval[0]-mx, mval[1]-my, dvec);
|
||||
sub_v3_v3v3(out, rvec, dvec);
|
||||
}
|
||||
}
|
||||
@@ -583,8 +583,8 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
|
||||
for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) {
|
||||
mval[0]= ptc->x; mval[1]= ptc->y;
|
||||
|
||||
if ((view_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) &&
|
||||
(i && (view_autodist_depth_segment(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0))
|
||||
if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) &&
|
||||
(i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0))
|
||||
) {
|
||||
interp_depth= TRUE;
|
||||
}
|
||||
@@ -1228,7 +1228,7 @@ static void gp_paint_strokeend (tGPsdata *p)
|
||||
|
||||
/* need to restore the original projection settings before packing up */
|
||||
view3d_region_operator_needs_opengl(p->win, p->ar);
|
||||
view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
|
||||
ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
|
||||
}
|
||||
|
||||
/* check if doing eraser or not */
|
||||
|
||||
@@ -80,9 +80,76 @@ typedef struct ViewDepths {
|
||||
float *give_cursor(struct Scene *scene, struct View3D *v3d);
|
||||
|
||||
int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
|
||||
void window_to_3d(struct ARegion *ar, float out[3], const float depth_pt[3], const float mx, const float my);
|
||||
void window_to_3d_delta(struct ARegion *ar, float out[3], const float mx, const float my);
|
||||
void window_to_3d_vector(struct ARegion *ar, float out[3], const float mx, const float my);
|
||||
|
||||
/**
|
||||
* Calculate a 3d location from 2d window coordinates.
|
||||
* @param ar The region (used for the window width and height).
|
||||
* @param depth_pt The reference location used to calculate the Z depth.
|
||||
* @param mx The area relative X location (such as event->mval[0]).
|
||||
* @param my The area relative Y location (such as event->mval[1]).
|
||||
* @param out The resulting world-space location.
|
||||
*/
|
||||
void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mx, const float my, float out[3]);
|
||||
|
||||
/**
|
||||
* Calculate a 3d difference vector from 2d window offset.
|
||||
* note that initgrabz() must be called first to determine
|
||||
* the depth used to calculate the delta.
|
||||
* @param ar The region (used for the window width and height).
|
||||
* @param mx The area relative X difference (such as event->mval[0] - other_x).
|
||||
* @param my The area relative Y difference (such as event->mval[1] - other_y).
|
||||
* @param out The resulting world-space delta.
|
||||
*/
|
||||
void ED_view3d_win_to_delta(struct ARegion *ar, const float mx, const float my, float out[3]);
|
||||
|
||||
/**
|
||||
* Calculate a 3d direction vector from 2d window coordinates.
|
||||
* This direction vector starts and the view in the direction of the 2d window coordinates.
|
||||
* In orthographic view all window coordinates yield the same vector.
|
||||
* @param ar The region (used for the window width and height).
|
||||
* @param mx The area relative X difference (such as event->mval[0]).
|
||||
* @param my The area relative Y difference (such as event->mval[1]).
|
||||
* @param out The resulting normalized world-space direction vector.
|
||||
*/
|
||||
void ED_view3d_win_to_vector(struct ARegion *ar, const float mx, const float my, float out[3]);
|
||||
|
||||
/**
|
||||
* Calculate a 3d segment from 2d window coordinates.
|
||||
* This ray_start is located at the viewpoint, ray_end is a far point.
|
||||
* ray_start and ray_end are clipped by the view near and far limits
|
||||
* so points along this line are always in view.
|
||||
* In orthographic view all resulting segments will be parallel.
|
||||
* @param ar The region (used for the window width and height).
|
||||
* @param v3d The 3d viewport (used for near and far clipping range).
|
||||
* @param mval The area relative 2d location (such as event->mval, converted into float[2]).
|
||||
* @param ray_start The world-space starting point of the segment.
|
||||
* @param ray_end The world-space end point of the segment.
|
||||
*/
|
||||
void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
|
||||
|
||||
/**
|
||||
* Calculate a 3d viewpoint and direction vector from 2d window coordinates.
|
||||
* This ray_start is located at the viewpoint, ray_normal is the direction towards mval.
|
||||
* ray_start is clipped by the view near limit so points in front of it are always in view.
|
||||
* In orthographic view the resulting ray_normal will match the view vector.
|
||||
* @param ar The region (used for the window width and height).
|
||||
* @param v3d The 3d viewport (used for near clipping value).
|
||||
* @param out The resulting normalized world-space direction vector.
|
||||
* @param mval The area relative 2d location (such as event->mval, converted into float[2]).
|
||||
* @param ray_start The world-space starting point of the segment.
|
||||
* @param ray_normal The normalized world-space direction of towards mval.
|
||||
*/
|
||||
void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
|
||||
|
||||
/**
|
||||
* Calculate a normalized 3d direction vector from the viewpoint towards a global location.
|
||||
* In orthographic view the resulting vector will match the view vector.
|
||||
* @param ar The region (used for the window width and height).
|
||||
* @param coord The world-space location.
|
||||
* @param vec The resulting normalized vector.
|
||||
*/
|
||||
void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
|
||||
|
||||
void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
|
||||
|
||||
/* Depth buffer */
|
||||
@@ -104,11 +171,6 @@ void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]);
|
||||
void project_float(struct ARegion *ar, const float vec[3], float adr[2]);
|
||||
void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]);
|
||||
|
||||
void viewvector(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
|
||||
|
||||
void viewline(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
|
||||
void viewray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
|
||||
|
||||
void get_object_clip_range(struct Object *ob, float *lens, float *clipsta, float *clipend);
|
||||
int get_view3d_cliprange(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend);
|
||||
int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
|
||||
@@ -138,13 +200,13 @@ unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2
|
||||
unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
|
||||
|
||||
/* draws and does a 4x4 sample */
|
||||
int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3]);
|
||||
int ED_view3d_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3]);
|
||||
|
||||
/* only draw so view_autodist_simple can be called many times after */
|
||||
int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
|
||||
int view_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
|
||||
int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
|
||||
int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
|
||||
/* only draw so ED_view3d_autodist_simple can be called many times after */
|
||||
int ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
|
||||
int ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
|
||||
int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
|
||||
int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
|
||||
|
||||
/* select */
|
||||
#define MAXPICKBUF 10000
|
||||
|
||||
@@ -3244,7 +3244,7 @@ static int brush_add(PEData *data, short number)
|
||||
|
||||
mco[0]= data->mval[0] + dmx;
|
||||
mco[1]= data->mval[1] + dmy;
|
||||
viewline(data->vc.ar, data->vc.v3d, mco, co1, co2);
|
||||
ED_view3d_win_to_segment_clip(data->vc.ar, data->vc.v3d, mco, co1, co2);
|
||||
|
||||
mul_m4_v3(imat,co1);
|
||||
mul_m4_v3(imat,co2);
|
||||
@@ -3512,7 +3512,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
|
||||
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
|
||||
window_to_3d_delta(ar, vec, dx, dy);
|
||||
ED_view3d_win_to_delta(ar, dx, dy, vec);
|
||||
data.dvec= vec;
|
||||
|
||||
foreach_mouse_hit_key(&data, brush_comb, selected);
|
||||
|
||||
@@ -5270,7 +5270,7 @@ static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
if(!view_autodist(scene, ar, v3d, event->mval, location))
|
||||
if(!ED_view3d_autodist(scene, ar, v3d, event->mval, location))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
RNA_float_set_array(op->ptr, "location", location);
|
||||
|
||||
@@ -333,7 +333,7 @@ static int project_brush_radius(RegionView3D* rv3d, float radius, float location
|
||||
{
|
||||
float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
|
||||
|
||||
viewvector(rv3d, location, view);
|
||||
ED_view3d_global_to_vector(rv3d, location, view);
|
||||
|
||||
// create a vector that is not orthogonal to view
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ float paint_calc_object_space_radius(ViewContext *vc, float center[3],
|
||||
mul_v3_m4v3(loc, ob->obmat, center);
|
||||
|
||||
initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
|
||||
window_to_3d_delta(vc->ar, delta, pixel_radius, 0);
|
||||
ED_view3d_win_to_delta(vc->ar, pixel_radius, 0, delta);
|
||||
|
||||
scale= fabsf(mat4_to_scale(ob->obmat));
|
||||
scale= (scale == 0.0f)? 1.0f: scale;
|
||||
|
||||
@@ -912,7 +912,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **n
|
||||
{
|
||||
switch (brush->sculpt_plane) {
|
||||
case SCULPT_DISP_DIR_VIEW:
|
||||
viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
|
||||
ED_view3d_global_to_vector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_X:
|
||||
@@ -1823,7 +1823,7 @@ static void calc_sculpt_plane(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn
|
||||
{
|
||||
switch (brush->sculpt_plane) {
|
||||
case SCULPT_DISP_DIR_VIEW:
|
||||
viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
|
||||
ED_view3d_global_to_vector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_X:
|
||||
@@ -2926,7 +2926,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
|
||||
cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
|
||||
view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats);
|
||||
|
||||
viewvector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
|
||||
ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
|
||||
/* Initialize layer brush displacements and persistent coords */
|
||||
if(brush->sculpt_tool == SCULPT_TOOL_LAYER) {
|
||||
/* not supported yet for multires */
|
||||
@@ -2994,8 +2994,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
|
||||
cache->orig_grab_location[1],
|
||||
cache->orig_grab_location[2]);
|
||||
|
||||
window_to_3d_delta(cache->vc->ar, grab_location,
|
||||
cache->mouse[0], cache->mouse[1]);
|
||||
ED_view3d_win_to_delta(cache->vc->ar, cache->mouse[0], cache->mouse[1], grab_location);
|
||||
|
||||
/* compute delta to move verts by */
|
||||
if(!cache->first_time) {
|
||||
@@ -3247,7 +3246,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
|
||||
|
||||
sculpt_stroke_modifiers_check(C, ob);
|
||||
|
||||
viewline(vc->ar, vc->v3d, mval, ray_start, ray_end);
|
||||
ED_view3d_win_to_segment_clip(vc->ar, vc->v3d, mval, ray_start, ray_end);
|
||||
|
||||
invert_m4_m4(obimat, ob->obmat);
|
||||
mul_m4_v3(obimat, ray_start);
|
||||
|
||||
@@ -1410,7 +1410,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
|
||||
/* calc window coord */
|
||||
initgrabz(rv3d, 0.0, 0.0, 0.0);
|
||||
window_to_3d_delta(ar, vec, 1, 0);
|
||||
ED_view3d_win_to_delta(ar, 1, 0, vec);
|
||||
fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) );
|
||||
fac= 1.0f/fac;
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
|
||||
|
||||
if((vod->use_dyn_ofs=view_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) {
|
||||
if((vod->use_dyn_ofs=ED_view3d_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) {
|
||||
if (rv3d->is_persp) {
|
||||
float my_origin[3]; /* original G.vd->ofs */
|
||||
float my_pivot[3]; /* view */
|
||||
@@ -419,7 +419,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
|
||||
}
|
||||
|
||||
/* for dolly */
|
||||
window_to_3d_vector(vod->ar, vod->mousevec, event->mval[0], event->mval[1]);
|
||||
ED_view3d_win_to_vector(vod->ar, event->mval[0], event->mval[1], vod->mousevec);
|
||||
|
||||
/* lookup, we dont pass on v3d to prevent confusement */
|
||||
vod->grid= vod->v3d->grid;
|
||||
@@ -929,7 +929,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
|
||||
else {
|
||||
float dvec[3];
|
||||
|
||||
window_to_3d_delta(vod->ar, dvec, x-vod->oldx, y-vod->oldy);
|
||||
ED_view3d_win_to_delta(vod->ar, x-vod->oldx, y-vod->oldy, dvec);
|
||||
add_v3_v3(vod->rv3d->ofs, dvec);
|
||||
|
||||
if(vod->rv3d->viewlock & RV3D_BOXVIEW)
|
||||
@@ -1085,7 +1085,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
|
||||
|
||||
/* Project cursor position into 3D space */
|
||||
initgrabz(rv3d, tpos[0], tpos[1], tpos[2]);
|
||||
window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2.0f, mouseloc[1]-vb[1]/2.0f);
|
||||
ED_view3d_win_to_delta(ar, mouseloc[0]-vb[0]/2.0f, mouseloc[1]-vb[1]/2.0f, dvec);
|
||||
|
||||
/* Calculate view target position for dolly */
|
||||
add_v3_v3v3(tvec, tpos, dvec);
|
||||
@@ -2076,7 +2076,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
|
||||
|
||||
initgrabz(rv3d, -new_ofs[0], -new_ofs[1], -new_ofs[2]);
|
||||
|
||||
window_to_3d_delta(ar, dvec, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2);
|
||||
ED_view3d_win_to_delta(ar, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2, dvec);
|
||||
/* center the view to the center of the rectangle */
|
||||
sub_v3_v3(new_ofs, dvec);
|
||||
}
|
||||
@@ -2484,10 +2484,10 @@ static int viewpan_exec(bContext *C, wmOperator *op)
|
||||
pandir = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
initgrabz(rv3d, 0.0, 0.0, 0.0);
|
||||
if(pandir == V3D_VIEW_PANRIGHT) window_to_3d_delta(ar, vec, -32, 0);
|
||||
else if(pandir == V3D_VIEW_PANLEFT) window_to_3d_delta(ar, vec, 32, 0);
|
||||
else if(pandir == V3D_VIEW_PANUP) window_to_3d_delta(ar, vec, 0, -25);
|
||||
else if(pandir == V3D_VIEW_PANDOWN) window_to_3d_delta(ar, vec, 0, 25);
|
||||
if(pandir == V3D_VIEW_PANRIGHT) ED_view3d_win_to_delta(ar, -32, 0, vec);
|
||||
else if(pandir == V3D_VIEW_PANLEFT) ED_view3d_win_to_delta(ar, 32, 0, vec);
|
||||
else if(pandir == V3D_VIEW_PANUP) ED_view3d_win_to_delta(ar, 0, -25, vec);
|
||||
else if(pandir == V3D_VIEW_PANDOWN) ED_view3d_win_to_delta(ar, 0, 25, vec);
|
||||
add_v3_v3(rv3d->ofs, vec);
|
||||
|
||||
if(rv3d->viewlock & RV3D_BOXVIEW)
|
||||
@@ -2806,12 +2806,12 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
|
||||
|
||||
if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */
|
||||
view3d_operator_needs_opengl(C);
|
||||
if (view_autodist(scene, ar, v3d, event->mval, fp))
|
||||
if (ED_view3d_autodist(scene, ar, v3d, event->mval, fp))
|
||||
depth_used= 1;
|
||||
}
|
||||
|
||||
if(depth_used==0) {
|
||||
window_to_3d_delta(ar, dvec, mval[0]-event->mval[0], mval[1]-event->mval[1]);
|
||||
ED_view3d_win_to_delta(ar, mval[0]-event->mval[0], mval[1]-event->mval[1], dvec);
|
||||
sub_v3_v3(fp, dvec);
|
||||
}
|
||||
}
|
||||
@@ -2961,7 +2961,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
|
||||
}
|
||||
|
||||
/* XXX todo Zooms in on a border drawn by the user */
|
||||
int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist )
|
||||
int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist )
|
||||
{
|
||||
bglMats mats; /* ZBuffer depth vars */
|
||||
float depth_close= FLT_MAX;
|
||||
@@ -2988,7 +2988,7 @@ int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], flo
|
||||
return 1;
|
||||
}
|
||||
|
||||
int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist )
|
||||
int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist )
|
||||
{
|
||||
/* Get Z Depths, needed for perspective, nice for ortho */
|
||||
switch(mode) {
|
||||
@@ -3004,7 +3004,7 @@ int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, flo
|
||||
}
|
||||
|
||||
// no 4x4 sampling, run view_autodist_init first
|
||||
int view_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist )
|
||||
int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist )
|
||||
{
|
||||
bglMats mats; /* ZBuffer depth vars, could cache? */
|
||||
float depth;
|
||||
@@ -3032,7 +3032,7 @@ int view_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3]
|
||||
return 1;
|
||||
}
|
||||
|
||||
int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth)
|
||||
int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth)
|
||||
{
|
||||
*depth= view_autodist_depth_margin(ar, mval, margin);
|
||||
|
||||
@@ -3059,7 +3059,7 @@ static int depth_segment_cb(int x, int y, void *userData)
|
||||
}
|
||||
}
|
||||
|
||||
int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
|
||||
int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth)
|
||||
{
|
||||
struct { struct ARegion *ar; int margin; float depth; } data = {NULL};
|
||||
int p1[2];
|
||||
|
||||
@@ -106,7 +106,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
|
||||
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
|
||||
|
||||
if(mval_cpy[0]!=IS_CLIPPED) {
|
||||
window_to_3d_delta(vc->ar, dvec, mval_cpy[0]-mval[0], mval_cpy[1]-mval[1]);
|
||||
ED_view3d_win_to_delta(vc->ar, mval_cpy[0]-mval[0], mval_cpy[1]-mval[1], dvec);
|
||||
sub_v3_v3(fp, dvec);
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -502,13 +502,13 @@ void view3d_calculate_clipping(BoundBox *bb, float planes[4][4], bglMats *mats,
|
||||
}
|
||||
|
||||
/* create intersection coordinates in view Z direction at mouse coordinates */
|
||||
void viewline(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
|
||||
void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
|
||||
if(rv3d->is_persp) {
|
||||
float vec[3];
|
||||
window_to_3d_vector(ar, vec, mval[0], mval[1]);
|
||||
ED_view3d_win_to_vector(ar, mval[0], mval[1], vec);
|
||||
|
||||
copy_v3_v3(ray_start, rv3d->viewinv[3]);
|
||||
VECADDFAC(ray_start, rv3d->viewinv[3], vec, v3d->near);
|
||||
@@ -537,16 +537,16 @@ void viewline(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3],
|
||||
}
|
||||
|
||||
/* create intersection ray in view Z direction at mouse coordinates */
|
||||
void viewray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
|
||||
void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
|
||||
{
|
||||
float ray_end[3];
|
||||
|
||||
viewline(ar, v3d, mval, ray_start, ray_end);
|
||||
ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
|
||||
sub_v3_v3v3(ray_normal, ray_end, ray_start);
|
||||
normalize_v3(ray_normal);
|
||||
}
|
||||
|
||||
void viewvector(RegionView3D *rv3d, const float coord[3], float vec[3])
|
||||
void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float vec[3])
|
||||
{
|
||||
if (rv3d->is_persp) {
|
||||
float p1[4], p2[4];
|
||||
@@ -592,7 +592,7 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z)
|
||||
return flip;
|
||||
}
|
||||
|
||||
void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const float mx, const float my)
|
||||
void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mx, const float my, float out[3])
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
|
||||
@@ -602,7 +602,7 @@ void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const floa
|
||||
if(rv3d->is_persp) {
|
||||
float mousevec[3];
|
||||
copy_v3_v3(line_sta, rv3d->viewinv[3]);
|
||||
window_to_3d_vector(ar, mousevec, mx, my);
|
||||
ED_view3d_win_to_vector(ar, mx, my, mousevec);
|
||||
add_v3_v3v3(line_end, line_sta, mousevec);
|
||||
|
||||
if(isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) {
|
||||
@@ -624,7 +624,7 @@ void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const floa
|
||||
|
||||
/* always call initgrabz */
|
||||
/* only to detect delta motion */
|
||||
void window_to_3d_delta(ARegion *ar, float out[3], const float mx, const float my)
|
||||
void ED_view3d_win_to_delta(ARegion *ar, const float mx, const float my, float out[3])
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
float dx, dy;
|
||||
@@ -640,7 +640,7 @@ void window_to_3d_delta(ARegion *ar, float out[3], const float mx, const float m
|
||||
/* doesn't rely on initgrabz */
|
||||
/* for perspective view, get the vector direction to
|
||||
* the mouse cursor as a normalized vector */
|
||||
void window_to_3d_vector(ARegion *ar, float out[3], const float mx, const float my)
|
||||
void ED_view3d_win_to_vector(ARegion *ar, const float mx, const float my, float out[3])
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ void convertViewVec(TransInfo *t, float *vec, int dx, int dy)
|
||||
if (t->spacetype==SPACE_VIEW3D) {
|
||||
if (t->ar->regiontype == RGN_TYPE_WINDOW)
|
||||
{
|
||||
window_to_3d_delta(t->ar, vec, dx, dy);
|
||||
ED_view3d_win_to_delta(t->ar, dx, dy, vec);
|
||||
}
|
||||
}
|
||||
else if(t->spacetype==SPACE_IMAGE) {
|
||||
|
||||
@@ -557,7 +557,7 @@ static void test_manipulator_axis(const bContext *C)
|
||||
float angle;
|
||||
float vec[3];
|
||||
|
||||
viewvector(rv3d, rv3d->twmat[3], vec);
|
||||
ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], vec);
|
||||
|
||||
angle = fabs(angle_v3v3(rv3d->twmat[0], vec));
|
||||
if (angle > (float)M_PI / 2.0f) {
|
||||
|
||||
@@ -1581,7 +1581,7 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, f
|
||||
int retval = 0;
|
||||
float ray_start[3], ray_normal[3];
|
||||
|
||||
viewray(ar, v3d, mval, ray_start, ray_normal);
|
||||
ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
|
||||
|
||||
if (mode == SNAP_ALL && obedit)
|
||||
{
|
||||
@@ -1812,7 +1812,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L
|
||||
int retval = 0;
|
||||
float ray_start[3], ray_normal[3];
|
||||
|
||||
viewray(ar, v3d, mval, ray_start, ray_normal);
|
||||
ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
|
||||
|
||||
for ( base = scene->base.first; base != NULL; base = base->next ) {
|
||||
if ( BASE_SELECTABLE(v3d, base) ) {
|
||||
|
||||
Reference in New Issue
Block a user