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:
authorCampbell Barton <ideasman42@gmail.com>2021-06-22 08:54:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-06-22 08:59:15 +0300
commit8af2c87f7e82f7abff8217c6de458a743be91f85 (patch)
tree6091ed4dc4da7e3c47ed5808192d1bb10da6be66 /source/blender/editors/space_view3d
parentcd39e3dec1fd0dd2ede4c0eaa10e4d285fd78b64 (diff)
3D View: adjust order of planes for occlusion check
Move far plane last since it's the least likely to intersect edges.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 5e0101e4160..2a381bb96cb 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -51,13 +51,13 @@
#include "ED_view3d.h"
/* -------------------------------------------------------------------- */
-/** \name Clipping Plane Utility
- *
- * Calculate clipping planes to use when #V3D_PROJ_TEST_CLIP_CONTENT is enabled.
+/** \name Internal Clipping Utilities
* \{ */
/**
- * Calculate clip planes from the viewpoint using `clip_flag`
+ * Calculate clipping planes to use when #V3D_PROJ_TEST_CLIP_CONTENT is enabled.
+ *
+ * Planes are selected from the viewpoint using `clip_flag`
* to detect which planes should be applied (maximum 6).
*
* \return The number of planes written into `planes`.
@@ -67,25 +67,32 @@ static int content_planes_from_clip_flag(const ARegion *region,
const eV3DProjTest clip_flag,
float planes[6][4])
{
+ BLI_assert(clip_flag & V3D_PROJ_TEST_CLIP_CONTENT);
+
float *clip_xmin = NULL, *clip_xmax = NULL;
float *clip_ymin = NULL, *clip_ymax = NULL;
float *clip_zmin = NULL, *clip_zmax = NULL;
int planes_len = 0;
+ /* The order of `planes` has been selected based on the likelihood of points being fully
+ * outside the plane to increase the chance of an early exit in #clip_segment_v3_plane_n.
+ * With "near" being most likely and "far" being unlikely.
+ *
+ * Otherwise the order of axes in `planes` isn't significant. */
+
if (clip_flag & V3D_PROJ_TEST_CLIP_NEAR) {
clip_zmin = planes[planes_len++];
}
- if (clip_flag & V3D_PROJ_TEST_CLIP_FAR) {
- clip_zmax = planes[planes_len++];
- }
if (clip_flag & V3D_PROJ_TEST_CLIP_WIN) {
- /* The order in `planes` doesn't matter as all planes are looped over. */
clip_xmin = planes[planes_len++];
clip_xmax = planes[planes_len++];
clip_ymin = planes[planes_len++];
clip_ymax = planes[planes_len++];
}
+ if (clip_flag & V3D_PROJ_TEST_CLIP_FAR) {
+ clip_zmax = planes[planes_len++];
+ }
BLI_assert(planes_len <= 6);
if (planes_len != 0) {
@@ -208,14 +215,14 @@ static bool view3d_project_segment_to_screen_with_clip_tag(const ARegion *region
* \{ */
typedef struct foreachScreenObjectVert_userData {
- void (*func)(void *userData, MVert *mv, const float screen_co_b[2], int index);
+ void (*func)(void *userData, MVert *mv, const float screen_co[2], int index);
void *userData;
ViewContext vc;
eV3DProjTest clip_flag;
} foreachScreenObjectVert_userData;
typedef struct foreachScreenVert_userData {
- void (*func)(void *userData, BMVert *eve, const float screen_co_b[2], int index);
+ void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index);
void *userData;
ViewContext vc;
eV3DProjTest clip_flag;