29#define BL_ZERO_CLIP 0.001
47 if (
vec4[3] > FLT_EPSILON) {
60 const float mat[4][4])
70 if (
vec4[3] > FLT_EPSILON) {
104 const float perspmat[4][4],
141 const float scalar = (
w != 0.0f) ? (1.0f /
w) : 0.0f;
142 const float fx = (
float(region->
winx) / 2.0f) * (1.0f + (
vec4[0] * scalar));
143 const float fy = (
float(region->
winy) / 2.0f) * (1.0f + (
vec4[1] * scalar));
146 (fx <= 0.0f || fy <= 0.0f || fx >=
float(region->
winx) || fy >=
float(region->
winy)))
158 float perspmat[4][4],
167 if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) && (tvec[1] > -32700.0f && tvec[1] < 32700.0f))
169 r_co[0] = short(
floorf(tvec[0]));
170 r_co[1] = short(
floorf(tvec[1]));
180 float perspmat[4][4],
189 if ((tvec[0] > -2140000000.0f && tvec[0] < 2140000000.0f) &&
190 (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f))
203 float perspmat[4][4],
212 if (isfinite(tvec[0]) && isfinite(tvec[1])) {
294 *r_flip = (zfac < 0.0f);
299 if (zfac < 1.e-6f && zfac > -1.e-6f) {
331 float r_ray_start[3],
335 float _ray_co[3], _ray_dir[3], start_offset, end_offset;
341 r_ray_dir = _ray_dir;
349 start_offset = -end_offset;
377 const bool do_clip_planes,
379 float r_ray_normal[3],
380 float r_ray_start[3],
384 depsgraph, region, v3d, mval, r_ray_co, r_ray_normal, r_ray_start, r_ray_end);
387 if (do_clip_planes) {
399 float r_ray_start[3],
400 float r_ray_normal[3],
401 const bool do_clip_planes)
403 float ray_end_dummy[3];
417 float r_ray_start[3],
418 float r_ray_normal[3])
449bool view3d_get_view_aligned_coordinate(
ARegion *region,
452 const bool do_fallback)
462 const float mval_f[2] = {
float(mval_cpy[0] - mval[0]),
float(mval_cpy[1] - mval[1])};
473 return view3d_get_view_aligned_coordinate(region, fp, mval,
false);
484 const float depth_pt[3],
491 float ray_direction[3];
503 lambda =
fabsf(lambda);
506 float dx = (2.0f * mval[0] /
float(region->
winx)) - 1.0f;
507 float dy = (2.0f * mval[1] /
float(region->
winy)) - 1.0f;
516 const float shiftx = cam->
shiftx * 0.5f *
518 const float shifty = cam->
shifty * 0.5f *
521 dx += (rv3d->
camdx + shiftx) * zoomfac;
522 dy += (rv3d->
camdy + shifty) * zoomfac;
537 const float depth_pt[3],
544 float ray_direction[3];
556 lambda =
fabsf(lambda);
559 float dx = (2.0f * mval[0] /
float(region->
winx)) - 1.0f;
560 float dy = (2.0f * mval[1] /
float(region->
winy)) - 1.0f;
569 const float shiftx = cam->
shiftx * 0.5f *
571 const float shifty = cam->
shifty * 0.5f *
574 dx += (rv3d->
camdx + shiftx) * zoomfac;
575 dy += (rv3d->
camdy + shifty) * zoomfac;
590 const float depth_pt[3],
594 const float mval_fl[2] = {
float(mval[0]),
float(mval[1])};
599 const float plane[4],
606 const bool do_clip_ray_plane = do_clip && !ray_co_is_centered;
607 float ray_co[3], ray_no[3];
616 if (do_clip && (do_clip_ray_plane ==
false)) {
621 if (z_offset > 1.0f) {
631 const float plane[4],
636 const float mval_fl[2] = {
float(mval[0]),
float(mval[1])};
641 const float plane[4],
644 const float plane_fallback[4],
647 float isect_co[3], isect_no[3];
676 const float xy_delta[2],
683 dx = 2.0f * xy_delta[0] * zfac / region->
winx;
684 dy = 2.0f * xy_delta[1] * zfac / region->
winy;
698 r_out[0] = 2.0f * mval[0] / region->
winx - 1.0f;
699 r_out[1] = 2.0f * mval[1] / region->
winy - 1.0f;
717 r_out[0] = 2.0f * (mval[0] / region->
winx) - 1.0f;
718 r_out[1] = 2.0f * (mval[1] / region->
winy) - 1.0f;
733 float r_ray_start[3],
735 const bool do_clip_planes)
738 depsgraph, region, v3d, mval,
nullptr,
nullptr, r_ray_start, r_ray_end);
741 if (do_clip_planes) {
772 const int viewport[4] = {0, 0, region->
winx, region->
winy};
780 const int viewport[4] = {0, 0, region->
winx, region->
winy};
785 const ARegion *region,
float regionx,
float regiony,
float regionz,
float world[3])
788 const int viewport[4] = {0, 0, region->
winx, region->
winy};
789 const float region_co[3] = {regionx, regiony, regionz};
Camera data-block and utility functions.
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
float BKE_screen_view3d_zoom_to_fac(float camzoom)
bool clip_segment_v3_plane_n(const float p1[3], const float p2[3], const float plane_array[][4], int plane_num, float r_p1[3], float r_p2[3])
bool isect_ray_plane_v3(const float ray_origin[3], const float ray_direction[3], const float plane[4], float *r_lambda, bool clip)
bool isect_plane_plane_v3(const float plane_a[4], const float plane_b[4], float r_isect_co[3], float r_isect_no[3]) ATTR_WARN_UNUSED_RESULT
float ray_point_factor_v3(const float p[3], const float ray_origin[3], const float ray_direction[3])
bool isect_ray_plane_v3_factor(const float ray_origin[3], const float ray_direction[3], const float plane_co[3], const float plane_no[3], float *r_lambda)
void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
void mul_project_m4_v3(const float mat[4][4], float vec[3])
void mul_m4_v3(const float M[4][4], float r[3])
void mul_m4_v4(const float mat[4][4], float r[4])
void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float dot_m4_v3_row_z(const float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
MINLINE float mul_project_m4_v3_zfac(const float mat[4][4], const float co[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE float normalize_v3(float n[3])
Object is a sort of wrapper for general info.
void ED_view3d_check_mats_rv3d(RegionView3D *rv3d)
@ V3D_PROJ_TEST_CLIP_NEAR
@ V3D_PROJ_TEST_CLIP_ZERO
bool ED_view3d_clip_range_get(const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, bool use_ortho_factor, float *r_clip_start, float *r_clip_end)
#define V3D_PROJ_TEST_CLIP_DEFAULT
#define V3D_PROJ_TEST_ALL
bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], bool is_local)
void GPU_matrix_project_2fv(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float r_win[2])
bool GPU_matrix_unproject_3fv(const float win[3], const float model_inverted[4][4], const float proj[4][4], const int view[4], float r_world[3])
void GPU_matrix_project_3fv(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float r_win[3])
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between world
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
velocity_obj_prev_buf[] vec4
MatBase< float, 4, 4 > float4x4
MatView< float, 4, 4, 4, 4, 0, 0, alignof(float)> float4x4_view
VecBase< float, 2 > float2
const c_style_mat & ptr() const
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_segment_clipped(const 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)
blender::float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const blender::float4x4 &mat)
void ED_view3d_project_float_v3_m4(const ARegion *region, const float co[3], float r_co[3], const float mat[4][4])
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 r_out[3])
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_float_object(const ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
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_3d_int(const View3D *v3d, const ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3])
float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[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_delta(const ARegion *region, const float xy_delta[2], const float zfac, float r_out[3])
float ED_view3d_calc_depth_for_comparison(const RegionView3D *rv3d, const float co[3])
bool ED_view3d_win_to_ray_clipped(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)
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
bool ED_view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float ray_end[3])
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
void ED_view3d_project_v2(const ARegion *region, const float world[3], float r_region_co[2])
eV3DProjStatus ED_view3d_project_int_object(const ARegion *region, const float co[3], int 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_int_ex(const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], int r_co[2], const eV3DProjTest flag)
blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
bool ED_view3d_unproject_v3(const ARegion *region, float regionx, float regiony, float regionz, float world[3])
void ED_view3d_win_to_3d_with_shift(const View3D *v3d, const ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3])
float ED_view3d_calc_zfac_ex(const RegionView3D *rv3d, const float co[3], bool *r_flip)
void ED_view3d_win_to_origin(const ARegion *region, const float mval[2], float r_out[3])
static void view3d_win_to_ray_segment(const 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])
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
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)
bool ED_view3d_win_to_ray_clipped_ex(Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const float mval[2], const bool do_clip_planes, float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], float r_ray_end[3])
eV3DProjStatus ED_view3d_project_short_object(const ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag)
void ED_view3d_project_v3(const ARegion *region, const float world[3], float r_region_co[3])
eV3DProjStatus ED_view3d_project_base(const ARegion *region, Base *base, float r_co[2])
blender::float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, const blender::float4x4 &obmat)
void ED_view3d_win_to_vector(const ARegion *region, const float mval[2], float r_out[3])
eV3DProjStatus ED_view3d_project_int_global(const ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag)
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)
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])