Modifiers: Add idname field to ModifierTypeInfo #110468

Merged
Falk David merged 3 commits from filedescriptor/blender:modifier-panel-id into main 2023-07-26 17:08:22 +02:00
Member

Previously the panel type name of a modifier (e.g. "MOD_PT_Smooth") was
created by copying from the ModifierTypeInfos name.
This meant that modifiers with the same default name would use
the same identifier for the panels.

Since different object types (e.g. OB_GREASE_PENCIL and OB_MESH)
might want to use the same default modifier name, this PR introduces
an idname field in the ModifierTypeInfo struct. This is then used to
generate the panel type name.

For compatibility reasons, the idname is the same as the name for now.

Note: Because the name was used previously, this means that some
modifiers have spaces in their panel type name.
E.g. "MOD_PT_Volume to Mesh".

Previously the panel type name of a modifier (e.g. "MOD_PT_Smooth") was created by copying from the `ModifierTypeInfo`s `name`. This meant that modifiers with the same default name would use the same identifier for the panels. Since different object types (e.g. `OB_GREASE_PENCIL` and `OB_MESH`) might want to use the same default modifier name, this PR introduces an `idname` field in the `ModifierTypeInfo` struct. This is then used to generate the panel type name. For compatibility reasons, the `idname` is the same as the `name` for now. Note: Because the `name` was used previously, this means that some modifiers have spaces in their panel type name. E.g. "MOD_PT_Volume to Mesh".
Falk David requested review from Sergey Sharybin 2023-07-25 18:24:20 +02:00
Member

If I understand correctly, this wasn't a problem before because grease pencil modifiers were totally separate.
I think that context is sort of essential to understand the patch.

Maybe use structName then? The panel identifiers don't really matter, since the panels are created and destroyed at runtime and just need to be unique between modifiers in a single object.

If I understand correctly, this wasn't a problem before because grease pencil modifiers were totally separate. I think that context is sort of essential to understand the patch. Maybe use `structName` then? The panel identifiers don't really matter, since the panels are created and destroyed at runtime and just need to be unique between modifiers in a single object.
Author
Member

AFAIK using the structName breaks compatibility, because addons could rely on the panel names. The names are specifically duplicated from the name so that the panel are still called the same.
Should have also added that to the description.

AFAIK using the `structName` breaks compatibility, because addons could rely on the panel names. The names are specifically duplicated from the `name` so that the panel are still called the same. Should have also added that to the description.
Member

I'm fairly sure panel types defined in C/C++ aren't accessible in Python anyway. And then, just finding any unique name when registering the panel should be fine.

I'm fairly sure panel types defined in C/C++ aren't accessible in Python anyway. And then, just finding any unique name when registering the panel should be fine.
Member

Addons can set their custom Panel's bl_parent_id to a C/C++ defined Panel's id name to add their custom Panel as a sub-panel of that C/C++ defined Panel. I think it's about the only way to extend C/C++ Panels from addons.

Addons can set their custom Panel's `bl_parent_id` to a C/C++ defined Panel's id name to add their custom Panel as a sub-panel of that C/C++ defined Panel. I think it's about the only way to extend C/C++ Panels from addons.

We should really be careful with the API, and if it is simple to avoid any API change we should follow this path.

The only thing which seems to make more sense is to add an id field, which then can be used to generate panel ID. Having it a panel ID in the type info seems a bit too specific.

We should really be careful with the API, and if it is simple to avoid any API change we should follow this path. The only thing which seems to make more sense is to add an `id` field, which then can be used to generate panel ID. Having it a panel ID in the type info seems a bit too specific.
Author
Member

I can confirm what @Mysteryem said.
image
image

I can confirm what @Mysteryem said. ![image](/attachments/e9e8f3fd-d88d-4424-9be9-f08b0ea5003b) ![image](/attachments/0b06dfe6-d5e5-4a7b-a4f8-b415f164f66d)
Author
Member

Another weird thing about using name in the panel id that I found is that the name can contain spaces.
Which means that using bl_parent_id = "MOD_PT_Volume to Mesh" in a panel actually works.
So yea this should probably be changed.
image

Another weird thing about using `name` in the panel id that I found is that the `name` can contain spaces. Which means that using `bl_parent_id = "MOD_PT_Volume to Mesh"` in a panel actually works. So yea this should probably be changed. ![image](/attachments/a5fb3087-cefe-44cd-80e3-1f308bcd1dac)
122 KiB
Falk David changed title from Modifiers: Add `panelIDName` field to Modifiers: Add `id` field 2023-07-26 11:20:42 +02:00
Sergey Sharybin approved these changes 2023-07-26 11:35:38 +02:00
Falk David force-pushed modifier-panel-id from 8c0b20332b to 6e811b61c2 2023-07-26 16:56:46 +02:00 Compare
Falk David changed title from Modifiers: Add `id` field to Modifiers: Add `idname` field 2023-07-26 16:58:00 +02:00
Falk David changed title from Modifiers: Add `idname` field to Modifiers: Add `idname` field to `ModifierTypeInfo` 2023-07-26 17:03:02 +02:00
Falk David merged commit d6aa9906fd into main 2023-07-26 17:08:22 +02:00
Falk David deleted branch modifier-panel-id 2023-07-26 17:08:23 +02:00
Sign in to join this conversation.
No reviewers
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#110468
No description provided.