Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_project.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | void ED_view3d_project_float_v3_m4(const ARegion *region, | ||||
| else { | else { | ||||
| zero_v3(r_co); | zero_v3(r_co); | ||||
| } | } | ||||
| } | } | ||||
| /* Clipping Projection Functions | /* Clipping Projection Functions | ||||
| * ***************************** */ | * ***************************** */ | ||||
| eV3DProjStatus ED_view3d_project_base(const struct ARegion *region, struct Base *base) | eV3DProjStatus ED_view3d_project_base(const struct ARegion *region, | ||||
| struct Base *base, | |||||
| short r_co[2]) | |||||
| { | { | ||||
| eV3DProjStatus ret = ED_view3d_project_short_global( | eV3DProjStatus ret = ED_view3d_project_short_global( | ||||
| region, base->object->obmat[3], &base->sx, V3D_PROJ_TEST_CLIP_DEFAULT); | region, base->object->obmat[3], r_co, V3D_PROJ_TEST_CLIP_DEFAULT); | ||||
| if (ret != V3D_PROJ_RET_OK) { | if (ret != V3D_PROJ_RET_OK) { | ||||
| base->sx = IS_CLIPPED; | r_co[0] = IS_CLIPPED; | ||||
| base->sy = 0; | r_co[1] = 0; | ||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| /* perspmat is typically... | /* perspmat is typically... | ||||
| * - 'rv3d->perspmat', is_local == false | * - 'rv3d->perspmat', is_local == false | ||||
| * - 'rv3d->persmatob', is_local == true | * - 'rv3d->persmatob', is_local == true | ||||
| ▲ Show 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| bool ED_view3d_win_to_3d_on_plane(const ARegion *region, | bool ED_view3d_win_to_3d_on_plane(const ARegion *region, | ||||
| const float plane[4], | const float plane[4], | ||||
| const float mval[2], | const float mval[2], | ||||
| const bool do_clip, | const bool do_clip, | ||||
| float r_out[3]) | float r_out[3]) | ||||
| { | { | ||||
| const RegionView3D *rv3d = region->regiondata; | |||||
| const bool ray_co_is_centered = rv3d->is_persp == false && rv3d->persp != RV3D_CAMOB; | |||||
| const bool do_clip_ray_plane = do_clip && !ray_co_is_centered; | |||||
| float ray_co[3], ray_no[3]; | float ray_co[3], ray_no[3]; | ||||
| ED_view3d_win_to_origin(region, mval, ray_co); | ED_view3d_win_to_origin(region, mval, ray_co); | ||||
| ED_view3d_win_to_vector(region, mval, ray_no); | ED_view3d_win_to_vector(region, mval, ray_no); | ||||
| float lambda; | float lambda; | ||||
| if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, do_clip)) { | if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, do_clip_ray_plane)) { | ||||
| madd_v3_v3v3fl(r_out, ray_co, ray_no, lambda); | madd_v3_v3v3fl(r_out, ray_co, ray_no, lambda); | ||||
| /* Handle clipping with an orthographic view differently, | |||||
| * check if the resulting point is behind the view instead of clipping the ray. */ | |||||
| if (do_clip && (do_clip_ray_plane == false)) { | |||||
| /* The offset is unit length where over 1.0 is beyond the views clip-plane (near and far) | |||||
| * as non-camera orthographic views only use far distance in both directions. | |||||
| * Multiply `r_out` by `persmat` (with translation), and get it's Z value. */ | |||||
| const float z_offset = fabsf(dot_m4_v3_row_z(rv3d->persmat, r_out) + rv3d->persmat[3][2]); | |||||
| if (z_offset > 1.0f) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| bool ED_view3d_win_to_3d_on_plane_int(const ARegion *region, | bool ED_view3d_win_to_3d_on_plane_int(const ARegion *region, | ||||
| const float plane[4], | const float plane[4], | ||||
| const int mval[2], | const int mval[2], | ||||
| ▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines | |||||