new math utility function isect_plane_plane_v3
This commit is contained in:
@@ -60,7 +60,7 @@ float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]);
|
||||
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]);
|
||||
void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2]);
|
||||
|
||||
float dist_to_plane_v3(const float p[2], const float plane_co[3], const float plane_no[2]);
|
||||
float dist_to_plane_v3(const float p[3], const float plane_co[3], const float plane_no[3]);
|
||||
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
|
||||
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
|
||||
float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);
|
||||
@@ -92,9 +92,11 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[
|
||||
* */
|
||||
|
||||
int isect_line_line_v3(const float v1[3], const float v2[3],
|
||||
const float v3[3], const float v4[3], float i1[3], float i2[3]);
|
||||
const float v3[3], const float v4[3],
|
||||
float i1[3], float i2[3]);
|
||||
int isect_line_line_strict_v3(const float v1[3], const float v2[3],
|
||||
const float v3[3], const float v4[3], float vi[3], float *lambda);
|
||||
const float v3[3], const float v4[3],
|
||||
float vi[3], float *lambda);
|
||||
|
||||
/*if clip is nonzero, will only return true if lambda is >= 0.0
|
||||
(i.e. intersection point is along positive d)*/
|
||||
@@ -113,6 +115,21 @@ int isect_ray_plane_v3(float p1[3], float d[3], float v0[3],
|
||||
int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3],
|
||||
const float plane_co[3], const float plane_no[3], const short no_flip);
|
||||
|
||||
/**
|
||||
* Intersect two planes, return a point on the intersection and a vector
|
||||
* that runs on the direction of the intersection.
|
||||
* Return error code is the same as 'isect_line_line_v3'.
|
||||
* @param r_isect_co The resulting intersection point.
|
||||
* @param r_isect_no The resulting vector of the intersection.
|
||||
* @param plane_a_co The point on the first plane.
|
||||
* @param plane_a_no The normal of the first plane.
|
||||
* @param plane_b_co The point on the second plane.
|
||||
* @param plane_b_no The normal of the second plane.
|
||||
*/
|
||||
int isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
|
||||
const float plane_a_co[3], const float plane_a_no[3],
|
||||
const float plane_b_co[3], const float plane_b_no[3]);
|
||||
|
||||
/* line/ray triangle */
|
||||
int isect_line_tri_v3(const float p1[3], const float p2[3],
|
||||
const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]);
|
||||
|
@@ -238,7 +238,7 @@ void closest_to_line_segment_v3(float closest[3], const float v1[3], const float
|
||||
}
|
||||
|
||||
/* signed distance from the point to the plane in 3D */
|
||||
float dist_to_plane_v3(const float p[2], const float plane_co[3], const float plane_no[2])
|
||||
float dist_to_plane_v3(const float p[3], const float plane_co[3], const float plane_no[3])
|
||||
{
|
||||
float plane_no_unit[3];
|
||||
float plane_co_other[3];
|
||||
@@ -833,6 +833,27 @@ int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], cons
|
||||
}
|
||||
}
|
||||
|
||||
int isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
|
||||
const float plane_a_co[3], const float plane_a_no[3],
|
||||
const float plane_b_co[3], const float plane_b_no[3])
|
||||
{
|
||||
float p1_co_other[3], p2_co_other[3];
|
||||
float isect_co_dummy[3];
|
||||
|
||||
cross_v3_v3v3(r_isect_no, plane_a_no, plane_b_no);
|
||||
cross_v3_v3v3(p1_co_other, plane_a_no, r_isect_no);
|
||||
cross_v3_v3v3(p2_co_other, plane_b_no, r_isect_no);
|
||||
|
||||
add_v3_v3(p1_co_other, plane_a_co);
|
||||
add_v3_v3(p2_co_other, plane_b_co);
|
||||
|
||||
/* we could use either ix_1, ix_2 - doesnt matter in this case */
|
||||
return isect_line_line_v3(plane_a_co, p1_co_other,
|
||||
plane_b_co, p2_co_other,
|
||||
r_isect_co, isect_co_dummy);
|
||||
}
|
||||
|
||||
|
||||
/* Adapted from the paper by Kasper Fauerby */
|
||||
/* "Improved Collision detection and Response" */
|
||||
static int getLowestRoot(const float a, const float b, const float c, const float maxR, float *root)
|
||||
|
@@ -181,19 +181,19 @@ MINLINE void add_v4_fl(float r[4], float f)
|
||||
r[3] += f;
|
||||
}
|
||||
|
||||
MINLINE void add_v2_v2(float *r, const float *a)
|
||||
MINLINE void add_v2_v2(float r[2], const float a[2])
|
||||
{
|
||||
r[0] += a[0];
|
||||
r[1] += a[1];
|
||||
}
|
||||
|
||||
MINLINE void add_v2_v2v2(float *r, const float *a, const float *b)
|
||||
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
|
||||
{
|
||||
r[0]= a[0] + b[0];
|
||||
r[1]= a[1] + b[1];
|
||||
}
|
||||
|
||||
MINLINE void add_v3_v3(float *r, const float *a)
|
||||
MINLINE void add_v3_v3(float r[3], const float a[3])
|
||||
{
|
||||
r[0] += a[0];
|
||||
r[1] += a[1];
|
||||
|
@@ -695,8 +695,8 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value)
|
||||
|
||||
omd->chop_amount = value;
|
||||
|
||||
if ((old_value == 0.0 && value > 0.0) ||
|
||||
(old_value > 0.0 && value == 0.0))
|
||||
if ((old_value == 0.0f && value > 0.0f) ||
|
||||
(old_value > 0.0f && value == 0.0f))
|
||||
{
|
||||
omd->refresh |= MOD_OCEAN_REFRESH_RESET;
|
||||
omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE;
|
||||
|
@@ -1213,6 +1213,7 @@ static PyMethodDef M_Geometry_methods[]= {
|
||||
{"intersect_line_line", (PyCFunction) M_Geometry_intersect_line_line, METH_VARARGS, M_Geometry_intersect_line_line_doc},
|
||||
{"intersect_line_line_2d", (PyCFunction) M_Geometry_intersect_line_line_2d, METH_VARARGS, M_Geometry_intersect_line_line_2d_doc},
|
||||
{"intersect_line_plane", (PyCFunction) M_Geometry_intersect_line_plane, METH_VARARGS, M_Geometry_intersect_line_plane_doc},
|
||||
/* TODO: isect_plane_plane_v3 --> intersect_plane_plane */
|
||||
{"intersect_line_sphere", (PyCFunction) M_Geometry_intersect_line_sphere, METH_VARARGS, M_Geometry_intersect_line_sphere_doc},
|
||||
{"intersect_line_sphere_2d", (PyCFunction) M_Geometry_intersect_line_sphere_2d, METH_VARARGS, M_Geometry_intersect_line_sphere_2d_doc},
|
||||
{"distance_point_to_plane", (PyCFunction) M_Geometry_distance_point_to_plane, METH_VARARGS, M_Geometry_distance_point_to_plane_doc},
|
||||
|
Reference in New Issue
Block a user