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:
authorAntony Riakiotakis <kalast@gmail.com>2013-12-18 20:34:02 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-12-18 20:34:02 +0400
commit9efef3c2515bef9cd2928834ab7e29cf32c20593 (patch)
tree751a028d8ba77fcb14838d15c146352a9ccba9b4 /source/blender/editors/sculpt_paint
parent355c699dc6b6e95ef9305100a62efa7e70ae93ec (diff)
Fix T37177, sculpting can act on opposite side of mesh in orthographic camera.
Summary: Issue here most probably is that the start point in ray-casting is too far away from the mesh. As a result the triangle intersection code can sometimes miss the ray intersection. To solve this, we project the ray segment to the boundary of the root node. Reviewers: brecht, sergey, campbellbarton Reviewed By: brecht Maniphest Tasks: T37177 Differential Revision: http://developer.blender.org/D115
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 74776d65a57..74afda731ea 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4290,12 +4290,16 @@ int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
float ray_start[3], ray_end[3], ray_normal[3], dist;
float obimat[4][4];
SculptRaycastData srd;
+ bool original;
+ RegionView3D *rv3d;
view3d_set_viewcontext(C, &vc);
+ rv3d = vc.ar->regiondata;
ob = vc.obact;
ss = ob->sculpt;
cache = ss->cache;
+ original = (cache) ? cache->original : 0;
sculpt_stroke_modifiers_check(C, ob);
@@ -4309,15 +4313,24 @@ int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
sub_v3_v3v3(ray_normal, ray_end, ray_start);
dist = normalize_v3(ray_normal);
+ if (!rv3d->is_persp) {
+ BKE_pbvh_raycast_project_ray_root(ss->pbvh, srd.original, ray_start, ray_end, ray_normal);
+
+ /* recalculate the normal */
+ sub_v3_v3v3(ray_normal, ray_end, ray_start);
+ dist = normalize_v3(ray_normal);
+ }
+
+ srd.original = original;
srd.ss = vc.obact->sculpt;
+ srd.hit = 0;
srd.ray_start = ray_start;
srd.ray_normal = ray_normal;
srd.dist = dist;
- srd.hit = 0;
- srd.original = (cache) ? cache->original : 0;
+
BKE_pbvh_raycast(ss->pbvh, sculpt_raycast_cb, &srd,
ray_start, ray_normal, srd.original);
-
+
copy_v3_v3(out, ray_normal);
mul_v3_fl(out, srd.dist);
add_v3_v3(out, ray_start);