Refactoring: Rename BKE modifiers funtions #76498

Closed
opened 2020-05-07 10:27:42 +02:00 by Antonio Vazquez · 14 comments

Actually there are a lot of naming conventions in BKE modifier funtions. This task is to fix this mixing of names and replace with BKE_modifier_*****

Actually there are a lot of naming conventions in BKE modifier funtions. This task is to fix this mixing of names and replace with BKE_modifier_*****
Antonio Vazquez self-assigned this 2020-05-07 10:27:42 +02:00
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @antoniov

Added subscriber: @antoniov
Author
Member

See proposed changes in P1373

See proposed changes in [P1373](https://archive.blender.org/developer/P1373.txt)
Author
Member

Added subscribers: @ideasman42, @brecht

Added subscribers: @ideasman42, @brecht
Author
Member

@brecht @ideasman42 I have seen there are two functions: modifier_isPreview and modifiers_isPreview almost with the same name but doing different things. What would be the best names.

Also, please review the naming in the attached file.

@brecht @ideasman42 I have seen there are two functions: `modifier_isPreview` and `modifiers_isPreview` almost with the same name but doing different things. What would be the best names. Also, please review the naming in the attached file.

The convention for BKE function is to use snake case rather than camel case, it's still using camel case now.

BKE_modifier_modwrap can just be BKE_modifier.

Existing functions use modifiers_ when they work on a list of modifiers and modifier when on a single modifier. I think that distinction should remain, making it all singular doesn't seem helpful.

Remove modifiers_isPreview, it's not used anywhere.

The convention for BKE function is to use snake case rather than camel case, it's still using camel case now. `BKE_modifier_modwrap` can just be `BKE_modifier`. Existing functions use `modifiers_` when they work on a list of modifiers and `modifier` when on a single modifier. I think that distinction should remain, making it all singular doesn't seem helpful. Remove `modifiers_isPreview`, it's not used anywhere.
Author
Member

@brecht Updated.

@brecht Updated.

Looks good to me.

Looks good to me.

Looks good, messes a few functions.

struct ModifierData *modifier_new(int type);
void modifier_free_ex(struct ModifierData *md, const int flag);
void modifier_free(struct ModifierData *md);
const ModifierTypeInfo *modifierType_getInfo(ModifierType type);
struct CDMaskLink *modifiers_calcDataMasks(struct Scene *scene,
                                           struct Object *ob,
                                           struct ModifierData *md,
                                           struct CustomData_MeshMasks *final_datamask,
                                           int required_mode,
                                           ModifierData *previewmd,
                                           const struct CustomData_MeshMasks *previewmask);
struct ModifierData *modifiers_getLastPreview(struct Scene *scene,
                                              struct ModifierData *md,
                                              int required_mode);
Looks good, messes a few functions. ``` struct ModifierData *modifier_new(int type); void modifier_free_ex(struct ModifierData *md, const int flag); void modifier_free(struct ModifierData *md); const ModifierTypeInfo *modifierType_getInfo(ModifierType type); struct CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, struct Object *ob, struct ModifierData *md, struct CustomData_MeshMasks *final_datamask, int required_mode, ModifierData *previewmd, const struct CustomData_MeshMasks *previewmask); struct ModifierData *modifiers_getLastPreview(struct Scene *scene, struct ModifierData *md, int required_mode); ```
Author
Member

Keep this list as reference in the task with the changes:

replace_modifiers = (
    ("modifier_new",                        "BKE_modifier_new"),
    ("modifier_free_ex",                    "BKE_modifier_free_ex"),
    ("modifier_free",                       "BKE_modifier_free"),
    ("modifierType_getInfo",                "BKE_modifier_get_info"),
    ("modifiers_calcDataMasks",             "BKE_modifier_calc_data_masks"),
    ("modifiers_getLastPreview",            "BKE_modifier_get_last_preview"),
    ("modifier_unique_name",                "BKE_modifier_unique_name"),
    ("modifier_copyData_generic",           "BKE_modifier_copydata_generic"),
    ("modifier_copyData",                   "BKE_modifier_copydata"),
    ("modifier_copyData_ex",                "BKE_modifier_copydata_ex"),
    ("modifier_dependsOnTime",              "BKE_modifier_depends_ontime"),
    ("modifier_supportsMapping",            "BKE_modifier_supports_mapping"),
    ("modifier_supportsCage",               "BKE_modifier_supports_cage"),
    ("modifier_couldBeCage",                "BKE_modifier_couldbe_cage"),
    ("modifier_isCorrectableDeformed",      "BKE_modifier_is_correctable_deformed"),
    ("modifier_isSameTopology",             "BKE_modifier_is_same_topology"),
    ("modifier_isNonGeometrical",           "BKE_modifier_is_non_geometrical"),
    ("modifier_isEnabled",                  "BKE_modifier_is_enabled"),
    ("modifier_setError",                   "BKE_modifier_set_error"),
    ("modifiers_foreachObjectLink",         "BKE_modifiers_foreach_object_link"),
    ("modifiers_foreachIDLink",             "BKE_modifiers_foreach_ID_link"),
    ("modifiers_foreachTexLink",            "BKE_modifiers_foreach_tex_link"),
    ("modifiers_findByType",                "BKE_modifiers_findby_type"),
    ("modifiers_findByName",                "BKE_modifiers_findny_name"),
    ("modifiers_clearErrors",               "BKE_modifiers_clear_errors"),
    ("modifiers_getCageIndex",              "BKE_modifiers_get_cage_index"),
    ("modifiers_isModifierEnabled",         "BKE_modifiers_is_modifier_enabled"),
    ("modifiers_isSoftbodyEnabled",         "BKE_modifiers_is_softbody_enabled"),
    ("modifiers_isClothEnabled",            "BKE_modifiers_is_cloth_enabled"),
    ("modifiers_isParticleEnabled",         "BKE_modifiers_is_particle_enabled"),
    ("modifiers_isDeformedByArmature",      "BKE_modifiers_is_deformed_by_armature"),
    ("modifiers_isDeformedByMeshDeform",    "BKE_modifiers_is_deformed_by_meshdeform"),
    ("modifiers_isDeformedByLattice",       "BKE_modifiers_is_deformed_by_lattice"),
    ("modifiers_isDeformedByCurve",         "BKE_modifiers_is_deformed_by_curve"),
    ("modifiers_usesMultires",              "BKE_modifiers_uses_multires"),
    ("modifiers_usesArmature",              "BKE_modifiers_uses_armature"),
    ("modifiers_usesSubsurfFacedots",       "BKE_modifiers_uses_subsurf_facedots"),
    ("modifiers_isCorrectableDeformed",     "BKE_modifiers_is_correctable_deformed"),
    ("modifier_freeTemporaryData",          "BKE_modifier_free_temporary_data"),
    ("modifier_isPreview",                  "BKE_modifier_is_preview"),

    - To Remove function (not used)
    - ("modifiers_isPreview",                ""),

    ("modifiers_getVirtualModifierList",    "BKE_modifiers_get_virtual_modifierlist"),
    ("test_object_modifiers",               "BKE_modifiers_test_object"),
    ("modifier_mdef_compact_influences",    "BKE_modifier_mdef_compact_influences"),
    ("modifier_path_init",                  "BKE_modifier_path_init"),
    ("modifier_path_relbase",               "BKE_modifier_path_relbase"),
    ("modifier_path_relbase_from_global",   "BKE_modifier_path_relbase_from_global"),
    ("modifier_get_original",               "BKE_modifier_get_original"),
    ("modifier_get_evaluated",              "BKE_modifier_get_evaluated"),
    ("modwrap_modifyMesh",                  "BKE_modifier_modify_mesh"),
    ("modwrap_deformVerts",                 "BKE_modifier_deform_verts"),
    ("modwrap_deformVertsEM",               "BKE_modifier_deform_vertsEM"),
)

Also some renames for Grease Pencil code to align names.

replace_gp = (
    ("BKE_gpencil_modifierType_getInfo",        "BKE_gpencil_modifier_get_info"),
    ("BKE_gpencil_modifier_dependsOnTime",      "BKE_gpencil_modifier_depends_ontime"),
    ("BKE_gpencil_modifiers_findByType",        "BKE_gpencil_modifiers_findby_type"),
    ("BKE_gpencil_modifiers_findByName",        "BKE_gpencil_modifiers_findby_name"),
    ("BKE_gpencil_modifier_copyData_generic",   "BKE_gpencil_modifier_copydata_generic"),
    ("BKE_gpencil_modifier_copyData",           "BKE_gpencil_modifier_copydata"),
    ("BKE_gpencil_modifier_copyData_ex",        "BKE_gpencil_modifier_copydata_ex"),
    ("BKE_gpencil_modifiers_foreachIDLink",     "BKE_gpencil_modifiers_foreach_ID_link"),
    ("BKE_gpencil_modifiers_foreachTexLink",    "BKE_gpencil_modifiers_foreach_tex_link"),

    ("BKE_shaderfxType_getInfo",                "BKE_shaderfx_get_info"),
    ("BKE_shaderfx_dependsOnTime",              "BKE_shaderfx_depends_ontime"),
    ("BKE_shaderfx_findByType",                 "BKE_shaderfx_findby_type"),
    ("BKE_shaderfx_findByName",                 "BKE_shaderfx_findby_name"),
    ("BKE_shaderfx_copyData_generic",           "BKE_shaderfx_copydata_generic"),
    ("BKE_shaderfx_copyData",                   "BKE_shaderfx_copydata"),
    ("BKE_shaderfx_copyData_ex",                "BKE_shaderfx_copydata_ex"),
    ("BKE_shaderfx_foreachIDLink",              "BKE_shaderfx_foreach_ID_link")
)
Keep this list as reference in the task with the changes: ``` replace_modifiers = ( ("modifier_new", "BKE_modifier_new"), ("modifier_free_ex", "BKE_modifier_free_ex"), ("modifier_free", "BKE_modifier_free"), ("modifierType_getInfo", "BKE_modifier_get_info"), ("modifiers_calcDataMasks", "BKE_modifier_calc_data_masks"), ("modifiers_getLastPreview", "BKE_modifier_get_last_preview"), ("modifier_unique_name", "BKE_modifier_unique_name"), ("modifier_copyData_generic", "BKE_modifier_copydata_generic"), ("modifier_copyData", "BKE_modifier_copydata"), ("modifier_copyData_ex", "BKE_modifier_copydata_ex"), ("modifier_dependsOnTime", "BKE_modifier_depends_ontime"), ("modifier_supportsMapping", "BKE_modifier_supports_mapping"), ("modifier_supportsCage", "BKE_modifier_supports_cage"), ("modifier_couldBeCage", "BKE_modifier_couldbe_cage"), ("modifier_isCorrectableDeformed", "BKE_modifier_is_correctable_deformed"), ("modifier_isSameTopology", "BKE_modifier_is_same_topology"), ("modifier_isNonGeometrical", "BKE_modifier_is_non_geometrical"), ("modifier_isEnabled", "BKE_modifier_is_enabled"), ("modifier_setError", "BKE_modifier_set_error"), ("modifiers_foreachObjectLink", "BKE_modifiers_foreach_object_link"), ("modifiers_foreachIDLink", "BKE_modifiers_foreach_ID_link"), ("modifiers_foreachTexLink", "BKE_modifiers_foreach_tex_link"), ("modifiers_findByType", "BKE_modifiers_findby_type"), ("modifiers_findByName", "BKE_modifiers_findny_name"), ("modifiers_clearErrors", "BKE_modifiers_clear_errors"), ("modifiers_getCageIndex", "BKE_modifiers_get_cage_index"), ("modifiers_isModifierEnabled", "BKE_modifiers_is_modifier_enabled"), ("modifiers_isSoftbodyEnabled", "BKE_modifiers_is_softbody_enabled"), ("modifiers_isClothEnabled", "BKE_modifiers_is_cloth_enabled"), ("modifiers_isParticleEnabled", "BKE_modifiers_is_particle_enabled"), ("modifiers_isDeformedByArmature", "BKE_modifiers_is_deformed_by_armature"), ("modifiers_isDeformedByMeshDeform", "BKE_modifiers_is_deformed_by_meshdeform"), ("modifiers_isDeformedByLattice", "BKE_modifiers_is_deformed_by_lattice"), ("modifiers_isDeformedByCurve", "BKE_modifiers_is_deformed_by_curve"), ("modifiers_usesMultires", "BKE_modifiers_uses_multires"), ("modifiers_usesArmature", "BKE_modifiers_uses_armature"), ("modifiers_usesSubsurfFacedots", "BKE_modifiers_uses_subsurf_facedots"), ("modifiers_isCorrectableDeformed", "BKE_modifiers_is_correctable_deformed"), ("modifier_freeTemporaryData", "BKE_modifier_free_temporary_data"), ("modifier_isPreview", "BKE_modifier_is_preview"), - To Remove function (not used) - ("modifiers_isPreview", ""), ("modifiers_getVirtualModifierList", "BKE_modifiers_get_virtual_modifierlist"), ("test_object_modifiers", "BKE_modifiers_test_object"), ("modifier_mdef_compact_influences", "BKE_modifier_mdef_compact_influences"), ("modifier_path_init", "BKE_modifier_path_init"), ("modifier_path_relbase", "BKE_modifier_path_relbase"), ("modifier_path_relbase_from_global", "BKE_modifier_path_relbase_from_global"), ("modifier_get_original", "BKE_modifier_get_original"), ("modifier_get_evaluated", "BKE_modifier_get_evaluated"), ("modwrap_modifyMesh", "BKE_modifier_modify_mesh"), ("modwrap_deformVerts", "BKE_modifier_deform_verts"), ("modwrap_deformVertsEM", "BKE_modifier_deform_vertsEM"), ) ``` Also some renames for Grease Pencil code to align names. ``` replace_gp = ( ("BKE_gpencil_modifierType_getInfo", "BKE_gpencil_modifier_get_info"), ("BKE_gpencil_modifier_dependsOnTime", "BKE_gpencil_modifier_depends_ontime"), ("BKE_gpencil_modifiers_findByType", "BKE_gpencil_modifiers_findby_type"), ("BKE_gpencil_modifiers_findByName", "BKE_gpencil_modifiers_findby_name"), ("BKE_gpencil_modifier_copyData_generic", "BKE_gpencil_modifier_copydata_generic"), ("BKE_gpencil_modifier_copyData", "BKE_gpencil_modifier_copydata"), ("BKE_gpencil_modifier_copyData_ex", "BKE_gpencil_modifier_copydata_ex"), ("BKE_gpencil_modifiers_foreachIDLink", "BKE_gpencil_modifiers_foreach_ID_link"), ("BKE_gpencil_modifiers_foreachTexLink", "BKE_gpencil_modifiers_foreach_tex_link"), ("BKE_shaderfxType_getInfo", "BKE_shaderfx_get_info"), ("BKE_shaderfx_dependsOnTime", "BKE_shaderfx_depends_ontime"), ("BKE_shaderfx_findByType", "BKE_shaderfx_findby_type"), ("BKE_shaderfx_findByName", "BKE_shaderfx_findby_name"), ("BKE_shaderfx_copyData_generic", "BKE_shaderfx_copydata_generic"), ("BKE_shaderfx_copyData", "BKE_shaderfx_copydata"), ("BKE_shaderfx_copyData_ex", "BKE_shaderfx_copydata_ex"), ("BKE_shaderfx_foreachIDLink", "BKE_shaderfx_foreach_ID_link") ) ```
Author
Member

@ideasman42 @brecht Can I run the script or must I wait for any date?

@ideasman42 @brecht Can I run the script or must I wait for any date?

Think it's fine to commit now.

Think it's fine to commit now.

This issue was referenced by 2bb9a465e6

This issue was referenced by 2bb9a465e6c0e1ca76545c8dbb1be80cf0998ee8
Author
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#76498
No description provided.