Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_surfacedeform.c
| Show First 20 Lines • Show All 1,118 Lines • ▼ Show 20 Lines | for (int j = 0; j < data->bind_verts[index].numbinds; j++, sdbind++) { | ||||
| madd_v3_v3fl(temp, norm, sdbind->normal_dist); | madd_v3_v3fl(temp, norm, sdbind->normal_dist); | ||||
| madd_v3_v3fl(vertexCos, temp, sdbind->influence); | madd_v3_v3fl(vertexCos, temp, sdbind->influence); | ||||
| } | } | ||||
| } | } | ||||
| static void surfacedeformModifier_do( | static void surfacedeformModifier_do( | ||||
| ModifierData *md, | ModifierData *md, | ||||
| const ModifierEvalContext *UNUSED(ctx), | const ModifierEvalContext *ctx, | ||||
| float (*vertexCos)[3], unsigned int numverts, Object *ob) | float (*vertexCos)[3], unsigned int numverts, Object *ob) | ||||
| { | { | ||||
| SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; | SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; | ||||
| Mesh *target; | Mesh *target; | ||||
| unsigned int tnumverts, tnumpoly; | unsigned int tnumverts, tnumpoly; | ||||
| /* Exit function if bind flag is not set (free bind data if any). */ | /* Exit function if bind flag is not set (free bind data if any). */ | ||||
| if (!(smd->flags & MOD_SDEF_BIND)) { | if (!(smd->flags & MOD_SDEF_BIND)) { | ||||
| /* Note: with new CoW system, we expect unbinding to be done by a special call from main thread, | |||||
| * outside of depsgraph evaluation (see object_force_modifier_update_for_bind() in object_modifier.c). */ | |||||
| if (smd->verts != NULL) { | if (smd->verts != NULL) { | ||||
| if (ob != DEG_get_original_object(ob)) { | if (!DEG_is_active(ctx->depsgraph)) { | ||||
| BLI_assert(!"Trying to unbind inside of depsgraph evaluation"); | modifier_setError(md, "Attempt to bind from inactive dependency graph"); | ||||
| modifier_setError(md, "Trying to unbind inside of depsgraph evaluation"); | return; | ||||
| } | |||||
| else { | |||||
| freeData(md); | |||||
| } | } | ||||
| ModifierData *md_orig = modifier_get_original(md); | |||||
| freeData(md_orig); | |||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| Object *ob_target = smd->target; | Object *ob_target = smd->target; | ||||
| target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); | target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); | ||||
| #if 0 /* Should not be needed anymore since we always get that mesh from eval object ? */ | |||||
| if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) { | |||||
| /* Special case, binding happens outside of depsgraph evaluation, so we can build our own | |||||
| * target mesh if needed. */ | |||||
| target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, CD_MASK_BAREMESH); | |||||
| free_target = target != NULL; | |||||
| } | |||||
| #endif | |||||
| if (!target) { | if (!target) { | ||||
| modifier_setError(md, "No valid target mesh"); | modifier_setError(md, "No valid target mesh"); | ||||
| return; | return; | ||||
| } | } | ||||
| tnumverts = target->totvert; | tnumverts = target->totvert; | ||||
| tnumpoly = target->totpoly; | tnumpoly = target->totpoly; | ||||
| /* If not bound, execute bind. */ | /* If not bound, execute bind. */ | ||||
| /* Note: with new CoW system, we expect binding to be done by a special call from main thread, | |||||
| * outside of depsgraph evaluation (see object_force_modifier_update_for_bind() in object_modifier.c). */ | |||||
| if (smd->verts == NULL) { | if (smd->verts == NULL) { | ||||
| if (ob != DEG_get_original_object(ob)) { | if (!DEG_is_active(ctx->depsgraph)) { | ||||
| BLI_assert(!"Trying to bind inside of depsgraph evaluation"); | modifier_setError(md, "Attempt to unbind from inactive dependency graph"); | ||||
| modifier_setError(md, "Trying to bind inside of depsgraph evaluation"); | |||||
| return; | return; | ||||
| } | } | ||||
| SurfaceDeformModifierData *smd_orig = (SurfaceDeformModifierData *)modifier_get_original(md); | |||||
| float tmp_mat[4][4]; | float tmp_mat[4][4]; | ||||
| invert_m4_m4(tmp_mat, ob->obmat); | invert_m4_m4(tmp_mat, ob->obmat); | ||||
| mul_m4_m4m4(smd->mat, tmp_mat, ob_target->obmat); | mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->obmat); | ||||
| if (!surfacedeformBind(smd, vertexCos, numverts, tnumpoly, tnumverts, target)) { | if (!surfacedeformBind(smd_orig, vertexCos, numverts, tnumpoly, tnumverts, target)) { | ||||
| smd->flags &= ~MOD_SDEF_BIND; | smd->flags &= ~MOD_SDEF_BIND; | ||||
| } | } | ||||
| /* Early abort, this is binding 'call', no need to perform whole evaluation. */ | /* Early abort, this is binding 'call', no need to perform whole evaluation. */ | ||||
| return; | return; | ||||
| } | } | ||||
| /* Poly count checks */ | /* Poly count checks */ | ||||
| if (smd->numverts != numverts) { | if (smd->numverts != numverts) { | ||||
| ▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines | |||||