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:
authormano-wii <germano.costa@ig.com.br>2019-06-17 15:16:13 +0300
committermano-wii <germano.costa@ig.com.br>2019-06-17 15:16:13 +0300
commite03b7176877d27f4dd42dd698a85a1f046f9202a (patch)
tree57930d5ffc7eb6c54529a59269a1c23a340c24da /source/blender/editors
parent5e7e49e00d46734281b28a82582e3e3dd37e609c (diff)
Fix T65620: Sculpting brush size jumping.
The PBVHs raycast function calls `isect_ray_tri_epsilon_v3` with epsilon `0.1` which is inaccurate and may result in the problem presented in T65620. The solution is to use `isect_ray_tri_watertight_v3` instead `isect_ray_tri_epsilon_v3`. This can positively affect other areas as well. Reviewers: brecht, campbellbarton Differential Revision: https://developer.blender.org/D5083
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c902b6a0551..5a7fb1abb7b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1730,17 +1730,21 @@ typedef struct SculptDoBrushSmoothGridDataChunk {
typedef struct {
SculptSession *ss;
- const float *ray_start, *ray_normal;
+ const float *ray_start;
bool hit;
float depth;
bool original;
+
+ struct IsectRayPrecalc isect_precalc;
} SculptRaycastData;
typedef struct {
- const float *ray_start, *ray_normal;
+ const float *ray_start;
bool hit;
float depth;
float edge_length;
+
+ struct IsectRayPrecalc isect_precalc;
} SculptDetailRaycastData;
typedef struct {
@@ -4949,7 +4953,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
origco,
use_origco,
srd->ray_start,
- srd->ray_normal,
+ &srd->isect_precalc,
&srd->depth)) {
srd->hit = 1;
*tmin = srd->depth;
@@ -4995,7 +4999,7 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
if (BKE_pbvh_node_get_tmin(node) < *tmin) {
SculptDetailRaycastData *srd = data_v;
if (BKE_pbvh_bmesh_node_raycast_detail(
- node, srd->ray_start, srd->ray_normal, &srd->depth, &srd->edge_length)) {
+ node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) {
srd->hit = 1;
*tmin = srd->depth;
}
@@ -5067,14 +5071,14 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
bool hit = false;
{
- SculptRaycastData srd = {
- .original = original,
- .ss = ob->sculpt,
- .hit = 0,
- .ray_start = ray_start,
- .ray_normal = ray_normal,
- .depth = depth,
- };
+ SculptRaycastData srd;
+ srd.ss = ob->sculpt;
+ srd.ray_start = ray_start;
+ srd.hit = 0;
+ srd.depth = depth;
+ srd.original = original;
+ isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal);
+
BKE_pbvh_raycast(ss->pbvh, sculpt_raycast_cb, &srd, ray_start, ray_normal, srd.original);
if (srd.hit) {
hit = true;
@@ -6372,9 +6376,9 @@ static void sample_detail(bContext *C, int mx, int my)
SculptDetailRaycastData srd;
srd.hit = 0;
srd.ray_start = ray_start;
- srd.ray_normal = ray_normal;
srd.depth = depth;
srd.edge_length = 0.0f;
+ isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal);
BKE_pbvh_raycast(ob->sculpt->pbvh, sculpt_raycast_detail_cb, &srd, ray_start, ray_normal, false);