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:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-02-22 18:56:54 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-02-22 19:02:51 +0300
commit3b132778deaac733baa78653685471e344b6b7c8 (patch)
tree568e05c772008ef3e1d3149c55dfb0e20719d950 /source/blender/blenkernel/BKE_subdiv_ccg.h
parentb6c61945aed51d86dc474df616761f9a25d71d09 (diff)
Multires: Support smooth shading when sculpting
On CCG side it is done similar to displacement, where we have a dedicated functor which evaluates displacement. Might be seemed as an overkill, but allows to decouple SubdivCCG from mesh entirely, and maybe even free up coarse mesh in order to save some memory. Some weak-looking aspect is the call to update normals from the draw manager. Ideally, the manager will only draw what is already evaluated. But it's a bit tricky to find a best place for this since we avoid dependency graph updates during sculpt as much as possible. The new code mimics the old code, this is how it was in 2.7. Fix shading part of T58307.
Diffstat (limited to 'source/blender/blenkernel/BKE_subdiv_ccg.h')
-rw-r--r--source/blender/blenkernel/BKE_subdiv_ccg.h40
1 files changed, 34 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h
index 804a5d0b500..822f4906bae 100644
--- a/source/blender/blenkernel/BKE_subdiv_ccg.h
+++ b/source/blender/blenkernel/BKE_subdiv_ccg.h
@@ -25,6 +25,7 @@
#define __BKE_SUBDIV_CCG_H__
#include "BKE_customdata.h"
+#include "BKE_DerivedMesh.h"
#include "BLI_bitmap.h"
#include "BLI_sys_types.h"
@@ -40,20 +41,41 @@ struct Subdiv;
*/
/* Functor which evaluates mask value at a given (u, v) of given ptex face. */
-typedef struct SubdivCCGMask {
- float (*eval_mask)(struct SubdivCCGMask *mask,
+typedef struct SubdivCCGMaskEvaluator {
+ float (*eval_mask)(struct SubdivCCGMaskEvaluator *mask_evaluator,
const int ptex_face_index,
const float u, const float v);
/* Free the data, not the evaluator itself. */
- void (*free)(struct SubdivCCGMask *mask);
+ void (*free)(struct SubdivCCGMaskEvaluator *mask_evaluator);
void *user_data;
-} SubdivCCGMask;
+} SubdivCCGMaskEvaluator;
/* Return true if mesh has mask and evaluator can be used. */
bool BKE_subdiv_ccg_mask_init_from_paint(
- SubdivCCGMask *mask_evaluator,
+ SubdivCCGMaskEvaluator *mask_evaluator,
+ const struct Mesh *mesh);
+
+/* =============================================================================
+ * Materials.
+ */
+
+/* Functor which evaluates material and flags of a given coarse face. */
+typedef struct SubdivCCGMaterialFlagsEvaluator {
+ DMFlagMat (*eval_material_flags)(
+ struct SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator,
+ const int coarse_face_index);
+
+ /* Free the data, not the evaluator itself. */
+ void (*free)(
+ struct SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator);
+
+ void *user_data;
+} SubdivCCGMaterialFlagsEvaluator;
+
+void BKE_subdiv_ccg_material_flags_init_from_mesh(
+ SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator,
const struct Mesh *mesh);
/* =============================================================================
@@ -196,7 +218,8 @@ typedef struct SubdivCCG {
struct SubdivCCG *BKE_subdiv_to_ccg(
struct Subdiv *subdiv,
const SubdivToCCGSettings *settings,
- SubdivCCGMask *mask_evaluator);
+ SubdivCCGMaskEvaluator *mask_evaluator,
+ SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator);
/* Destroy CCG representation of subdivision surface. */
void BKE_subdiv_ccg_destroy(SubdivCCG *subdiv_ccg);
@@ -218,6 +241,11 @@ void BKE_subdiv_ccg_key_top_level(
/* Recalculate all normals based on grid element coordinates. */
void BKE_subdiv_ccg_recalc_normals(SubdivCCG *subdiv_ccg);
+/* Update normals of affected faces. */
+void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg,
+ struct CCGFace **effected_faces,
+ int num_effected_faces);
+
/* Average grid coordinates and normals along the grid boundatries. */
void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg);