Blender
V3.3
|
#include "DNA_camera_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "BLI_sys_types.h"
#include "BLI_math_vector.h"
#include "BKE_camera.h"
#include "BKE_screen.h"
#include "GPU_matrix.h"
#include "ED_view3d.h"
Go to the source code of this file.
Macros | |
#define | BL_ZERO_CLIP 0.001 |
Functions | |
void | ED_view3d_project_float_v2_m4 (const ARegion *region, const float co[3], float r_co[2], const float mat[4][4]) |
void | ED_view3d_project_float_v3_m4 (const ARegion *region, const float co[3], float r_co[3], const float mat[4][4]) |
eV3DProjStatus | ED_view3d_project_base (const struct ARegion *region, struct Base *base) |
static eV3DProjStatus | ed_view3d_project__internal (const ARegion *region, const float perspmat[4][4], const bool is_local, const float co[3], float r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_short_ex (const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], short r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_int_ex (const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], int r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_float_ex (const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], float r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_short_global (const ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_short_object (const ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_int_global (const ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_int_object (const ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_float_global (const ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag) |
eV3DProjStatus | ED_view3d_project_float_object (const ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag) |
float | ED_view3d_pixel_size (const RegionView3D *rv3d, const float co[3]) |
float | ED_view3d_pixel_size_no_ui_scale (const RegionView3D *rv3d, const float co[3]) |
float | ED_view3d_calc_zfac_ex (const RegionView3D *rv3d, const float co[3], bool *r_flip) |
float | ED_view3d_calc_zfac (const RegionView3D *rv3d, const float co[3]) |
float | ED_view3d_calc_depth_for_comparison (const RegionView3D *rv3d, const float co[3]) |
static void | view3d_win_to_ray_segment (const struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_co[3], float r_ray_dir[3], float r_ray_start[3], float r_ray_end[3]) |
bool | ED_view3d_clip_segment (const RegionView3D *rv3d, float ray_start[3], float ray_end[3]) |
bool | ED_view3d_win_to_ray_clipped_ex (struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip_planes) |
bool | ED_view3d_win_to_ray_clipped (struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_normal[3], const bool do_clip_planes) |
void | ED_view3d_win_to_ray (const ARegion *region, const float mval[2], float r_ray_start[3], float r_ray_normal[3]) |
void | ED_view3d_global_to_vector (const RegionView3D *rv3d, const float coord[3], float vec[3]) |
void | ED_view3d_win_to_3d (const View3D *v3d, const ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3]) |
void | ED_view3d_win_to_3d_int (const View3D *v3d, const ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3]) |
bool | ED_view3d_win_to_3d_on_plane (const ARegion *region, const float plane[4], const float mval[2], const bool do_clip, float r_out[3]) |
bool | ED_view3d_win_to_3d_on_plane_int (const ARegion *region, const float plane[4], const int mval[2], const bool do_clip, float r_out[3]) |
bool | ED_view3d_win_to_3d_on_plane_with_fallback (const ARegion *region, const float plane[4], const float mval[2], const bool do_clip, const float plane_fallback[4], float r_out[3]) |
void | ED_view3d_win_to_delta (const ARegion *region, const float xy_delta[2], const float zfac, float r_out[3]) |
void | ED_view3d_win_to_origin (const ARegion *region, const float mval[2], float r_out[3]) |
void | ED_view3d_win_to_vector (const ARegion *region, const float mval[2], float r_out[3]) |
bool | ED_view3d_win_to_segment_clipped (const struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_end[3], const bool do_clip_planes) |
Utility functions for projection | |
void | ED_view3d_ob_project_mat_get (const RegionView3D *rv3d, const Object *ob, float r_pmat[4][4]) |
void | ED_view3d_ob_project_mat_get_from_obmat (const RegionView3D *rv3d, const float obmat[4][4], float r_pmat[4][4]) |
void | ED_view3d_project_v3 (const struct ARegion *region, const float world[3], float r_region_co[3]) |
void | ED_view3d_project_v2 (const struct ARegion *region, const float world[3], float r_region_co[2]) |
bool | ED_view3d_unproject_v3 (const struct ARegion *region, float regionx, float regiony, float regionz, float world[3]) |
#define BL_ZERO_CLIP 0.001 |
Definition at line 25 of file view3d_project.c.
float ED_view3d_calc_depth_for_comparison | ( | const RegionView3D * | rv3d, |
const float | co[3] | ||
) |
Definition at line 307 of file view3d_project.c.
References dot_v3v3(), ED_view3d_calc_zfac(), RegionView3D::is_persp, and RegionView3D::viewinv.
float ED_view3d_calc_zfac | ( | const RegionView3D * | rv3d, |
const float | co[3] | ||
) |
Definition at line 302 of file view3d_project.c.
References ED_view3d_calc_zfac_ex(), and NULL.
Referenced by ED_view3d_calc_depth_for_comparison().
float ED_view3d_calc_zfac_ex | ( | const RegionView3D * | rv3d, |
const float | co[3], | ||
bool * | r_flip | ||
) |
Definition at line 279 of file view3d_project.c.
References mul_project_m4_v3_zfac(), and RegionView3D::persmat.
Referenced by ED_view3d_calc_zfac().
bool ED_view3d_clip_segment | ( | const RegionView3D * | rv3d, |
float | ray_start[3], | ||
float | ray_end[3] | ||
) |
Definition at line 353 of file view3d_project.c.
References RegionView3D::clip, clip_segment_v3_plane_n(), RegionView3D::rflag, and RV3D_CLIPPING.
Referenced by ED_view3d_win_to_ray_clipped_ex(), and ED_view3d_win_to_segment_clipped().
void ED_view3d_global_to_vector | ( | const RegionView3D * | rv3d, |
const float | coord[3], | ||
float | vec[3] | ||
) |
Definition at line 405 of file view3d_project.c.
References copy_v3_v3(), RegionView3D::is_persp, mul_m4_v4(), mul_v3_fl(), normalize_v3(), sub_v3_v3v3(), RegionView3D::viewinv, and RegionView3D::viewmat.
void ED_view3d_ob_project_mat_get | ( | const RegionView3D * | rv3d, |
const Object * | ob, | ||
float | r_pmat[4][4] | ||
) |
Definition at line 682 of file view3d_project.c.
References mul_m4_m4m4(), Object::obmat, RegionView3D::viewmat, and RegionView3D::winmat.
void ED_view3d_ob_project_mat_get_from_obmat | ( | const RegionView3D * | rv3d, |
const float | obmat[4][4], | ||
float | r_pmat[4][4] | ||
) |
Definition at line 690 of file view3d_project.c.
References mul_m4_m4m4(), RegionView3D::viewmat, and RegionView3D::winmat.
float ED_view3d_pixel_size | ( | const RegionView3D * | rv3d, |
const float | co[3] | ||
) |
Definition at line 269 of file view3d_project.c.
References mul_project_m4_v3_zfac(), RegionView3D::persmat, and RegionView3D::pixsize.
float ED_view3d_pixel_size_no_ui_scale | ( | const RegionView3D * | rv3d, |
const float | co[3] | ||
) |
Definition at line 274 of file view3d_project.c.
References mul_project_m4_v3_zfac(), RegionView3D::persmat, and RegionView3D::pixsize.
|
static |
Definition at line 95 of file view3d_project.c.
References BL_ZERO_CLIP, BLI_assert, copy_v3_v3(), ED_view3d_clipping_test(), fabsf, float(), mul_m4_v4(), ARegion::regiondata, RegionView3D::rflag, RV3D_CLIPPING, V3D_PROJ_RET_CLIP_BB, V3D_PROJ_RET_CLIP_FAR, V3D_PROJ_RET_CLIP_NEAR, V3D_PROJ_RET_CLIP_WIN, V3D_PROJ_RET_CLIP_ZERO, V3D_PROJ_RET_OK, V3D_PROJ_TEST_ALL, V3D_PROJ_TEST_CLIP_BB, V3D_PROJ_TEST_CLIP_FAR, V3D_PROJ_TEST_CLIP_NEAR, V3D_PROJ_TEST_CLIP_WIN, V3D_PROJ_TEST_CLIP_ZERO, vec4, w(), ARegion::winx, and ARegion::winy.
Referenced by ED_view3d_project_float_ex(), ED_view3d_project_int_ex(), and ED_view3d_project_short_ex().
eV3DProjStatus ED_view3d_project_base | ( | const struct ARegion * | region, |
struct Base * | base | ||
) |
Definition at line 78 of file view3d_project.c.
References ED_view3d_project_short_global(), IS_CLIPPED, Base::object, Object::obmat, ret, Base::sx, Base::sy, V3D_PROJ_RET_OK, and V3D_PROJ_TEST_CLIP_DEFAULT.
Referenced by do_lasso_select_objects(), and object_mouse_select_menu().
eV3DProjStatus ED_view3d_project_float_ex | ( | const ARegion * | region, |
float | perspmat[4][4], | ||
const bool | is_local, | ||
const float | co[3], | ||
float | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 192 of file view3d_project.c.
References copy_v2_v2(), ed_view3d_project__internal(), CCL_NAMESPACE_BEGIN::isfinite(), ret, V3D_PROJ_RET_OK, and V3D_PROJ_RET_OVERFLOW.
Referenced by ED_view3d_project_float_global(), and ED_view3d_project_float_object().
eV3DProjStatus ED_view3d_project_float_global | ( | const ARegion * | region, |
const float | co[3], | ||
float | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 248 of file view3d_project.c.
References ED_view3d_project_float_ex(), RegionView3D::persmat, and ARegion::regiondata.
eV3DProjStatus ED_view3d_project_float_object | ( | const ARegion * | region, |
const float | co[3], | ||
float | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 256 of file view3d_project.c.
References ED_view3d_check_mats_rv3d, ED_view3d_project_float_ex(), RegionView3D::persmatob, and ARegion::regiondata.
void ED_view3d_project_float_v2_m4 | ( | const ARegion * | region, |
const float | co[3], | ||
float | r_co[2], | ||
const float | mat[4][4] | ||
) |
Definition at line 30 of file view3d_project.c.
References copy_v3_v3(), float(), mul_m4_v4(), vec4, ARegion::winx, ARegion::winy, and zero_v2().
void ED_view3d_project_float_v3_m4 | ( | const ARegion * | region, |
const float | co[3], | ||
float | r_co[3], | ||
const float | mat[4][4] | ||
) |
Definition at line 52 of file view3d_project.c.
References copy_v3_v3(), float(), mul_m4_v4(), vec4, ARegion::winx, ARegion::winy, and zero_v3().
eV3DProjStatus ED_view3d_project_int_ex | ( | const ARegion * | region, |
float | perspmat[4][4], | ||
const bool | is_local, | ||
const float | co[3], | ||
int | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 170 of file view3d_project.c.
References ed_view3d_project__internal(), floorf, ret, V3D_PROJ_RET_OK, and V3D_PROJ_RET_OVERFLOW.
Referenced by ED_view3d_project_int_global(), and ED_view3d_project_int_object().
eV3DProjStatus ED_view3d_project_int_global | ( | const ARegion * | region, |
const float | co[3], | ||
int | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 230 of file view3d_project.c.
References ED_view3d_project_int_ex(), RegionView3D::persmat, and ARegion::regiondata.
eV3DProjStatus ED_view3d_project_int_object | ( | const ARegion * | region, |
const float | co[3], | ||
int | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 238 of file view3d_project.c.
References ED_view3d_check_mats_rv3d, ED_view3d_project_int_ex(), RegionView3D::persmatob, and ARegion::regiondata.
eV3DProjStatus ED_view3d_project_short_ex | ( | const ARegion * | region, |
float | perspmat[4][4], | ||
const bool | is_local, | ||
const float | co[3], | ||
short | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 148 of file view3d_project.c.
References ed_view3d_project__internal(), floorf, ret, V3D_PROJ_RET_OK, and V3D_PROJ_RET_OVERFLOW.
Referenced by ED_view3d_project_short_global(), and ED_view3d_project_short_object().
eV3DProjStatus ED_view3d_project_short_global | ( | const ARegion * | region, |
const float | co[3], | ||
short | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 212 of file view3d_project.c.
References ED_view3d_project_short_ex(), RegionView3D::persmat, and ARegion::regiondata.
Referenced by ED_view3d_project_base().
eV3DProjStatus ED_view3d_project_short_object | ( | const ARegion * | region, |
const float | co[3], | ||
short | r_co[2], | ||
const eV3DProjTest | flag | ||
) |
Definition at line 220 of file view3d_project.c.
References ED_view3d_check_mats_rv3d, ED_view3d_project_short_ex(), RegionView3D::persmatob, and ARegion::regiondata.
void ED_view3d_project_v2 | ( | const struct ARegion * | region, |
const float | world[3], | ||
float | r_region_co[2] | ||
) |
Definition at line 708 of file view3d_project.c.
References GPU_matrix_project_2fv(), ARegion::regiondata, RegionView3D::viewmat, RegionView3D::winmat, ARegion::winx, ARegion::winy, and world.
Referenced by blender::ed::sculpt_paint::min_distance_edit::calculate_points_per_side(), gizmo_preselect_elem_test_select(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), paint_line_strokes_spacing(), paint_space_stroke(), and voxel_size_edit_invoke().
void ED_view3d_project_v3 | ( | const struct ARegion * | region, |
const float | world[3], | ||
float | r_region_co[3] | ||
) |
Convert between region relative coordinates (x,y) and depth component z and a point in world space.
Definition at line 700 of file view3d_project.c.
References GPU_matrix_project_3fv(), ARegion::regiondata, RegionView3D::viewmat, RegionView3D::winmat, ARegion::winx, ARegion::winy, and world.
Referenced by cursor_draw_point_screen_space(), key_test_depth(), and object_transform_axis_target_calc_depth_init().
bool ED_view3d_unproject_v3 | ( | const struct ARegion * | region, |
float | regionx, | ||
float | regiony, | ||
float | regionz, | ||
float | world[3] | ||
) |
Definition at line 716 of file view3d_project.c.
References GPU_matrix_unproject_3fv(), ARegion::regiondata, RegionView3D::viewinv, RegionView3D::winmat, ARegion::winx, ARegion::winy, and world.
Referenced by ED_view3d_autodist(), ED_view3d_autodist_simple(), ED_view3d_clipping_calc(), ED_view3d_depth_unproject_v3(), knife_input_ray_segment(), point_is_visible(), and view3d_zoom_border_exec().
void ED_view3d_win_to_3d | ( | const View3D * | v3d, |
const ARegion * | region, | ||
const float | depth_pt[3], | ||
const float | mval[2], | ||
float | r_out[3] | ||
) |
Definition at line 463 of file view3d_project.c.
References BKE_camera_sensor_fit(), BKE_screen_view3d_zoom_to_fac(), RegionView3D::camdx, RegionView3D::camdy, View3D::camera, CAMERA_SENSOR_FIT_HOR, RegionView3D::camzoom, copy_v3_v3(), Object::data, ED_view3d_win_to_vector(), fabsf, float(), RegionView3D::is_persp, isect_ray_plane_v3(), madd_v3_v3v3fl(), RegionView3D::persinv, RegionView3D::persp, plane_from_point_normal_v3(), ray_point_factor_v3(), ARegion::regiondata, RV3D_CAMOB, Camera::sensor_fit, Camera::shiftx, Camera::shifty, RegionView3D::viewinv, ARegion::winx, and ARegion::winy.
Referenced by ED_view3d_win_to_3d_int().
void ED_view3d_win_to_3d_int | ( | const View3D * | v3d, |
const ARegion * | region, | ||
const float | depth_pt[3], | ||
const int | mval[2], | ||
float | r_out[3] | ||
) |
Definition at line 519 of file view3d_project.c.
References ED_view3d_win_to_3d().
bool ED_view3d_win_to_3d_on_plane | ( | const ARegion * | region, |
const float | plane[4], | ||
const float | mval[2], | ||
const bool | do_clip, | ||
float | r_out[3] | ||
) |
Definition at line 529 of file view3d_project.c.
References dot_m4_v3_row_z(), ED_view3d_win_to_origin(), ED_view3d_win_to_vector(), fabsf, RegionView3D::is_persp, isect_ray_plane_v3(), madd_v3_v3v3fl(), RegionView3D::persmat, RegionView3D::persp, ARegion::regiondata, and RV3D_CAMOB.
Referenced by ED_view3d_win_to_3d_on_plane_int(), and ED_view3d_win_to_3d_on_plane_with_fallback().
bool ED_view3d_win_to_3d_on_plane_int | ( | const ARegion * | region, |
const float | plane[4], | ||
const int | mval[2], | ||
const bool | do_clip, | ||
float | r_out[3] | ||
) |
Definition at line 561 of file view3d_project.c.
References ED_view3d_win_to_3d_on_plane().
bool ED_view3d_win_to_3d_on_plane_with_fallback | ( | const ARegion * | region, |
const float | plane[4], | ||
const float | mval[2], | ||
const bool | do_clip, | ||
const float | plane_fallback[4], | ||
float | r_out[3] | ||
) |
Definition at line 571 of file view3d_project.c.
References closest_to_plane_v3(), copy_m4_m3(), ED_view3d_win_to_3d_on_plane(), isect_plane_plane_v3(), mat4, mul_m4_v3(), normalize_v3(), rotation_between_vecs_to_mat3(), and transform_pivot_set_m4().
void ED_view3d_win_to_delta | ( | const ARegion * | region, |
const float | xy_delta[2], | ||
const float | zfac, | ||
float | r_out[3] | ||
) |
Definition at line 606 of file view3d_project.c.
References RegionView3D::persinv, ARegion::regiondata, ARegion::winx, and ARegion::winy.
Definition at line 622 of file view3d_project.c.
References copy_v3_v3(), RegionView3D::is_persp, mul_project_m4_v3(), RegionView3D::persinv, RegionView3D::persp, ARegion::regiondata, RV3D_CAMOB, RegionView3D::viewinv, ARegion::winx, and ARegion::winy.
Referenced by ED_view3d_win_to_3d_on_plane(), ED_view3d_win_to_ray(), and view3d_win_to_ray_segment().
void ED_view3d_win_to_ray | ( | const ARegion * | region, |
const float | mval[2], | ||
float | r_ray_start[3], | ||
float | r_ray_normal[3] | ||
) |
Definition at line 396 of file view3d_project.c.
References ED_view3d_win_to_origin(), and ED_view3d_win_to_vector().
bool ED_view3d_win_to_ray_clipped | ( | struct Depsgraph * | depsgraph, |
const ARegion * | region, | ||
const View3D * | v3d, | ||
const float | mval[2], | ||
float | r_ray_start[3], | ||
float | r_ray_normal[3], | ||
const bool | do_clip_planes | ||
) |
Definition at line 384 of file view3d_project.c.
References depsgraph, ED_view3d_win_to_ray_clipped_ex(), and NULL.
bool ED_view3d_win_to_ray_clipped_ex | ( | struct Depsgraph * | depsgraph, |
const ARegion * | region, | ||
const View3D * | v3d, | ||
const float | mval[2], | ||
float | r_ray_co[3], | ||
float | r_ray_normal[3], | ||
float | r_ray_start[3], | ||
bool | do_clip_planes | ||
) |
Definition at line 362 of file view3d_project.c.
References depsgraph, ED_view3d_clip_segment(), ARegion::regiondata, and view3d_win_to_ray_segment().
Referenced by ED_view3d_win_to_ray_clipped().
bool ED_view3d_win_to_segment_clipped | ( | const struct Depsgraph * | depsgraph, |
const ARegion * | region, | ||
const View3D * | v3d, | ||
const float | mval[2], | ||
float | r_ray_start[3], | ||
float | r_ray_end[3], | ||
const bool | do_clip_planes | ||
) |
Definition at line 660 of file view3d_project.c.
References depsgraph, ED_view3d_clip_segment(), NULL, ARegion::regiondata, and view3d_win_to_ray_segment().
Definition at line 643 of file view3d_project.c.
References RegionView3D::is_persp, mul_project_m4_v3(), negate_v3_v3(), normalize_v3(), RegionView3D::persinv, ARegion::regiondata, sub_v3_v3(), RegionView3D::viewinv, ARegion::winx, and ARegion::winy.
Referenced by ED_view3d_win_to_3d(), ED_view3d_win_to_3d_on_plane(), ED_view3d_win_to_ray(), and view3d_win_to_ray_segment().
|
static |
Definition at line 315 of file view3d_project.c.
References View3D::clip_end, depsgraph, ED_view3d_clip_range_get(), ED_view3d_win_to_origin(), ED_view3d_win_to_vector(), RegionView3D::is_persp, madd_v3_v3v3fl(), RegionView3D::persp, ARegion::regiondata, and RV3D_CAMOB.
Referenced by ED_view3d_win_to_ray_clipped_ex(), and ED_view3d_win_to_segment_clipped().