Mesh: Move vertex/edge crease to generic attributes #108089

Merged
Hans Goudey merged 23 commits from HooglyBoogly/blender:refactor-mesh-crease-generic into main 2023-06-13 20:23:46 +02:00
Member

Store subdivion surface creases in two new named float attributes:

  • crease_vert
  • crease_edge

The attributes are naming conventions, so their data type and domain
aren't enforced, and may be interpolated when necessary. Editing tools
and the subdivision surface modifier use the hard-coded name. It might
be best if these were edited as generic attributes in the future, but
in the meantime using generic attributes helps.

The attributes are visible in the list, which is how they're now meant
to be removed. They are now interchangeable with any tool that works
with the generic attribute system-- even tools like vertex paint can
affect creases now.

This is a breaking change. Forward compatibility isn't preserved, and
the crease property in RNA is removed in favor of making a smaller
API surface area with just the attribute API. Mesh.vertex_creases
and Mesh.edge_creases now just return the matching attribute if
possible, and are now implemented in Python.

A few extrude node test files have to be updated because of different
(now generic) attribute interpolation behavior.

Store subdivion surface creases in two new named float attributes: - `crease_vert` - `crease_edge` The attributes are naming conventions, so their data type and domain aren't enforced, and may be interpolated when necessary. Editing tools and the subdivision surface modifier use the hard-coded name. It might be best if these were edited as generic attributes in the future, but in the meantime using generic attributes helps. The attributes are visible in the list, which is how they're now meant to be removed. They are now interchangeable with any tool that works with the generic attribute system-- even tools like vertex paint can affect creases now. This is a breaking change. Forward compatibility isn't preserved, and the `crease` property in RNA is removed in favor of making a smaller API surface area with just the attribute API. `Mesh.vertex_creases` and `Mesh.edge_creases` now just return the matching attribute if possible, and are now implemented in Python. A few extrude node test files have to be updated because of different (now generic) attribute interpolation behavior.
Hans Goudey added 1 commit 2023-05-19 19:50:42 +02:00
4d00b8d3ec Mesh: Move vertex/edge crease to generic attributes
Store subdivion surface creases in two new named float attributes:
- `crease_vert`
- `crease_edge`

The attributes are naming conventions, so their data type and domain
aren't enforced, and may be interpolated when necessary. Editing tools
and the subdivision surface modifier use the hard-coded name. It might
be best if these were edited as generic attributes in the future, but
in the meantime using generic attributes helps.

The attributes are visible in the list, which is how they're now meant
to be removed. They are now interchangeable with any tool that works
with the generic attribute system-- even tools like vertex paint can
affect creases now.

This is a breaking change. Forward compatibility isn't preserved, and
the `.vertex_creases` and `.edge_creases` and `crease` properties in
RNA are removed in favor of making a smaller API surface area with just
the attribute API.

A few extrude node test files have to be updated because of different
attribute interpolation behavior.
First-time contributor

Move face...👀

Move face...👀
Hans Goudey added 1 commit 2023-05-23 18:16:54 +02:00
Hans Goudey added 4 commits 2023-05-25 03:04:29 +02:00
Hans Goudey added 1 commit 2023-05-31 21:09:05 +02:00
Hans Goudey added 1 commit 2023-06-03 03:40:56 +02:00

I think we should definitely keep vertex_creases and edge_creases. Such properties are more discoverable in the API docs, and give clear errors where string lookups in attributes do not. And maybe also avoid users have to write validation to ensure the attribute has the right domain?

Personally I would keep crease too, but care less about that one.

What do you think about implementing these and similar attributes in Python, in scripts/modules/bpy_types.py? That way we can simplify the RNA code.

I think we should definitely keep `vertex_creases` and `edge_creases`. Such properties are more discoverable in the API docs, and give clear errors where string lookups in attributes do not. And maybe also avoid users have to write validation to ensure the attribute has the right domain? Personally I would keep `crease` too, but care less about that one. What do you think about implementing these and similar attributes in Python, in `scripts/modules/bpy_types.py`? That way we can simplify the RNA code.
Hans Goudey added 5 commits 2023-06-08 22:58:41 +02:00
Author
Member

What do you think about implementing these and similar attributes in Python, in scripts/modules/bpy_types.py? That way we can simplify the RNA code.

That's a great idea! And I agree it helps to document these things, especially since they're used for such a common use cases.
I add the properties back, defined in Python. Like before, you can't add or remove the attribute with the property, but I think it's fine to require the attribute API for that (before I think the recommended way was the operators).

> What do you think about implementing these and similar attributes in Python, in `scripts/modules/bpy_types.py`? That way we can simplify the RNA code. That's a great idea! And I agree it helps to document these things, especially since they're used for such a common use cases. I add the properties back, defined in Python. Like before, you can't add or remove the attribute with the property, but I think it's fine to require the attribute API for that (before I think the recommended way was the operators).
Hans Goudey added 2 commits 2023-06-09 14:04:06 +02:00
Hans Goudey added this to the 4.0 milestone 2023-06-09 14:54:43 +02:00
Hans Goudey added 1 commit 2023-06-12 14:15:51 +02:00
Brecht Van Lommel requested changes 2023-06-12 15:40:07 +02:00
@ -600,0 +627,4 @@
return None
return creases
except KeyError:
return None

If we are going to do this for more attributes, a utility function to implement this would be nice:

    return builtin_attribute_("crease_edge", 'FLOAT', 'EDGE')

Otherwise looks fine.

I think we also need functions to add/remove creases, since the operators for doing that were removed. Implementing this correctly is non-trivial when the attribute exists on the wrong domain, and add-ons are likely to get it wrong when we don't provide the functionality ourselves.

If we are going to do this for more attributes, a utility function to implement this would be nice: ``` return builtin_attribute_("crease_edge", 'FLOAT', 'EDGE') ``` Otherwise looks fine. I think we also need functions to add/remove creases, since the operators for doing that were removed. Implementing this correctly is non-trivial when the attribute exists on the wrong domain, and add-ons are likely to get it wrong when we don't provide the functionality ourselves.
Author
Member

Good ideas, thanks!

Good ideas, thanks!
HooglyBoogly marked this conversation as resolved
Hans Goudey added 2 commits 2023-06-13 03:24:48 +02:00
Hans Goudey requested review from Brecht Van Lommel 2023-06-13 16:24:27 +02:00
Brecht Van Lommel approved these changes 2023-06-13 18:55:50 +02:00
@ -523,6 +523,36 @@ def ord_ind(i1, i2):
return i2, i1
def name_convention_attribute_get(attributes, name, domain, data_type):

Should prefix with _ to mark it private.

Should prefix with `_` to mark it private.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 2 commits 2023-06-13 19:40:10 +02:00
Hans Goudey added 1 commit 2023-06-13 19:46:19 +02:00
Hans Goudey added 2 commits 2023-06-13 20:18:53 +02:00
Hans Goudey merged commit e5ec04d73c into main 2023-06-13 20:23:46 +02:00
Hans Goudey deleted branch refactor-mesh-crease-generic 2023-06-13 20:23:47 +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
3 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#108089
No description provided.