forked from bartvdbraak/blender
add inline function mul_project_m4_v3_zfac() to get the z-depth value from a vector & mat4x4
This commit is contained in:
parent
85f15bb0ed
commit
2433404e4b
@ -108,6 +108,7 @@ MINLINE void mul_v3_v3(float r[3], const float a[3]);
|
|||||||
MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
||||||
MINLINE void mul_v4_fl(float r[4], float f);
|
MINLINE void mul_v4_fl(float r[4], float f);
|
||||||
MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
|
MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
|
||||||
|
MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]);
|
||||||
|
|
||||||
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
|
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
|
||||||
MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
||||||
|
@ -367,9 +367,7 @@ void mul_mat3_m4_v3(float mat[4][4], float vec[3])
|
|||||||
|
|
||||||
void mul_project_m4_v3(float mat[4][4], float vec[3])
|
void mul_project_m4_v3(float mat[4][4], float vec[3])
|
||||||
{
|
{
|
||||||
const float w = (mat[0][3] * vec[0]) +
|
const float w = mul_project_m4_v3_zfac(mat, vec);
|
||||||
(mat[1][3] * vec[1]) +
|
|
||||||
(mat[2][3] * vec[2]) + mat[3][3];
|
|
||||||
mul_m4_v3(mat, vec);
|
mul_m4_v3(mat, vec);
|
||||||
|
|
||||||
vec[0] /= w;
|
vec[0] /= w;
|
||||||
|
@ -398,6 +398,15 @@ MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
|
|||||||
r[3] = a[3] * f;
|
r[3] = a[3] * f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* note: could add a matrix inline */
|
||||||
|
MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3])
|
||||||
|
{
|
||||||
|
return (mat[0][3] * co[0]) +
|
||||||
|
(mat[1][3] * co[1]) +
|
||||||
|
(mat[2][3] * co[2]) + mat[3][3];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
|
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
|
||||||
{
|
{
|
||||||
r[0] += a[0] * f;
|
r[0] += a[0] * f;
|
||||||
|
@ -276,9 +276,7 @@ eV3DProjStatus ED_view3d_project_float_object(ARegion *ar, const float co[3], fl
|
|||||||
*/
|
*/
|
||||||
float ED_view3d_calc_zfac(RegionView3D *rv3d, const float co[3], bool *r_flip)
|
float ED_view3d_calc_zfac(RegionView3D *rv3d, const float co[3], bool *r_flip)
|
||||||
{
|
{
|
||||||
float zfac = (rv3d->persmat[0][3] * co[0]) +
|
float zfac = mul_project_m4_v3_zfac(rv3d->persmat, co);
|
||||||
(rv3d->persmat[1][3] * co[1]) +
|
|
||||||
(rv3d->persmat[2][3] * co[2]) + rv3d->persmat[3][3];
|
|
||||||
|
|
||||||
if (r_flip) {
|
if (r_flip) {
|
||||||
*r_flip = (zfac < 0.0f);
|
*r_flip = (zfac < 0.0f);
|
||||||
|
@ -1560,11 +1560,7 @@ static void UNUSED_FUNCTION(view3d_align_axis_to_vector)(View3D *v3d, RegionView
|
|||||||
|
|
||||||
float ED_view3d_pixel_size(RegionView3D *rv3d, const float co[3])
|
float ED_view3d_pixel_size(RegionView3D *rv3d, const float co[3])
|
||||||
{
|
{
|
||||||
return (rv3d->persmat[3][3] + (
|
return mul_project_m4_v3_zfac(rv3d->persmat, co) * rv3d->pixsize * U.pixelsize;
|
||||||
rv3d->persmat[0][3] * co[0] +
|
|
||||||
rv3d->persmat[1][3] * co[1] +
|
|
||||||
rv3d->persmat[2][3] * co[2])
|
|
||||||
) * rv3d->pixsize * U.pixelsize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float ED_view3d_radius_to_persp_dist(const float angle, const float radius)
|
float ED_view3d_radius_to_persp_dist(const float angle, const float radius)
|
||||||
|
@ -892,9 +892,7 @@ static void setNearestAxis3d(TransInfo *t)
|
|||||||
* of two 2D points 30 pixels apart (that's the last factor in the formula) after
|
* of two 2D points 30 pixels apart (that's the last factor in the formula) after
|
||||||
* projecting them with ED_view3d_win_to_delta and then get the length of that vector.
|
* projecting them with ED_view3d_win_to_delta and then get the length of that vector.
|
||||||
*/
|
*/
|
||||||
zfac = (t->persmat[0][3] * t->center[0]) +
|
zfac = mul_project_m4_v3_zfac(t->persmat, t->center);
|
||||||
(t->persmat[1][3] * t->center[1]) +
|
|
||||||
(t->persmat[2][3] * t->center[2]) + t->persmat[3][3];
|
|
||||||
zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;
|
zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user