diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-08-14 18:05:54 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-08-15 16:40:08 +0300 |
commit | 913b8396d971f258df70827274bcdf86dd894185 (patch) | |
tree | 56b0a0f53752ed26da0ea1580a26bfe41490310d /source/blender/modifiers/intern/MOD_multires.c | |
parent | 5a89dfe06baa2ab96947bb6b5f6c63c4b864fab2 (diff) |
Multires: Initial groundwork to hook up displacement to new Subdiv object
Adds a displacement support for OpenSubdiov based subsurf object implemented
as a callback which gives vector displacement in object space. Currently is
implemented to calculate displacement based on myltires displacement grids,
but we can support things in the future if needed.
Submitting to review to see if there is something obviously wrong in the
direction (old multires code was sharing same displacement code to both
calculate final displaced mesh and reshape an existing one, which is rather
confusing and probably can be done more cleanly?).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D3604
Diffstat (limited to 'source/blender/modifiers/intern/MOD_multires.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_multires.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index ca60dceb052..4379e6748cc 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -173,11 +173,14 @@ static Mesh *applyModifier_subdiv(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { + Object *object = ctx->object; Mesh *result = mesh; MultiresModifierData *mmd = (MultiresModifierData *)md; SubdivSettings subdiv_settings; subdiv_settings_init(&subdiv_settings, mmd); - if (subdiv_settings.level == 0) { + SubdivToMeshSettings mesh_settings; + subdiv_mesh_settings_init(&mesh_settings, mmd, ctx); + if (subdiv_settings.level == 0 || mesh_settings.resolution < 3) { /* NOTE: Shouldn't really happen, is supposed to be catched by * isDisabled() callback. */ @@ -189,8 +192,7 @@ static Mesh *applyModifier_subdiv(ModifierData *md, /* Happens on bad topology, ut also on empty input mesh. */ return result; } - SubdivToMeshSettings mesh_settings; - subdiv_mesh_settings_init(&mesh_settings, mmd, ctx); + BKE_subdiv_displacement_attach_from_multires(subdiv, object, mmd); result = BKE_subdiv_to_mesh(subdiv, &mesh_settings, mesh); /* TODO(sergey): Cache subdiv somehow. */ // BKE_subdiv_stats_print(&subdiv->stats); |