[Bf-blender-cvs] [8af2c87f7e8] master: 3D View: adjust order of planes for occlusion check
Campbell Barton
noreply at git.blender.org
Tue Jun 22 08:00:11 CEST 2021
Commit: 8af2c87f7e82f7abff8217c6de458a743be91f85
Author: Campbell Barton
Date: Tue Jun 22 15:54:11 2021 +1000
Branches: master
https://developer.blender.org/rB8af2c87f7e82f7abff8217c6de458a743be91f85
3D View: adjust order of planes for occlusion check
Move far plane last since it's the least likely to intersect edges.
===================================================================
M source/blender/editors/space_view3d/view3d_iterators.c
===================================================================
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;
More information about the Bf-blender-cvs
mailing list