Fix #109491: Erratic behavior of materials for text objects #109746
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#109746
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "lichtwerk/blender:109491"
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?
Symptoms for this were most likely observed when removing material slots
(or moving them up/down).
For text objects, the
CharInfo
mat_nr
material index starts at 1(not at zero like for meshes or nurbs).
Code was mostly considering this (but not in all places, so material
index handling (removing/moving) could still go wrong.
This patch (hopefully) fixes the remaining places where the 1-based index
should be used.
In addition to that, new text objects will have their
CharInfo
mat_nr
index 1-based, places where the index is cleared also set it to1 (instead of zero) now. This also includes version code to correct a
zero index for old files (and sets it to 1 as well).
Just noting that an alternative approach would be to change the whole thing to be zero-based instead (including version-patching old files). Much more involved, but could be considered (but maybe better be done separately).
These one based indices will always be confusing. If it's causing problems, personally I'd prefer to move to zero-based like you mentioned. Seems like 4.0 is also the ideal time to do that.
I probably just don't know these material details enough so my guesses are nonsense. But my understanding here is that this per-character CharInfo->mat_nr uses zero to indicate not set, and so a value of 1 will represent the first material, probably indexed as 0 elsewhere. But wouldn't that mean that initialization of this value should be to zero?
I dont think there is really a concept of "not set" elsewhere in blender.
You have these at zero by default, so there is no distinction of the first material being assigned explicitly or never touched, first material will be used regardless.
So text objects should probably not be different here.
For sure it is weird. But I still worry that the behavior was chosen for some purpose and if we are not sure what that is then we might run into whatever it was that they were trying to avoid. Personally... I would limit this change to the referenced fix but then plan on a larger refactor later than changes the index to zero-based.
For report #109491 the only code of your changes that is hit is in
BKE_curve_material_index_remove
. We have three materials and remove the last one so the index coming in is 2 while our values ininfo->mat_nr
are 1-3. We are off by one and your change there fixes it nicely.But I would consider leaving the rest, including the versioning, to a refactor. That way this fix could go into a future 3.6 release while 4.0 could have these zero-based.
Thats where I started as well, so I get your point.
However, the report also mentions material slots moving up and down, so this would need more changes than the one in
BKE_curve_material_index_remove
and these involve material remapping, array permutation etc (seeBKE_object_material_remap
), which is not easily fixable with "arrays with holes". What I mean by that is that we dont actually have "values ininfo->mat_nr
1-3 " as you mentioned, but instead it is 0/2/3. Only if you specifically assign the first material to some letters, the mat_nr will change from 0 to 1 [which makes the whole situation more manageble, but cannot be required by the user]As much as I'd like to just have some short, backportable fix, leaving the rest of this patch out does not really fix it. Old files would still be broken. And since we already know the root of the issue, imho it only makes sense to have it either 1-based (but "all the way" as in this patch -- which could be backported to 3.6 I think) or zero-based (which is probably better to do in 4.0 for the reasons you mention).
So my suggestion would be: land this patch as it is in main, backport to 3.6, and followup with a change to zero-based in main only (4.0).
Opinions?
Oh, and will merge with main again in a bit...
I merged main now, note there is a bit of confusion wrt versioning code see #108286 (comment)
merged again (above was fixed in
9ec018e1df
)So this should be fixed in 4.0 with !112954.
Now we have to see if/what makes the most sense in terms of backporting.
Go with the zero-based solution in LTS as well?
Or take in the approach from this PR in LTS?
Do nothing in LTS?
I guess the zero based indexing seems easiest to reason about, and best for forward compatibility.
OK, will close this PR then and make one that resembles !112954 for the LTSses
Pull request closed