forked from bartvdbraak/blender
Fix T70476: Sculpting with Subsurf on top produces artifacts
The issue was caused by crazy space distortion orientation happening for subsurf modifier. Solved by making it so subsurf only deforms the surface but keeps matrices as-is. This is not fully mathematically correct, but is better that the fall-back solution which was doing wrong matrices anyway. Also, this is closer to have subsurf was handled prior to the related changes. Reviewed By: brecht, pablodp606 Differential Revision: https://developer.blender.org/D5991
This commit is contained in:
parent
d4c452ff39
commit
cc1614123e
@ -1 +1 @@
|
||||
Subproject commit 1f6ec7f7a145c36808231090c8666febb49db220
|
||||
Subproject commit 88497d7507e76281fbdd0cc1f8451f81ae7e3785
|
@ -1 +1 @@
|
||||
Subproject commit eb9bab0e7153fda8de113af9e3c54eca74c986ef
|
||||
Subproject commit d39c2b61470059dd31cf688441c817a875b928cc
|
@ -1 +1 @@
|
||||
Subproject commit d9ed9d4d064c74c86e2767cd4be32d602a0ee317
|
||||
Subproject commit 69bcc72f1ec4df73265ce35851658ef184b9d0f9
|
@ -355,7 +355,7 @@ static void crazyspace_init_verts_and_matrices(const Mesh *mesh,
|
||||
BLI_assert(num_verts == mesh->totvert);
|
||||
}
|
||||
|
||||
static bool crazyspace_modifier_supports_deform(ModifierData *md)
|
||||
static bool crazyspace_modifier_supports_deform_matrices(ModifierData *md)
|
||||
{
|
||||
if (ELEM(md->type, eModifierType_Subsurf, eModifierType_Multires)) {
|
||||
return true;
|
||||
@ -364,6 +364,12 @@ static bool crazyspace_modifier_supports_deform(ModifierData *md)
|
||||
return (mti->type == eModifierTypeType_OnlyDeform);
|
||||
}
|
||||
|
||||
static bool crazyspace_modifier_supports_deform(ModifierData *md)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
return (mti->type == eModifierTypeType_OnlyDeform);
|
||||
}
|
||||
|
||||
int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
Object *object,
|
||||
@ -391,13 +397,12 @@ int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
|
||||
md = modifiers_getVirtualModifierList(&object_eval, &virtualModifierData);
|
||||
|
||||
for (; md; md = md->next) {
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mti->type == eModifierTypeType_OnlyDeform) {
|
||||
if (crazyspace_modifier_supports_deform_matrices(md)) {
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
if (defmats == NULL) {
|
||||
/* NOTE: Evaluated object si re-set to its original undeformed
|
||||
* state. */
|
||||
|
@ -228,16 +228,22 @@ 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)
|
||||
static void deformMatrices(ModifierData *md,
|
||||
const ModifierEvalContext *UNUSED(ctx),
|
||||
Mesh *mesh,
|
||||
float (*vertex_cos)[3],
|
||||
float (*deform_matrices)[3][3],
|
||||
int num_verts)
|
||||
|
||||
{
|
||||
#if !defined(WITH_OPENSUBDIV)
|
||||
modifier_setError(md, "Disabled, built without OpenSubdiv");
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Subsurf does not require extra space mapping, keep matrices as is. */
|
||||
(void)deform_matrices;
|
||||
|
||||
MultiresModifierData *mmd = (MultiresModifierData *)md;
|
||||
SubdivSettings subdiv_settings;
|
||||
BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
|
||||
@ -268,8 +274,8 @@ ModifierTypeInfo modifierType_Multires = {
|
||||
|
||||
/* copyData */ copyData,
|
||||
|
||||
/* deformVerts */ deformVerts,
|
||||
/* deformMatrices */ NULL,
|
||||
/* deformVerts */ NULL,
|
||||
/* deformMatrices */ deformMatrices,
|
||||
/* deformVertsEM */ NULL,
|
||||
/* deformMatricesEM */ NULL,
|
||||
/* applyModifier */ applyModifier,
|
||||
|
@ -241,16 +241,21 @@ 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)
|
||||
static void deformMatrices(ModifierData *md,
|
||||
const ModifierEvalContext *UNUSED(ctx),
|
||||
Mesh *mesh,
|
||||
float (*vertex_cos)[3],
|
||||
float (*deform_matrices)[3][3],
|
||||
int num_verts)
|
||||
{
|
||||
#if !defined(WITH_OPENSUBDIV)
|
||||
modifier_setError(md, "Disabled, built without OpenSubdiv");
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Subsurf does not require extra space mapping, keep matrices as is. */
|
||||
(void)deform_matrices;
|
||||
|
||||
SubsurfModifierData *smd = (SubsurfModifierData *)md;
|
||||
SubdivSettings subdiv_settings;
|
||||
subdiv_settings_init(&subdiv_settings, smd);
|
||||
@ -281,8 +286,8 @@ ModifierTypeInfo modifierType_Subsurf = {
|
||||
|
||||
/* copyData */ copyData,
|
||||
|
||||
/* deformVerts */ deformVerts,
|
||||
/* deformMatrices */ NULL,
|
||||
/* deformVerts */ NULL,
|
||||
/* deformMatrices */ deformMatrices,
|
||||
/* deformVertsEM */ NULL,
|
||||
/* deformMatricesEM */ NULL,
|
||||
/* applyModifier */ applyModifier,
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7b740545cd039ddcadbfb9bffcac842476eee271
|
||||
Subproject commit 4ad446dbddd1b23acc185b8c056474d27b69278b
|
Loading…
Reference in New Issue
Block a user