Reset values of property layer, when mesh is edited (after 2.74) #42865

Closed
opened 2014-12-10 16:04:00 +01:00 by Jiri Hnidek · 30 comments
Member

Hi All,
when you create your own property layer using e.g.:

lay = bm.verts.layers.int.new(id_name)

and you assign some values to this layer, then these values are copied to some vertexes during extruding, duplicating, etc. It is OK in some cases, but developers IMHO usually want to handle theirs values (I want). Current behaviour does not allow to distinguish between existing vertices/edges/faces/loops and new created elements. BTW: I created following Python script for testing: https://gist.github.com/jirihnidek/bf0a8cb6bb2f306a39a7

I created patch that reset values in property layers of newly created vertices/edges/faces/loops. It will probably requires further modification of Python API and do not make such behaviour as default. I propose following modification:

new(layer_name, reset_new_values=False)

customdata_prop_layer.diff

Hi All, when you create your own property layer using e.g.: ``` lay = bm.verts.layers.int.new(id_name) ``` and you assign some values to this layer, then these values are copied to some vertexes during extruding, duplicating, etc. It is OK in some cases, but developers IMHO usually want to handle theirs values (I want). Current behaviour does not allow to distinguish between existing vertices/edges/faces/loops and new created elements. BTW: I created following Python script for testing: https://gist.github.com/jirihnidek/bf0a8cb6bb2f306a39a7 I created patch that reset values in property layers of newly created vertices/edges/faces/loops. It will probably requires further modification of Python API and do not make such behaviour as default. I propose following modification: ``` new(layer_name, reset_new_values=False) ``` [customdata_prop_layer.diff](https://archive.blender.org/developer/F130609/customdata_prop_layer.diff)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Campbell Barton was assigned by Jiri Hnidek 2014-12-10 16:04:00 +01:00
Author
Member

Added subscriber: @jiri

Added subscriber: @jiri

Not sure about this: we have a set_default callback already.

We could just have a flag on the layer that defines duplicated elements are set to their default instead of copying from the data they came from.

Not sure about this: we have a `set_default` callback already. We could just have a flag on the layer that defines duplicated elements are set to their default instead of copying from the data they came from.
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Author
Member

It sound reasonably. I will change the patch. Thanks for your feedback.

It sound reasonably. I will change the patch. Thanks for your feedback.
Author
Member

Hi All,
I created new version of patch. It adds one optional parameter to function new():

new(name, copy_values=True)

I updated previous gist file: https://gist.github.com/jirihnidek/bf0a8cb6bb2f306a39a7 to work with this patch.

Jiri

customdata_prop_layer_new.diff

Hi All, I created new version of patch. It adds one optional parameter to function `new()`: ``` new(name, copy_values=True) ``` I updated previous gist file: https://gist.github.com/jirihnidek/bf0a8cb6bb2f306a39a7 to work with this patch. Jiri [customdata_prop_layer_new.diff](https://archive.blender.org/developer/F130996/customdata_prop_layer_new.diff)
Author
Member

I did some tests and it seems that new layer flag: CD_FLAG_NOCOPY_ELEM is forgotten, when object goes from object mode to edit mode.

I did some tests and it seems that new layer flag: CD_FLAG_NOCOPY_ELEM is forgotten, when object goes from object mode to edit mode.
Author
Member

The flag was cleared in CustomData_merge(). I'm attaching new patch file.

customdata_prop_layer_new2.diff

The flag was cleared in CustomData_merge(). I'm attaching new patch file. [customdata_prop_layer_new2.diff](https://archive.blender.org/developer/F132266/customdata_prop_layer_new2.diff)
Author
Member

I'm attaching new patch that use attribute of layer (lay.use_force_default = True) for changing behaviour of custom-data layers in edit mode. Gist file with example is updated too.

customdata_prop_layer_new3.diff

I'm attaching new patch that use attribute of layer (`lay.use_force_default = True`) for changing behaviour of custom-data layers in edit mode. Gist file with example is updated too. [customdata_prop_layer_new3.diff](https://archive.blender.org/developer/F143197/customdata_prop_layer_new3.diff)

Checked latest patch. seems good, but would tweak names a bit before going into master. (ufd is a bit cryptic)

Would like to do final check before going into master still.

Checked latest patch. seems good, but would tweak names a bit before going into master. (``ufd`` is a bit cryptic) Would like to do final check before going into master still.
Campbell Barton changed title from Reset values of property layer, when mesh is edited to Reset values of property layer, when mesh is edited (after 2.74) 2015-02-25 12:18:02 +01:00
Author
Member

Hi,
I extended the patch. It is also possible to get and set default value of custom-data layers using attribute, e.g.: lay.default_value = -1. Note: only int and float subtypes are supported, string subtype is not supported. When you try to get default value of other layer type (e.g.: UV), then lay.default_value returns None.

customdata_default_value.diff

I changed some typos and fixed wrong names of functions (caused by copy-paste).

Hi, I extended the patch. It is also possible to get and set default value of custom-data layers using attribute, e.g.: `lay.default_value = -1`. Note: only int and float subtypes are supported, string subtype is not supported. When you try to get default value of other layer type (e.g.: UV), then `lay.default_value` returns `None`. [customdata_default_value.diff](https://archive.blender.org/developer/F153084/customdata_default_value.diff) I changed some typos and fixed wrong names of functions (caused by copy-paste).

Added subscriber: @HorusIceRaven

Added subscriber: @HorusIceRaven

This comment was removed by @HorusIceRaven

*This comment was removed by @HorusIceRaven*
Member

@HorusIceRaven, we're currently not redesigning our layer system and tbh I don't see that happen soon. Thanks for the idea and the effort, we'll keep it in mind, it's just not the right time&place for it ;)

@HorusIceRaven, we're currently not redesigning our layer system and tbh I don't see that happen soon. Thanks for the idea and the effort, we'll keep it in mind, it's just not the right time&place for it ;)

I understand, as I stated in the beginning. This message may have to be redirected or scrapped. My hope is only to improve by planting a seed that may grow into the form I depict or pieces may grow in a direction that no one could have foreseen.
Thanks for you rapid response.
I think you and your teem are doing a fantastic job, so to this.
Do what you will.

I understand, as I stated in the beginning. This message may have to be redirected or scrapped. My hope is only to improve by planting a seed that may grow into the form I depict or pieces may grow in a direction that no one could have foreseen. Thanks for you rapid response. I think you and your teem are doing a fantastic job, so to this. Do what you will.

Added subscriber: @dfelinto

Added subscriber: @dfelinto
Member

Added subscriber: @CodeManX

Added subscriber: @CodeManX
Member

What's the status of the patch?
The parameter could also be called propagate_values IMO.
Also interesting would be auto-increment as default value, so assign unique numbers (IDs) to vertices and disable value propagation...

What's the status of the patch? The parameter could also be called `propagate_values` IMO. Also interesting would be auto-increment as default value, so assign unique numbers (IDs) to vertices and disable value propagation...
Author
Member

Hi,
the status of this patch is following: I wait for @ideasman42 to approve it and merge to master. I poke him regularly at IRC chat ;-).

The name of parameter default_value is IMHO more descriptive then propagate_value. I'm not big fan of auto-increment of layer values, because it duplicates functionality. Vertices, Edges, Faces, etc. have property index and it is unique.

Cheers

Hi, the status of this patch is following: I wait for @ideasman42 to approve it and merge to master. I poke him regularly at IRC chat ;-). The name of parameter `default_value` is IMHO more descriptive then `propagate_value`. I'm not big fan of auto-increment of layer values, because it duplicates functionality. Vertices, Edges, Faces, etc. have property `index` and it is unique. Cheers
Member

Fingers crossed for this to land soon!

.index is not unique in the sense that it can change at any time (can even be overwritten by script) and does not persistently identify a geometry element over its lifetime. That's what I had in mind.

An auto-incrementing value would be unique and identify a vertex even after mesh sort operator.

Fingers crossed for this to land soon! .index is not unique in the sense that it can change at any time (can even be overwritten by script) and does not persistently identify a geometry element over its lifetime. That's what I had in mind. An auto-incrementing value would be unique and identify a vertex even after mesh sort operator.
Author
Member

Why fingers crossed? @ideasman42 approved first version of this patch (layer parameter use_force_default). Do you have anything against this patch? If so, you should clarify what is wrong.

You are right about uniqueness of index, but I'm not willing to add auto-increment functionality to this patch. May be it could be implemented in another patch.

Why fingers crossed? @ideasman42 approved first version of this patch (layer parameter `use_force_default`). Do you have anything against this patch? If so, you should clarify what is wrong. You are right about uniqueness of `index`, but I'm not willing to add auto-increment functionality to this patch. May be it could be implemented in another patch.
Member

Don't get me wrong, your patch is great! It's just that I've seen ready patches lurking around for months or even a year. So the emphasis was on "soon"!

Don't get me wrong, your patch is great! It's just that I've seen ready patches lurking around for months or even a year. So the emphasis was on "soon"!
Author
Member

Aha, I understand now :-). Fingers crossed gesture is not Batsu gesture.

Aha, I understand now :-). Fingers crossed gesture is not Batsu gesture.

@HorusIceRaven, your comments about layers re-design are unrelated to this patch, and off topic.

removed, pasted here, http://www.pasteall.org/60563 for reference.

@HorusIceRaven, your comments about layers re-design are unrelated to this patch, and off topic. removed, pasted here, http://www.pasteall.org/60563 for reference.
Author
Member

Hi @ideasman42,
I refactored code for setting/getting default_value it is possible to set/get default values for int, float and now string custom property layers, but there are other layer types. What other layer types should be supported? I'm adding all layer types accessible using Python API:

CD_MDEFORMVERT
CD_PAINT_MASK
CD_MTEXPOLY
CD_MLOOPUV
CD_MLOOPCOL
CD_SHAPEKEY
CD_BWEIGHT
CD_CREASE
CD_MVERT_SKIN

Thanks.

Hi @ideasman42, I refactored code for setting/getting `default_value` it is possible to set/get default values for `int`, `float` and now `string` custom property layers, but there are other layer types. What other layer types should be supported? I'm adding all layer types accessible using Python API: CD_MDEFORMVERT CD_PAINT_MASK CD_MTEXPOLY CD_MLOOPUV CD_MLOOPCOL CD_SHAPEKEY CD_BWEIGHT CD_CREASE CD_MVERT_SKIN Thanks.

Added subscriber: @SwoorupJoshi

Added subscriber: @SwoorupJoshi
Campbell Barton removed their assignment 2016-08-11 06:36:34 +02:00

Removed subscriber: @ideasman42

Removed subscriber: @ideasman42

Added subscriber: @RobinKauffman

Added subscriber: @RobinKauffman

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Dalai Felinto self-assigned this 2019-12-23 18:42:38 +01:00

Hi, thanks for your patch.

We are undergoing a Tracker Curfew where we are automatically closing old patches.

If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.

Hi, thanks for your patch. We are undergoing a [Tracker Curfew ](https://code.blender.org/?p=3861) where we are automatically closing old patches. If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.
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
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
8 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#42865
No description provided.