diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-01-20 04:23:36 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-01-20 04:28:22 +0300 |
commit | ae349eb2d50524b030f702b8ed3fd75531d4db7e (patch) | |
tree | ac73e74f5f120b83fd7e9858f25171f1d4501424 /source/blender/blenkernel/intern/subdiv_ccg.c | |
parent | eb3ff1d6f9ca231f7cfde4a5b8255fa895d80d00 (diff) |
Sculpt: Multires Heal Brush
This brush fixes the random spikes that
occasionally happen in multires models.
These spikes can be nearly impossible to
fix manually and can make working with
multires a nightmare.
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_ccg.c')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_ccg.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index 7d876acf776..2acf94cf7d1 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -37,6 +37,7 @@ #include "BKE_ccg.h" #include "BKE_global.h" #include "BKE_mesh.h" +#include "BKE_multires.h" #include "BKE_subdiv.h" #include "BKE_subdiv_eval.h" @@ -2102,4 +2103,38 @@ void BKE_subdiv_ccg_eval_limit_point(const SubdivCCG *subdiv_ccg, BKE_subdiv_eval_limit_point(subdiv, ptex_face_index, u, v, r_point); } +void BKE_subdiv_ccg_eval_limit_point_and_derivatives(const SubdivCCG *subdiv_ccg, + const SubdivCCGCoord *coord, + float r_point[3], + float r_dPdu[3], + float r_dPdv[3]) +{ + Subdiv *subdiv = subdiv_ccg->subdiv; + int ptex_face_index; + float u, v; + subdiv_ccg_coord_to_ptex_coord(subdiv_ccg, coord, &ptex_face_index, &u, &v); + BKE_subdiv_eval_limit_point_and_derivatives( + subdiv, ptex_face_index, u, v, r_point, r_dPdu, r_dPdv); +} + +void BKE_subdiv_ccg_get_tangent_matrix(const SubdivCCG *subdiv_ccg, + const SubdivCCGCoord *coord, + float mat[3][3], + float r_point[3]) +{ + int ptex_face_index; + float u, v; + float du[3], dv[3]; + + const int face_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, coord->grid_index); + const SubdivCCGFace *faces = subdiv_ccg->faces; + const SubdivCCGFace *face = &faces[face_index]; + const float corner = coord->grid_index - face->start_grid_index; + + subdiv_ccg_coord_to_ptex_coord(subdiv_ccg, coord, &ptex_face_index, &u, &v); + + BKE_subdiv_ccg_eval_limit_point_and_derivatives(subdiv_ccg, coord, r_point, du, dv); + BKE_multires_construct_tangent_matrix(mat, du, dv, corner); +} + /** \} */ |