Merge branch 'blender-v4.1-release'
This commit is contained in:
@@ -579,6 +579,12 @@ bool isect_ray_ray_v3(const float ray_origin_a[3],
|
||||
*
|
||||
* \note #line_plane_factor_v3() shares logic.
|
||||
*/
|
||||
bool isect_ray_plane_v3_factor(const float ray_origin[3],
|
||||
const float ray_direction[3],
|
||||
const float plane_co[3],
|
||||
const float plane_no[3],
|
||||
float *r_lambda);
|
||||
|
||||
bool isect_ray_plane_v3(const float ray_origin[3],
|
||||
const float ray_direction[3],
|
||||
const float plane[4],
|
||||
|
||||
@@ -1697,22 +1697,33 @@ bool isect_ray_tri_v3(const float ray_origin[3],
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isect_ray_plane_v3_factor(const float ray_origin[3],
|
||||
const float ray_direction[3],
|
||||
const float plane_co[3],
|
||||
const float plane_no[3],
|
||||
float *r_lambda)
|
||||
{
|
||||
float h[3];
|
||||
float dot = dot_v3v3(plane_no, ray_direction);
|
||||
if (dot == 0.0f) {
|
||||
return false;
|
||||
}
|
||||
sub_v3_v3v3(h, ray_origin, plane_co);
|
||||
*r_lambda = -dot_v3v3(plane_no, h) / dot;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isect_ray_plane_v3(const float ray_origin[3],
|
||||
const float ray_direction[3],
|
||||
const float plane[4],
|
||||
float *r_lambda,
|
||||
const bool clip)
|
||||
{
|
||||
float h[3], plane_co[3];
|
||||
float dot;
|
||||
|
||||
dot = dot_v3v3(plane, ray_direction);
|
||||
if (dot == 0.0f) {
|
||||
float plane_co[3], plane_no[3];
|
||||
plane_to_point_vector_v3(plane, plane_co, plane_no);
|
||||
if (!isect_ray_plane_v3_factor(ray_origin, ray_direction, plane_co, plane_no, r_lambda)) {
|
||||
return false;
|
||||
}
|
||||
mul_v3_v3fl(plane_co, plane, (-plane[3] / len_squared_v3(plane)));
|
||||
sub_v3_v3v3(h, ray_origin, plane_co);
|
||||
*r_lambda = -dot_v3v3(plane, h) / dot;
|
||||
if (clip && (*r_lambda < 0.0f)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,9 @@ static void constraint_snap_plane_to_edge(const TransInfo *t, const float plane[
|
||||
const float *edge_snap_point = t->tsnap.snap_target;
|
||||
const float *edge_dir = t->tsnap.snapNormal;
|
||||
bool is_aligned = fabsf(dot_v3v3(edge_dir, plane)) < CONSTRAIN_EPSILON;
|
||||
if (!is_aligned && isect_ray_plane_v3(edge_snap_point, edge_dir, plane, &lambda, false)) {
|
||||
if (!is_aligned &&
|
||||
isect_ray_plane_v3_factor(edge_snap_point, edge_dir, t->tsnap.snap_source, plane, &lambda))
|
||||
{
|
||||
madd_v3_v3v3fl(r_out, edge_snap_point, edge_dir, lambda);
|
||||
sub_v3_v3(r_out, t->tsnap.snap_source);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user