Snap system: Adds support to Clip Planes and uses a clip plane to simulate occlusion
This patch adds support for clip_planes (ie ignore what is behind a face)...
The idea is to first execute a raycast to get the polygon to which the mouse cursor points.
Then a snap test is done on the vertices or edges of the polygon.
Then with the normal and location obtained in raycast a new clip_plane is created and the snap over the whole scene is processed ignoring the elements behind the clip_plane.
Here 2 gif of how the previous patch would work on blender2.79:
{F497176}
{F497177}
Reviewers: mont29, campbellbarton
Reviewed By: campbellbarton
Subscribers: bliblubli
Tags: #bf_blender_2.8
Differential Revision: https://developer.blender.org/D2527
This commit is contained in:
@@ -107,6 +107,7 @@ typedef void (*BVHTree_RangeQuery)(void *userdata, int index, const float co[3],
|
||||
typedef void (*BVHTree_NearestProjectedCallback)(
|
||||
void *userdata, int index,
|
||||
const struct DistProjectedAABBPrecalc *precalc,
|
||||
const float (*clip_plane)[4], const int clip_plane_len,
|
||||
BVHTreeNearest *nearest);
|
||||
|
||||
|
||||
|
||||
@@ -2040,7 +2040,10 @@ static void bvhtree_nearest_projected_dfs_recursive(
|
||||
{
|
||||
if (node->totnode == 0) {
|
||||
if (data->callback) {
|
||||
data->callback(data->userdata, node->index, &data->precalc, &data->nearest);
|
||||
data->callback(
|
||||
data->userdata, node->index, &data->precalc,
|
||||
NULL, 0,
|
||||
&data->nearest);
|
||||
}
|
||||
else {
|
||||
data->nearest.index = node->index;
|
||||
@@ -2089,7 +2092,10 @@ static void bvhtree_nearest_projected_with_clipplane_test_dfs_recursive(
|
||||
{
|
||||
if (node->totnode == 0) {
|
||||
if (data->callback) {
|
||||
data->callback(data->userdata, node->index, &data->precalc, &data->nearest);
|
||||
data->callback(
|
||||
data->userdata, node->index, &data->precalc,
|
||||
data->clip_plane, data->clip_plane_len,
|
||||
&data->nearest);
|
||||
}
|
||||
else {
|
||||
data->nearest.index = node->index;
|
||||
|
||||
@@ -1201,6 +1201,7 @@ bool snapObjectsTransform(
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = t->tsnap.modeSelect,
|
||||
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
|
||||
.use_occlusion_test = t->scene->toolsettings->snap_mode != SCE_SNAP_MODE_FACE,
|
||||
},
|
||||
mval, dist_px, NULL,
|
||||
r_loc, r_no, NULL,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user