Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-12-17 16:01:32 +0300
committerSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-12-17 16:01:32 +0300
commitdbc41b30f88b96f7d8c6e995b17f5930eb55cc77 (patch)
treec6c495328443ea3621e5df2ef483b0e0dd504496 /source/blender/editors/space_view3d/view3d_utils.c
parent99a2af76d10e05a18987be5d554ada197b1ca086 (diff)
parent7c9e4099854a4fc8eab4db97173c1aacd25f9e08 (diff)
Merge branch 'master' into soc-2021-uv-edge-select-supportsoc-2021-uv-edge-select-support
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c161
1 files changed, 5 insertions, 156 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index d6a1cd930fc..8b75ce63cde 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -122,9 +122,6 @@ void ED_view3d_dist_range_get(const View3D *v3d, float r_dist_range[2])
r_dist_range[1] = v3d->clip_end * 10.0f;
}
-/**
- * \note copies logic of #ED_view3d_viewplane_get(), keep in sync.
- */
bool ED_view3d_clip_range_get(Depsgraph *depsgraph,
const View3D *v3d,
const RegionView3D *rv3d,
@@ -191,10 +188,6 @@ bool ED_view3d_viewplane_get(Depsgraph *depsgraph,
/** \name View State/Context Utilities
* \{ */
-/**
- * Use this call when executing an operator,
- * event system doesn't set for each event the OpenGL drawing context.
- */
void view3d_operator_needs_opengl(const bContext *C)
{
wmWindow *win = CTX_wm_window(C);
@@ -218,9 +211,6 @@ void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *region)
}
}
-/**
- * Use instead of: `GPU_polygon_offset(rv3d->dist, ...)` see bug T37727.
- */
void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist)
{
if (rv3d->rflag & RV3D_ZOFFSET_DISABLED) {
@@ -339,18 +329,6 @@ static void points_in_planes_minmax_fn(
minmax_v3v3_v3(user_data->min, user_data->max, co);
}
-/**
- * Clamp min/max by the viewport clipping.
- *
- * \note This is an approximation, with the limitation that the bounding box from the (mix, max)
- * calculation might not have any geometry inside the clipped region.
- * Performing a clipping test on each vertex would work well enough for most cases,
- * although it's not perfect either as edges/faces may intersect the clipping without having any
- * of their vertices inside it.
- * A more accurate result would be quite involved.
- *
- * \return True when the arguments were clamped.
- */
bool ED_view3d_clipping_clamp_minmax(const RegionView3D *rv3d, float min[3], float max[3])
{
/* 6 planes for the cube, 4..6 for the current view clipping planes. */
@@ -481,9 +459,6 @@ bool ED_view3d_offset_lock_check(const View3D *v3d, const RegionView3D *rv3d)
return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_center_cursor || v3d->ob_center);
}
-/**
- * Use to store the last view, before entering camera view.
- */
void ED_view3d_lastview_store(RegionView3D *rv3d)
{
copy_qt_qt(rv3d->lviewquat, rv3d->viewquat);
@@ -503,13 +478,6 @@ void ED_view3d_lock_clear(View3D *v3d)
v3d->flag2 &= ~V3D_LOCK_CAMERA;
}
-/**
- * For viewport operators that exit camera perspective.
- *
- * \note This differs from simply setting `rv3d->persp = persp` because it
- * sets the `ofs` and `dist` values of the viewport so it matches the camera,
- * otherwise switching out of camera view may jump to a different part of the scene.
- */
void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph,
View3D *v3d,
RegionView3D *rv3d,
@@ -528,12 +496,6 @@ void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph,
rv3d->persp = persp;
}
}
-/**
- * Action to take when rotating the view,
- * handle auto-perspective and logic for switching out of views.
- *
- * shared with NDOF.
- */
bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *region)
{
RegionView3D *rv3d = region->regiondata;
@@ -569,19 +531,12 @@ bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *re
* Lock the camera to the 3D Viewport, allowing view manipulation to transform the camera.
* \{ */
-/**
- * \return true when the 3D Viewport is locked to its camera.
- */
bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d)
{
return ((v3d->camera) && (!ID_IS_LINKED(v3d->camera)) && (v3d->flag2 & V3D_LOCK_CAMERA) &&
(rv3d->persp == RV3D_CAMOB));
}
-/**
- * Apply the camera object transformation to the 3D Viewport.
- * (needed so we can use regular 3D Viewport manipulation operators, that sync back to the camera).
- */
void ED_view3d_camera_lock_init_ex(const Depsgraph *depsgraph,
View3D *v3d,
RegionView3D *rv3d,
@@ -603,11 +558,6 @@ void ED_view3d_camera_lock_init(const Depsgraph *depsgraph, View3D *v3d, RegionV
ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, true);
}
-/**
- * Apply the 3D Viewport transformation back to the camera object.
- *
- * \return true if the camera is moved.
- */
bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d)
{
if (ED_view3d_camera_lock_check(v3d, rv3d)) {
@@ -701,12 +651,6 @@ bool ED_view3d_camera_autokey(const Scene *scene,
return false;
}
-/**
- * Call after modifying a locked view.
- *
- * \note Not every view edit currently auto-keys (num-pad for eg),
- * this is complicated because of smooth-view.
- */
bool ED_view3d_camera_lock_autokey(View3D *v3d,
RegionView3D *rv3d,
struct bContext *C,
@@ -885,7 +829,6 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_
}
}
-/* sync center/zoom view of region to others, for view transforms */
void view3d_boxview_sync(ScrArea *area, ARegion *region)
{
RegionView3D *rv3d = region->regiondata;
@@ -910,7 +853,6 @@ void view3d_boxview_sync(ScrArea *area, ARegion *region)
}
}
-/* for home, center etc */
void view3d_boxview_copy(ScrArea *area, ARegion *region)
{
RegionView3D *rv3d = region->regiondata;
@@ -935,7 +877,6 @@ void view3d_boxview_copy(ScrArea *area, ARegion *region)
}
}
-/* 'clip' is used to know if our clip setting has changed */
void ED_view3d_quadview_update(ScrArea *area, ARegion *region, bool do_clip)
{
ARegion *region_sync = NULL;
@@ -1023,14 +964,6 @@ static float view_autodist_depth_margin(ARegion *region, const int mval[2], int
return depth_close;
}
-/**
- * Get the world-space 3d location from a screen-space 2d point.
- * TODO: Implement #alphaoverride. We don't want to zoom into billboards.
- *
- * \param mval: Input screen-space pixel location.
- * \param mouse_worldloc: Output world-space location.
- * \param fallback_depth_pt: Use this points depth when no depth can be found.
- */
bool ED_view3d_autodist(Depsgraph *depsgraph,
ARegion *region,
View3D *v3d,
@@ -1069,7 +1002,6 @@ bool ED_view3d_autodist(Depsgraph *depsgraph,
return false;
}
-/* no 4x4 sampling, run #ED_view3d_depth_override first */
bool ED_view3d_autodist_simple(ARegion *region,
const int mval[2],
float mouse_worldloc[3],
@@ -1127,7 +1059,7 @@ bool ED_view3d_depth_read_cached_seg(
data.vd = vd;
data.margin = margin;
- data.depth = FLT_MAX;
+ data.depth = 1.0f;
copy_v2_v2_int(p1, mval_sta);
copy_v2_v2_int(p2, mval_end);
@@ -1136,7 +1068,7 @@ bool ED_view3d_depth_read_cached_seg(
*depth = data.depth;
- return (*depth != FLT_MAX);
+ return (*depth != 1.0f);
}
/** \} */
@@ -1157,31 +1089,6 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius)
return radius / (DEFAULT_SENSOR_WIDTH / lens);
}
-/**
- * Return a new RegionView3D.dist value to fit the \a radius.
- *
- * \note Depth isn't taken into account, this will fit a flat plane exactly,
- * but points towards the view (with a perspective projection),
- * may be within the radius but outside the view. eg:
- *
- * <pre>
- * +
- * pt --> + /^ radius
- * / |
- * / |
- * view + +
- * \ |
- * \ |
- * \|
- * +
- * </pre>
- *
- * \param region: Can be NULL if \a use_aspect is false.
- * \param persp: Allow the caller to tell what kind of perspective to use (ortho/view/camera)
- * \param use_aspect: Increase the distance to account for non 1:1 view aspect.
- * \param radius: The radius will be fitted exactly,
- * typically pre-scaled by a margin (#VIEW3D_MARGIN).
- */
float ED_view3d_radius_to_dist(const View3D *v3d,
const ARegion *region,
const struct Depsgraph *depsgraph,
@@ -1262,18 +1169,6 @@ float ED_view3d_radius_to_dist(const View3D *v3d,
/** \name View Distance Utilities
* \{ */
-/**
- * This function solves the problem of having to switch between camera and non-camera views.
- *
- * When viewing from the perspective of \a mat, and having the view center \a ofs,
- * this calculates a distance from \a ofs to the matrix \a mat.
- * Using \a fallback_dist when the distance would be too small.
- *
- * \param mat: A matrix use for the view-point (typically the camera objects matrix).
- * \param ofs: Orbit center (negated), matching #RegionView3D.ofs, which is typically passed in.
- * \param fallback_dist: The distance to use if the object is too near or in front of \a ofs.
- * \returns A newly calculated distance or the fallback.
- */
float ED_view3d_offset_distance(const float mat[4][4],
const float ofs[3],
const float fallback_dist)
@@ -1295,11 +1190,6 @@ float ED_view3d_offset_distance(const float mat[4][4],
return dist;
}
-/**
- * Set the dist without moving the view (compensate with #RegionView3D.ofs)
- *
- * \note take care that viewinv is up to date, #ED_view3d_update_viewmat first.
- */
void ED_view3d_distance_set(RegionView3D *rv3d, const float dist)
{
float viewinv[4];
@@ -1320,13 +1210,6 @@ void ED_view3d_distance_set(RegionView3D *rv3d, const float dist)
rv3d->dist = dist;
}
-/**
- * Change the distance & offset to match the depth of \a dist_co along the view axis.
- *
- * \param dist_co: A world-space location to use for the new depth.
- * \param dist_min: Resulting distances below this will be ignored.
- * \return Success if the distance was set.
- */
bool ED_view3d_distance_set_from_location(RegionView3D *rv3d,
const float dist_co[3],
const float dist_min)
@@ -1485,14 +1368,6 @@ bool ED_view3d_lock(RegionView3D *rv3d)
/** \name View Transform Utilities
* \{ */
-/**
- * Set the view transformation from a 4x4 matrix.
- *
- * \param mat: The view 4x4 transformation matrix to assign.
- * \param ofs: The view offset, normally from RegionView3D.ofs.
- * \param quat: The view rotation, quaternion normally from RegionView3D.viewquat.
- * \param dist: The view distance from ofs, normally from RegionView3D.dist.
- */
void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const float *dist)
{
float nmat[3][3];
@@ -1519,14 +1394,6 @@ void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const
}
}
-/**
- * Calculate the view transformation matrix from RegionView3D input.
- * The resulting matrix is equivalent to RegionView3D.viewinv
- * \param mat: The view 4x4 transformation matrix to calculate.
- * \param ofs: The view offset, normally from RegionView3D.ofs.
- * \param quat: The view rotation, quaternion normally from RegionView3D.viewquat.
- * \param dist: The view distance from ofs, normally from RegionView3D.dist.
- */
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist)
{
const float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]};
@@ -1537,14 +1404,6 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c
sub_v3_v3v3(mat[3], dvec, ofs);
}
-/**
- * Set the RegionView3D members from an objects transformation and optionally lens.
- * \param ob: The object to set the view to.
- * \param ofs: The view offset to be set, normally from RegionView3D.ofs.
- * \param quat: The view rotation to be set, quaternion normally from RegionView3D.viewquat.
- * \param dist: The view distance from ofs to be set, normally from RegionView3D.dist.
- * \param lens: The view lens angle set for cameras and lights, normally from View3D.lens.
- */
void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
{
ED_view3d_from_m4(ob->obmat, ofs, quat, dist);
@@ -1558,15 +1417,6 @@ void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float
}
}
-/**
- * Set the object transformation from RegionView3D members.
- * \param depsgraph: The depsgraph to get the evaluated object parent
- * for the transformation calculation.
- * \param ob: The object which has the transformation assigned.
- * \param ofs: The view offset, normally from RegionView3D.ofs.
- * \param quat: The view rotation, quaternion normally from RegionView3D.viewquat.
- * \param dist: The view distance from ofs, normally from RegionView3D.dist.
- */
void ED_view3d_to_object(const Depsgraph *depsgraph,
Object *ob,
const float ofs[3],
@@ -1647,6 +1497,9 @@ bool ED_view3d_depth_read_cached(const ViewDepths *vd,
int margin,
float *r_depth)
{
+ BLI_assert(1.0 <= vd->depth_range[1]);
+ *r_depth = 1.0f;
+
if (!vd || !vd->depths) {
return false;
}
@@ -1676,15 +1529,11 @@ bool ED_view3d_depth_read_cached(const ViewDepths *vd,
depth = vd->depths[y * vd->w + x];
}
- BLI_assert(1.0 <= vd->depth_range[1]);
if (depth != 1.0f) {
*r_depth = depth;
return true;
}
- /* Grease-pencil and annotations also need the returned depth value to be high
- * so the caller can detect it's invalid. */
- *r_depth = FLT_MAX;
return false;
}