Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_cast.c
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | ||||
| CastModifierData *cmd = (CastModifierData *)md; | CastModifierData *cmd = (CastModifierData *)md; | ||||
| if (cmd->object != NULL) { | if (cmd->object != NULL) { | ||||
| DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier"); | DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier"); | ||||
| DEG_add_modifier_to_transform_relation(ctx->node, "Cast Modifier"); | DEG_add_modifier_to_transform_relation(ctx->node, "Cast Modifier"); | ||||
| } | } | ||||
| } | } | ||||
| static void sphere_do( | static void sphere_do( | ||||
| CastModifierData *cmd, const ModifierEvalContext *ctx, | CastModifierData *cmd, const ModifierEvalContext *UNUSED(ctx), | ||||
| Object *ob, Mesh *mesh, | Object *ob, Mesh *mesh, | ||||
| float (*vertexCos)[3], int numVerts) | float (*vertexCos)[3], int numVerts) | ||||
| { | { | ||||
| MDeformVert *dvert = NULL; | MDeformVert *dvert = NULL; | ||||
| Object *ctrl_ob = NULL; | Object *ctrl_ob = NULL; | ||||
| int i, defgrp_index; | int i, defgrp_index; | ||||
| bool has_radius = false; | bool has_radius = false; | ||||
| short flag, type; | short flag, type; | ||||
| float len = 0.0f; | float len = 0.0f; | ||||
| float fac = cmd->fac; | float fac = cmd->fac; | ||||
| float facm = 1.0f - fac; | float facm = 1.0f - fac; | ||||
| const float fac_orig = fac; | const float fac_orig = fac; | ||||
| float vec[3], center[3] = {0.0f, 0.0f, 0.0f}; | float vec[3], center[3] = {0.0f, 0.0f, 0.0f}; | ||||
| float mat[4][4], imat[4][4]; | float mat[4][4], imat[4][4]; | ||||
| flag = cmd->flag; | flag = cmd->flag; | ||||
| type = cmd->type; /* projection type: sphere or cylinder */ | type = cmd->type; /* projection type: sphere or cylinder */ | ||||
| if (type == MOD_CAST_TYPE_CYLINDER) | if (type == MOD_CAST_TYPE_CYLINDER) | ||||
| flag &= ~MOD_CAST_Z; | flag &= ~MOD_CAST_Z; | ||||
| ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object); | ctrl_ob = cmd->object; | ||||
| /* spherify's center is {0, 0, 0} (the ob's own center in its local | /* spherify's center is {0, 0, 0} (the ob's own center in its local | ||||
| * space), by default, but if the user defined a control object, | * space), by default, but if the user defined a control object, | ||||
| * we use its location, transformed to ob's local space */ | * we use its location, transformed to ob's local space */ | ||||
| if (ctrl_ob) { | if (ctrl_ob) { | ||||
| if (flag & MOD_CAST_USE_OB_TRANSFORM) { | if (flag & MOD_CAST_USE_OB_TRANSFORM) { | ||||
| invert_m4_m4(imat, ctrl_ob->obmat); | invert_m4_m4(imat, ctrl_ob->obmat); | ||||
| mul_m4_m4m4(mat, imat, ob->obmat); | mul_m4_m4m4(mat, imat, ob->obmat); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if (ctrl_ob) { | ||||
| } | } | ||||
| } | } | ||||
| copy_v3_v3(vertexCos[i], tmp_co); | copy_v3_v3(vertexCos[i], tmp_co); | ||||
| } | } | ||||
| } | } | ||||
| static void cuboid_do( | static void cuboid_do( | ||||
| CastModifierData *cmd, const ModifierEvalContext *ctx, | CastModifierData *cmd, const ModifierEvalContext *UNUSED(ctx), | ||||
| Object *ob, Mesh *mesh, | Object *ob, Mesh *mesh, | ||||
| float (*vertexCos)[3], int numVerts) | float (*vertexCos)[3], int numVerts) | ||||
| { | { | ||||
| MDeformVert *dvert = NULL; | MDeformVert *dvert = NULL; | ||||
| Object *ctrl_ob = NULL; | Object *ctrl_ob = NULL; | ||||
| int i, defgrp_index; | int i, defgrp_index; | ||||
| bool has_radius = false; | bool has_radius = false; | ||||
| short flag; | short flag; | ||||
| float fac = cmd->fac; | float fac = cmd->fac; | ||||
| float facm = 1.0f - fac; | float facm = 1.0f - fac; | ||||
| const float fac_orig = fac; | const float fac_orig = fac; | ||||
| float min[3], max[3], bb[8][3]; | float min[3], max[3], bb[8][3]; | ||||
| float center[3] = {0.0f, 0.0f, 0.0f}; | float center[3] = {0.0f, 0.0f, 0.0f}; | ||||
| float mat[4][4], imat[4][4]; | float mat[4][4], imat[4][4]; | ||||
| flag = cmd->flag; | flag = cmd->flag; | ||||
| ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object); | ctrl_ob = cmd->object; | ||||
| /* now we check which options the user wants */ | /* now we check which options the user wants */ | ||||
| /* 1) (flag was checked in the "if (ctrl_ob)" block above) */ | /* 1) (flag was checked in the "if (ctrl_ob)" block above) */ | ||||
| /* 2) cmd->radius > 0.0f: only the vertices within this radius from | /* 2) cmd->radius > 0.0f: only the vertices within this radius from | ||||
| * the center of the effect should be deformed */ | * the center of the effect should be deformed */ | ||||
| if (cmd->radius > FLT_EPSILON) has_radius = 1; | if (cmd->radius > FLT_EPSILON) has_radius = 1; | ||||
| ▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines | |||||