Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2022-01-20 04:23:36 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-01-20 04:28:22 +0300
commitae349eb2d50524b030f702b8ed3fd75531d4db7e (patch)
treeac73e74f5f120b83fd7e9858f25171f1d4501424 /source/blender/blenkernel
parenteb3ff1d6f9ca231f7cfde4a5b8255fa895d80d00 (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')
-rw-r--r--source/blender/blenkernel/BKE_subdiv_ccg.h11
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c35
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h
index b3aa966e0d0..2de16bbddd4 100644
--- a/source/blender/blenkernel/BKE_subdiv_ccg.h
+++ b/source/blender/blenkernel/BKE_subdiv_ccg.h
@@ -314,6 +314,17 @@ void BKE_subdiv_ccg_eval_limit_point(const SubdivCCG *subdiv_ccg,
const SubdivCCGCoord *coord,
float r_point[3]);
+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]);
+
+void BKE_subdiv_ccg_get_tangent_matrix(const SubdivCCG *subdiv_ccg,
+ const SubdivCCGCoord *coord,
+ float mat[3][3],
+ float r_point[3]);
+
typedef enum SubdivCCGAdjacencyType {
SUBDIV_CCG_ADJACENT_NONE,
SUBDIV_CCG_ADJACENT_VERTEX,
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);
+}
+
/** \} */