Fix #103410: name collisions between vertex groups and attributes #109910
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109910
Loading…
Reference in New Issue
No description provided.
Delete Branch "lichtwerk/blender:103410"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
These name collisions should be avoided with attributes, all sorts of
issues can arise from those. We already warned in the attributes
(but not the vertex groups) list if those were found.
Previously, creating a vertex group with the same name as an already
existing attribute would allow this (and give said warning), and creating
an attribute with the same name as an already existing vertex group
would silently fail (as in: not return a layer) -- and then due to an oversight
in
101d04f41f
(which assumed a valid layer would always be returnedby
BKE_id_attribute_new
) would even crash.Now name collisions between vertex groups and attributes are avoided,
unique names will be found across attributes and vertex groups if either
BKE_id_attribute_calc_unique_name
orBKE_object_defgroup_unique_name
is called.
This is done by unifying the checks and callbacks for both into a single.
Hrmf, just noticed this can still produce non-uniques..., probably better to stick into a single callback after all, will check again...
Fix #103410: name collisions between vertex groups and attributesto WIP: Fix #103410: name collisions between vertex groups and attributesCan you describe the behavior, "handled by ensuring unique names correctly" is not clear to me.
Does it refuse to rename? Rename the item being edited? Rename another item?
Unique names will be found across attributes and vertex groups if either
BKE_id_attribute_calc_unique_name
orBKE_object_defgroup_unique_name
is called, so renaming will always be possible, who's name is being changed depends on how the two functions are called [but should be mostly done on the currently edited entiy afaict]WIP: Fix #103410: name collisions between vertex groups and attributesto Fix #103410: name collisions between vertex groups and attributesThanks, this seems generally reasonable.
@ -10,2 +10,4 @@
#pragma once
#include "DNA_ID.h"
#include "DNA_object_types.h"
These includes should be unnecessary with forward declarations. It's good to avoid including headers in headers where possible, especially for such a common file such as
BKE_attribute.h
.@ -22,6 +25,11 @@ struct CustomDataLayer;
struct ID;
struct ReportList;
typedef struct AttributeAndDefgroupUniqueNameData {
It might be nicer to define this right above
BKE_id_attribute_and_defgroup_unique_name_check
, leaving the top of the file for more generally used / important things like the attribute domain enum definition.@ -233,0 +229,4 @@
AttributeAndDefgroupUniqueNameData *data = static_cast<AttributeAndDefgroupUniqueNameData *>(
arg);
/* Checking vertex groups first. */
This comment basically says the same thing that the
BKE_defgroup_unique_name_check
function name does. Best to let the code do the talking here I think-- comments can describe the reasoning, etc. but just saying what the code does on the next line usually shouldn't be necessary@ -447,6 +448,9 @@ bool BKE_object_supports_vertex_groups(const Object *ob)
const ListBase *BKE_id_defgroup_list_get(const ID *id)
{
switch (GS(id->name)) {
case ID_OB: {
This function is meant to be called on object data, adding this is misleading compared to the other cases IMO
Is it mostly or always? And if not always, when is it renaming another item?
If for example you rename an attribute and then it changes a vertex group name that would be a problem.
Checking the current usages of the two, I dont see how that could happen, seems to always use the unique name on the entity being edited
Ok, that's fine then.
@ -119,1 +119,4 @@
typedef struct AttributeAndDefgroupUniqueNameData {
struct ID *id;
struct bDeformGroup *dg;
This should be forward declared at the top of the file right before
CustomData
@ -303,1 +308,4 @@
const int index = CustomData_get_named_layer_index(customdata, type, uniquename);
if (index == -1) {
BKE_reportf(
reports, RPT_WARNING, "Layer '%s' could not be created with a unique name", uniquename);
"with a unique name" seems a bit off here, a bit like unnecessary information-- there are other things that could go wrong. And actually the unique name seems like one thing that generally shouldn't fail? When do you run into this in practice?
Yep, this was from the very first iteration where I didnt actually have the real solution implemented...
@ -715,0 +722,4 @@
sizeof(dg->name));
}
else {
AttributeAndDefgroupUniqueNameData data{&ob->id, dg};
AttributeAndDefgroupUniqueNameData data{static_cast<ID *>(ob->data), dg};
This removes the need for the change in
defgroup_find_name_dupe
The design is fine, I don't think I need to review the implementation.