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-09-11 12:10:46 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-09-19 12:51:25 +0300
commit74d27bb0efaddbd5f49eb58ff2ce1cfde2a53804 (patch)
tree6ee075842fa1e6a60c9ef1119b7f724269b39d2d /source/blender/modifiers/intern/MOD_multires.c
parent65d8c771c7b7c0b0e3416222cf81c8aee97e0ed3 (diff)
Subdiv: Add vertex deformation callback to multires/subsurf
Currently unused but the intention is to use this to hook up these modifiers to a generic deformed PBVH to make it easier to sculpt or paint on a subdivided mesh.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_multires.c')
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index dd7c001931c..53bb579128a 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -38,6 +38,7 @@
#include "BKE_paint.h"
#include "BKE_subdiv.h"
#include "BKE_subdiv_ccg.h"
+#include "BKE_subdiv_deform.h"
#include "BKE_subdiv_mesh.h"
#include "BKE_subsurf.h"
@@ -227,6 +228,36 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
return result;
}
+static void deformVerts(ModifierData *md,
+ const ModifierEvalContext *UNUSED(ctx),
+ Mesh *mesh,
+ float (*vertex_cos)[3],
+ int num_verts)
+{
+#if !defined(WITH_OPENSUBDIV)
+ modifier_setError(md, "Disabled, built without OpenSubdiv");
+ return;
+#endif
+ MultiresModifierData *mmd = (MultiresModifierData *)md;
+ SubdivSettings subdiv_settings;
+ BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
+ if (subdiv_settings.level == 0) {
+ return;
+ }
+ BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh);
+ MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd);
+ Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
+ if (subdiv == NULL) {
+ /* Happens on bad topology, ut also on empty input mesh. */
+ return;
+ }
+ BKE_subdiv_displacement_attach_from_multires(subdiv, mesh, mmd);
+ BKE_subdiv_deform_coarse_vertices(subdiv, mesh, vertex_cos, num_verts);
+ if (subdiv != runtime_data->subdiv) {
+ BKE_subdiv_free(subdiv);
+ }
+}
+
ModifierTypeInfo modifierType_Multires = {
/* name */ "Multires",
/* structName */ "MultiresModifierData",
@@ -237,7 +268,7 @@ ModifierTypeInfo modifierType_Multires = {
/* copyData */ copyData,
- /* deformVerts */ NULL,
+ /* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,