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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-01-29 23:10:03 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-01-29 23:10:03 +0400
commit77089a3bf20319be87a434750656206449c04dbc (patch)
tree83b7fd34ce9ea4a6fcec20e48dd293a65597fe85 /source/blender/blenkernel/intern/object.c
parent95e153a319b48a3a8d4fcb013b7be24fe1f07af3 (diff)
Fix T38358: Face snapping fails on Orthographic view
Issue is caused by start point of ray used to detect faces under the mouse is set rather far away in ortho 3dviews. The loss of precision on the ray location induced by this can lead to face snapping failures. Solution is to do the raycasting with a temp start point, much closer to the object we check, and add back to the found distance the diff to the real start point once detection is done (as we need all hit distances from all tested objects to be relative to a common point!). Note this commit only addresses the "face snapping on mesh" case, other kind of snapping do not seem to suffer from this issue. Reviewers: brecht, campbellbarton Differential Revision: https://developer.blender.org/D268
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index dc20629b0d0..019885df935 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3131,7 +3131,8 @@ int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc,
* Test a bounding box for ray intersection
* assumes the ray is already local to the boundbox space
*/
-bool BKE_boundbox_ray_hit_check(struct BoundBox *bb, const float ray_start[3], const float ray_normal[3])
+bool BKE_boundbox_ray_hit_check(struct BoundBox *bb, const float ray_start[3], const float ray_normal[3],
+ float *r_lambda)
{
const int triangle_indexes[12][3] = {
{0, 1, 2}, {0, 2, 3},
@@ -3144,13 +3145,18 @@ bool BKE_boundbox_ray_hit_check(struct BoundBox *bb, const float ray_start[3], c
bool result = false;
int i;
- for (i = 0; i < 12 && result == 0; i++) {
+ for (i = 0; i < 12 && (!result || r_lambda); i++) {
float lambda;
int v1, v2, v3;
v1 = triangle_indexes[i][0];
v2 = triangle_indexes[i][1];
v3 = triangle_indexes[i][2];
- result = isect_ray_tri_v3(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL);
+ if (isect_ray_tri_v3(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL) &&
+ (!r_lambda || *r_lambda > lambda))
+ {
+ result = true;
+ *r_lambda = lambda;
+ }
}
return result;