Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_wave.cc
- This file was moved from source/blender/modifiers/intern/MOD_wave.c.
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| WaveModifierData *wmd = (WaveModifierData *)md; | WaveModifierData *wmd = (WaveModifierData *)md; | ||||
| BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wmd, modifier)); | BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wmd, modifier)); | ||||
| MEMCPY_STRUCT_AFTER(wmd, DNA_struct_default_get(WaveModifierData), modifier); | MEMCPY_STRUCT_AFTER(wmd, DNA_struct_default_get(WaveModifierData), modifier); | ||||
| } | } | ||||
| static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md)) | static bool dependsOnTime(Scene *UNUSED(scene), ModifierData *UNUSED(md)) | ||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | ||||
| { | { | ||||
| WaveModifierData *wmd = (WaveModifierData *)md; | WaveModifierData *wmd = (WaveModifierData *)md; | ||||
| walk(userData, ob, (ID **)&wmd->texture, IDWALK_CB_USER); | walk(userData, ob, (ID **)&wmd->texture, IDWALK_CB_USER); | ||||
| walk(userData, ob, (ID **)&wmd->objectcenter, IDWALK_CB_NOP); | walk(userData, ob, (ID **)&wmd->objectcenter, IDWALK_CB_NOP); | ||||
| walk(userData, ob, (ID **)&wmd->map_object, IDWALK_CB_NOP); | walk(userData, ob, (ID **)&wmd->map_object, IDWALK_CB_NOP); | ||||
| } | } | ||||
| static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void *userData) | static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void *userData) | ||||
| { | { | ||||
| walk(userData, ob, md, "texture"); | walk(userData, ob, md, "texture"); | ||||
| } | } | ||||
| static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | ||||
| { | { | ||||
| WaveModifierData *wmd = (WaveModifierData *)md; | WaveModifierData *wmd = (WaveModifierData *)md; | ||||
| bool need_transform_relation = false; | bool need_transform_relation = false; | ||||
| if (wmd->objectcenter != NULL) { | if (wmd->objectcenter != nullptr) { | ||||
| DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier"); | DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier"); | ||||
| need_transform_relation = true; | need_transform_relation = true; | ||||
| } | } | ||||
| if (wmd->texture != NULL) { | if (wmd->texture != nullptr) { | ||||
| DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier"); | DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier"); | ||||
| if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) { | if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != nullptr) { | ||||
| MOD_depsgraph_update_object_bone_relation( | MOD_depsgraph_update_object_bone_relation( | ||||
| ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier"); | ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier"); | ||||
| need_transform_relation = true; | need_transform_relation = true; | ||||
| } | } | ||||
| else if (wmd->texmapping == MOD_DISP_MAP_GLOBAL) { | else if (wmd->texmapping == MOD_DISP_MAP_GLOBAL) { | ||||
| need_transform_relation = true; | need_transform_relation = true; | ||||
| } | } | ||||
| } | } | ||||
| Show All 31 Lines | static void waveModifier_do(WaveModifierData *md, | ||||
| Mesh *mesh, | Mesh *mesh, | ||||
| float (*vertexCos)[3], | float (*vertexCos)[3], | ||||
| int verts_num) | int verts_num) | ||||
| { | { | ||||
| WaveModifierData *wmd = (WaveModifierData *)md; | WaveModifierData *wmd = (WaveModifierData *)md; | ||||
| const MDeformVert *dvert; | const MDeformVert *dvert; | ||||
| int defgrp_index; | int defgrp_index; | ||||
| float ctime = DEG_get_ctime(ctx->depsgraph); | float ctime = DEG_get_ctime(ctx->depsgraph); | ||||
| float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); | float minfac = float(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); | ||||
| float lifefac = wmd->height; | float lifefac = wmd->height; | ||||
| float(*tex_co)[3] = NULL; | float(*tex_co)[3] = nullptr; | ||||
| const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y); | const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y); | ||||
| const float falloff = wmd->falloff; | const float falloff = wmd->falloff; | ||||
| float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */ | float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */ | ||||
| const bool invert_group = (wmd->flag & MOD_WAVE_INVERT_VGROUP) != 0; | const bool invert_group = (wmd->flag & MOD_WAVE_INVERT_VGROUP) != 0; | ||||
| const float(*vert_normals)[3] = NULL; | const float(*vert_normals)[3] = nullptr; | ||||
| if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) { | if ((wmd->flag & MOD_WAVE_NORM) && (mesh != nullptr)) { | ||||
| vert_normals = BKE_mesh_vertex_normals_ensure(mesh); | vert_normals = BKE_mesh_vertex_normals_ensure(mesh); | ||||
| } | } | ||||
| if (wmd->objectcenter != NULL) { | if (wmd->objectcenter != nullptr) { | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| /* get the control object's location in local coordinates */ | /* get the control object's location in local coordinates */ | ||||
| invert_m4_m4(ob->imat, ob->obmat); | invert_m4_m4(ob->imat, ob->obmat); | ||||
| mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat); | mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat); | ||||
| wmd->startx = mat[3][0]; | wmd->startx = mat[3][0]; | ||||
| wmd->starty = mat[3][1]; | wmd->starty = mat[3][1]; | ||||
| } | } | ||||
| Show All 10 Lines | if (wmd->lifetime != 0.0f) { | ||||
| if (x > wmd->lifetime) { | if (x > wmd->lifetime) { | ||||
| lifefac = x - wmd->lifetime; | lifefac = x - wmd->lifetime; | ||||
| if (lifefac > wmd->damp) { | if (lifefac > wmd->damp) { | ||||
| lifefac = 0.0; | lifefac = 0.0; | ||||
| } | } | ||||
| else { | else { | ||||
| lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); | lifefac = float(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Tex *tex_target = wmd->texture; | Tex *tex_target = wmd->texture; | ||||
| if (mesh != NULL && tex_target != NULL) { | if (mesh != nullptr && tex_target != nullptr) { | ||||
| tex_co = MEM_malloc_arrayN(verts_num, sizeof(*tex_co), "waveModifier_do tex_co"); | tex_co = static_cast<float(*)[3]>(MEM_malloc_arrayN(verts_num, sizeof(*tex_co), __func__)); | ||||
| MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); | MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); | ||||
| MOD_init_texture((MappingInfoModifierData *)wmd, ctx); | MOD_init_texture((MappingInfoModifierData *)wmd, ctx); | ||||
| } | } | ||||
| if (lifefac != 0.0f) { | if (lifefac != 0.0f) { | ||||
| /* avoid divide by zero checks within the loop */ | /* avoid divide by zero checks within the loop */ | ||||
| float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f; | float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f; | ||||
| Show All 28 Lines | for (i = 0; i < verts_num; i++) { | ||||
| amplit = y; | amplit = y; | ||||
| break; | break; | ||||
| } | } | ||||
| /* this way it makes nice circles */ | /* this way it makes nice circles */ | ||||
| amplit -= (ctime - wmd->timeoffs) * wmd->speed; | amplit -= (ctime - wmd->timeoffs) * wmd->speed; | ||||
| if (wmd->flag & MOD_WAVE_CYCL) { | if (wmd->flag & MOD_WAVE_CYCL) { | ||||
| amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) + wmd->width; | amplit = float(fmodf(amplit - wmd->width, 2.0f * wmd->width)) + wmd->width; | ||||
| } | } | ||||
| if (falloff != 0.0f) { | if (falloff != 0.0f) { | ||||
| float dist = 0.0f; | float dist = 0.0f; | ||||
| switch (wmd_axis) { | switch (wmd_axis) { | ||||
| case MOD_WAVE_X | MOD_WAVE_Y: | case MOD_WAVE_X | MOD_WAVE_Y: | ||||
| dist = sqrtf(x * x + y * y); | dist = sqrtf(x * x + y * y); | ||||
| break; | break; | ||||
| case MOD_WAVE_X: | case MOD_WAVE_X: | ||||
| dist = fabsf(x); | dist = fabsf(x); | ||||
| break; | break; | ||||
| case MOD_WAVE_Y: | case MOD_WAVE_Y: | ||||
| dist = fabsf(y); | dist = fabsf(y); | ||||
| break; | break; | ||||
| } | } | ||||
| falloff_fac = (1.0f - (dist * falloff_inv)); | falloff_fac = (1.0f - (dist * falloff_inv)); | ||||
| CLAMP(falloff_fac, 0.0f, 1.0f); | CLAMP(falloff_fac, 0.0f, 1.0f); | ||||
| } | } | ||||
| /* GAUSSIAN */ | /* GAUSSIAN */ | ||||
| if ((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) { | if ((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) { | ||||
| amplit = amplit * wmd->narrow; | amplit = amplit * wmd->narrow; | ||||
| amplit = (float)(1.0f / expf(amplit * amplit) - minfac); | amplit = float(1.0f / expf(amplit * amplit) - minfac); | ||||
| /* Apply texture. */ | /* Apply texture. */ | ||||
| if (tex_co) { | if (tex_co) { | ||||
| Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); | Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); | ||||
| TexResult texres; | TexResult texres; | ||||
| BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false); | BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false); | ||||
| amplit *= texres.tin; | amplit *= texres.tin; | ||||
| } | } | ||||
| Show All 26 Lines | |||||
| static void deformVerts(ModifierData *md, | static void deformVerts(ModifierData *md, | ||||
| const ModifierEvalContext *ctx, | const ModifierEvalContext *ctx, | ||||
| Mesh *mesh, | Mesh *mesh, | ||||
| float (*vertexCos)[3], | float (*vertexCos)[3], | ||||
| int verts_num) | int verts_num) | ||||
| { | { | ||||
| WaveModifierData *wmd = (WaveModifierData *)md; | WaveModifierData *wmd = (WaveModifierData *)md; | ||||
| Mesh *mesh_src = NULL; | Mesh *mesh_src = nullptr; | ||||
| if (wmd->flag & MOD_WAVE_NORM) { | if (wmd->flag & MOD_WAVE_NORM) { | ||||
| mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, vertexCos, verts_num, false); | mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, vertexCos, verts_num, false); | ||||
| } | } | ||||
| else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { | else if (wmd->texture != nullptr || wmd->defgrp_name[0] != '\0') { | ||||
| mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); | mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false); | ||||
| } | } | ||||
| waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); | waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); | ||||
| if (!ELEM(mesh_src, NULL, mesh)) { | if (!ELEM(mesh_src, nullptr, mesh)) { | ||||
| BKE_id_free(NULL, mesh_src); | BKE_id_free(nullptr, mesh_src); | ||||
| } | } | ||||
| } | } | ||||
| static void deformVertsEM(ModifierData *md, | static void deformVertsEM(ModifierData *md, | ||||
| const ModifierEvalContext *ctx, | const ModifierEvalContext *ctx, | ||||
| struct BMEditMesh *editData, | BMEditMesh *editData, | ||||
| Mesh *mesh, | Mesh *mesh, | ||||
| float (*vertexCos)[3], | float (*vertexCos)[3], | ||||
| int verts_num) | int verts_num) | ||||
| { | { | ||||
| WaveModifierData *wmd = (WaveModifierData *)md; | WaveModifierData *wmd = (WaveModifierData *)md; | ||||
| Mesh *mesh_src = NULL; | Mesh *mesh_src = nullptr; | ||||
| if (wmd->flag & MOD_WAVE_NORM) { | if (wmd->flag & MOD_WAVE_NORM) { | ||||
| mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, verts_num, false); | mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, verts_num, false); | ||||
| } | } | ||||
| else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { | else if (wmd->texture != nullptr || wmd->defgrp_name[0] != '\0') { | ||||
| mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); | mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false); | ||||
| } | } | ||||
| /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ | /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ | ||||
| if (mesh_src != NULL) { | if (mesh_src != nullptr) { | ||||
| BKE_mesh_wrapper_ensure_mdata(mesh_src); | BKE_mesh_wrapper_ensure_mdata(mesh_src); | ||||
| } | } | ||||
| waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); | waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); | ||||
| if (!ELEM(mesh_src, NULL, mesh)) { | if (!ELEM(mesh_src, nullptr, mesh)) { | ||||
| /* Important not to free `vertexCos` owned by the caller. */ | /* Important not to free `vertexCos` owned by the caller. */ | ||||
| EditMeshData *edit_data = mesh_src->runtime.edit_data; | EditMeshData *edit_data = mesh_src->runtime.edit_data; | ||||
| if (edit_data->vertexCos == vertexCos) { | if (edit_data->vertexCos == vertexCos) { | ||||
| edit_data->vertexCos = NULL; | edit_data->vertexCos = nullptr; | ||||
| } | } | ||||
| BKE_id_free(NULL, mesh_src); | BKE_id_free(nullptr, mesh_src); | ||||
| } | } | ||||
| } | } | ||||
| static void panel_draw(const bContext *UNUSED(C), Panel *panel) | static void panel_draw(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| uiLayout *sub, *row, *col; | uiLayout *sub, *row, *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA ob_ptr; | PointerRNA ob_ptr; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| row = uiLayoutRowWithHeading(layout, true, IFACE_("Motion")); | row = uiLayoutRowWithHeading(layout, true, IFACE_("Motion")); | ||||
| uiItemR(row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); | uiItemR( | ||||
| uiItemR(row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); | row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, nullptr, ICON_NONE); | ||||
| uiItemR( | |||||
| row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, nullptr, ICON_NONE); | |||||
| uiItemR(layout, ptr, "use_cyclic", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_cyclic", 0, nullptr, ICON_NONE); | ||||
| row = uiLayoutRowWithHeading(layout, true, IFACE_("Along Normals")); | row = uiLayoutRowWithHeading(layout, true, IFACE_("Along Normals")); | ||||
| uiItemR(row, ptr, "use_normal", 0, "", ICON_NONE); | uiItemR(row, ptr, "use_normal", 0, "", ICON_NONE); | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_normal")); | uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_normal")); | ||||
| uiItemR(sub, ptr, "use_normal_x", UI_ITEM_R_TOGGLE, "X", ICON_NONE); | uiItemR(sub, ptr, "use_normal_x", UI_ITEM_R_TOGGLE, "X", ICON_NONE); | ||||
| uiItemR(sub, ptr, "use_normal_y", UI_ITEM_R_TOGGLE, "Y", ICON_NONE); | uiItemR(sub, ptr, "use_normal_y", UI_ITEM_R_TOGGLE, "Y", ICON_NONE); | ||||
| uiItemR(sub, ptr, "use_normal_z", UI_ITEM_R_TOGGLE, "Z", ICON_NONE); | uiItemR(sub, ptr, "use_normal_z", UI_ITEM_R_TOGGLE, "Z", ICON_NONE); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, ptr, "falloff_radius", 0, IFACE_("Falloff"), ICON_NONE); | uiItemR(col, ptr, "falloff_radius", 0, IFACE_("Falloff"), ICON_NONE); | ||||
| uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); | uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); | ||||
| uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); | uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); | ||||
| uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, NULL, ICON_NONE); | uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); | ||||
| modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); | modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); | ||||
| modifier_panel_end(layout, ptr); | modifier_panel_end(layout, ptr); | ||||
| } | } | ||||
| static void position_panel_draw(const bContext *UNUSED(C), Panel *panel) | static void position_panel_draw(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| uiItemR(layout, ptr, "start_position_object", 0, IFACE_("Object"), ICON_NONE); | uiItemR(layout, ptr, "start_position_object", 0, IFACE_("Object"), ICON_NONE); | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiItemR(col, ptr, "start_position_x", 0, IFACE_("Start Position X"), ICON_NONE); | uiItemR(col, ptr, "start_position_x", 0, IFACE_("Start Position X"), ICON_NONE); | ||||
| uiItemR(col, ptr, "start_position_y", 0, "Y", ICON_NONE); | uiItemR(col, ptr, "start_position_y", 0, "Y", ICON_NONE); | ||||
| } | } | ||||
| static void time_panel_draw(const bContext *UNUSED(C), Panel *panel) | static void time_panel_draw(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, ptr, "time_offset", 0, IFACE_("Offset"), ICON_NONE); | uiItemR(col, ptr, "time_offset", 0, IFACE_("Offset"), ICON_NONE); | ||||
| uiItemR(col, ptr, "lifetime", 0, IFACE_("Life"), ICON_NONE); | uiItemR(col, ptr, "lifetime", 0, IFACE_("Life"), ICON_NONE); | ||||
| uiItemR(col, ptr, "damping_time", 0, IFACE_("Damping"), ICON_NONE); | uiItemR(col, ptr, "damping_time", 0, IFACE_("Damping"), ICON_NONE); | ||||
| uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, NULL, ICON_NONE); | uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); | ||||
| } | } | ||||
| static void texture_panel_draw(const bContext *C, Panel *panel) | static void texture_panel_draw(const bContext *C, Panel *panel) | ||||
| { | { | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA ob_ptr; | PointerRNA ob_ptr; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | ||||
| int texture_coords = RNA_enum_get(ptr, "texture_coords"); | int texture_coords = RNA_enum_get(ptr, "texture_coords"); | ||||
| uiTemplateID(layout, C, ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL); | uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr, 0, ICON_NONE, nullptr); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, ptr, "texture_coords", 0, IFACE_("Coordinates"), ICON_NONE); | uiItemR(col, ptr, "texture_coords", 0, IFACE_("Coordinates"), ICON_NONE); | ||||
| if (texture_coords == MOD_DISP_MAP_OBJECT) { | if (texture_coords == MOD_DISP_MAP_OBJECT) { | ||||
| uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); | uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); | ||||
| PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object"); | PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object"); | ||||
| if (!RNA_pointer_is_null(&texture_coords_obj_ptr) && | if (!RNA_pointer_is_null(&texture_coords_obj_ptr) && | ||||
| (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) { | (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) { | ||||
| PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data"); | PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data"); | ||||
| uiItemPointerR(col, | uiItemPointerR(col, | ||||
| ptr, | ptr, | ||||
| "texture_coords_bone", | "texture_coords_bone", | ||||
| &texture_coords_obj_data_ptr, | &texture_coords_obj_data_ptr, | ||||
| "bones", | "bones", | ||||
| IFACE_("Bone"), | IFACE_("Bone"), | ||||
| ICON_NONE); | ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) { | else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) { | ||||
| PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data"); | PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data"); | ||||
| uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE); | uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| static void panelRegister(ARegionType *region_type) | static void panelRegister(ARegionType *region_type) | ||||
| { | { | ||||
| PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Wave, panel_draw); | PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Wave, panel_draw); | ||||
| modifier_subpanel_register( | modifier_subpanel_register( | ||||
| region_type, "position", "Start Position", NULL, position_panel_draw, panel_type); | region_type, "position", "Start Position", nullptr, position_panel_draw, panel_type); | ||||
| modifier_subpanel_register(region_type, "time", "Time", NULL, time_panel_draw, panel_type); | modifier_subpanel_register(region_type, "time", "Time", nullptr, time_panel_draw, panel_type); | ||||
| modifier_subpanel_register( | modifier_subpanel_register( | ||||
| region_type, "texture", "Texture", NULL, texture_panel_draw, panel_type); | region_type, "texture", "Texture", nullptr, texture_panel_draw, panel_type); | ||||
| } | } | ||||
| ModifierTypeInfo modifierType_Wave = { | ModifierTypeInfo modifierType_Wave = { | ||||
| /* name */ N_("Wave"), | /* name */ N_("Wave"), | ||||
| /* structName */ "WaveModifierData", | /* structName */ "WaveModifierData", | ||||
| /* structSize */ sizeof(WaveModifierData), | /* structSize */ sizeof(WaveModifierData), | ||||
| /* srna */ &RNA_WaveModifier, | /* srna */ &RNA_WaveModifier, | ||||
| /* type */ eModifierTypeType_OnlyDeform, | /* type */ eModifierTypeType_OnlyDeform, | ||||
| /* flags */ eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_AcceptsVertexCosOnly | | /* flags */ eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_AcceptsVertexCosOnly | | ||||
| eModifierTypeFlag_SupportsEditmode, | eModifierTypeFlag_SupportsEditmode, | ||||
| /* icon */ ICON_MOD_WAVE, | /* icon */ ICON_MOD_WAVE, | ||||
| /* copyData */ BKE_modifier_copydata_generic, | /* copyData */ BKE_modifier_copydata_generic, | ||||
| /* deformVerts */ deformVerts, | /* deformVerts */ deformVerts, | ||||
| /* deformMatrices */ NULL, | /* deformMatrices */ nullptr, | ||||
| /* deformVertsEM */ deformVertsEM, | /* deformVertsEM */ deformVertsEM, | ||||
| /* deformMatricesEM */ NULL, | /* deformMatricesEM */ nullptr, | ||||
| /* modifyMesh */ NULL, | /* modifyMesh */ nullptr, | ||||
| /* modifyGeometrySet */ NULL, | /* modifyGeometrySet */ nullptr, | ||||
| /* initData */ initData, | /* initData */ initData, | ||||
| /* requiredDataMask */ requiredDataMask, | /* requiredDataMask */ requiredDataMask, | ||||
| /* freeData */ NULL, | /* freeData */ nullptr, | ||||
| /* isDisabled */ NULL, | /* isDisabled */ nullptr, | ||||
| /* updateDepsgraph */ updateDepsgraph, | /* updateDepsgraph */ updateDepsgraph, | ||||
| /* dependsOnTime */ dependsOnTime, | /* dependsOnTime */ dependsOnTime, | ||||
| /* dependsOnNormals */ dependsOnNormals, | /* dependsOnNormals */ dependsOnNormals, | ||||
| /* foreachIDLink */ foreachIDLink, | /* foreachIDLink */ foreachIDLink, | ||||
| /* foreachTexLink */ foreachTexLink, | /* foreachTexLink */ foreachTexLink, | ||||
| /* freeRuntimeData */ NULL, | /* freeRuntimeData */ nullptr, | ||||
| /* panelRegister */ panelRegister, | /* panelRegister */ panelRegister, | ||||
| /* blendWrite */ NULL, | /* blendWrite */ nullptr, | ||||
| /* blendRead */ NULL, | /* blendRead */ nullptr, | ||||
| }; | }; | ||||