Refactor: Use new math API for ED_view3d_ob_project_mat_get_from_obmat #117938

Merged
Falk David merged 2 commits from filedescriptor/blender:refactor-view3d-project-mat-from-obmat into main 2024-02-07 14:04:35 +01:00
3 changed files with 8 additions and 11 deletions

View File

@ -708,9 +708,8 @@ bool ED_view3d_win_to_segment_clipped(const Depsgraph *depsgraph,
float r_ray_end[3],
bool do_clip_planes);
blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob);
void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d,
const float obmat[4][4],
float r_pmat[4][4]);
blender::float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d,
const blender::float4x4 &obmat);
/**
* Convert between region relative coordinates (x,y) and depth component z and

View File

@ -3712,7 +3712,9 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet
copy_m4_m4(viewmat, ps->rv3d->viewmat);
copy_m4_m4(viewinv, ps->rv3d->viewinv);
ED_view3d_ob_project_mat_get_from_obmat(ps->rv3d, ps->obmat, ps->projectMat);
blender::float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(
ps->rv3d, blender::float4x4(ps->obmat));
copy_m4_m4(ps->projectMat, projection.ptr());
ps->is_ortho = ED_view3d_clip_range_get(
ps->depsgraph, ps->v3d, ps->rv3d, &ps->clip_start, &ps->clip_end, true);

View File

@ -710,14 +710,10 @@ blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const O
return r_pmat;
}
void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d,
const float obmat[4][4],
float r_pmat[4][4])
blender::float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d,
Review

Might be nice to change the code inside of ED_view3d_ob_project_mat_get at the same time? Not a big deal though.

Might be nice to change the code inside of `ED_view3d_ob_project_mat_get` at the same time? Not a big deal though.
const blender::float4x4 &obmat)
{
float vmat[4][4];
mul_m4_m4m4(vmat, rv3d->viewmat, obmat);
mul_m4_m4m4(r_pmat, rv3d->winmat, vmat);
return blender::float4x4_view(rv3d->winmat) * blender::float4x4_view(rv3d->viewmat) * obmat;
}
void ED_view3d_project_v3(const ARegion *region, const float world[3], float r_region_co[3])