Sculpt: Refactor topology islands cache #125907
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#125907
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "HooglyBoogly/blender:sculpt-topology-island-refactor"
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?
Part of #118145.
meant to store user-edited data, not derived data like caches.
flood-fill algorithm.
1 byte per vertex.
@blender-bot build
@ -480,2 +478,4 @@
};
struct SculptTopologyIslandCache {
blender::Array<uint8_t> vert_island_ids;
Is there is some reason to have such limit for number of islands (or only legacy/)?
Yeah, in the previous version of this branch I stored this in a full integer if necessary. I removed that for now to make the change smaller. It's easy to add later now if we want.
Main area of concern I think is the comments in
vert_id_get
@ -144,2 +144,3 @@
* \return The total number of unique IDs.
*/
void calc_reduced_ids(MutableSpan<int> result) const;
int calc_reduced_ids(MutableSpan<int> result) const;
Being a bit nitpicky here, but maybe this BLI change should be a separate PR? I don't think it'll have odd side effects, but it seems better to isolate it.
I committed this separately.
@ -6484,2 +6485,2 @@
if (ss.attrs.topology_island_key) {
return *static_cast<uint8_t *>(SCULPT_vertex_attr_get(vertex, ss.attrs.topology_island_key));
BLI_assert(ss.topology_island_cache);
const SculptTopologyIslandCache &cache = *ss.topology_island_cache;
With this change, the updated code does crash in non-debug builds if
topology_island_cache
hasn't been set. Probably safer to still exit early with-1
or change this signature tostd::optional<int>
I think developers should always make sure the cache is available before using it. However it's reasonable to avoid giving users crashes in release builds.
@ -6486,3 +6489,2 @@
}
return -1;
return 0;
Related to the above comment, I think if we keep this method as returning only integers, it makes more sense keep it returning
-1
as a not found indicator instead of changing this.The array is now empty when there is just one island, I think it's a little clearer to return 0 in that case
Ah, I completely missed your comment and the code that explained that. Might be worth a small comment in the
ensure_cache
function header or on the variable insideSculptSession
@ -6543,0 +6553,4 @@
SubdivCCGNeighbors neighbors;
for (const short y : IndexRange(key.grid_size)) {
for (const short x : IndexRange(key.grid_size)) {
const SubdivCCGCoord coord{grid, x, y};
Minor styling question - do we have a standardized way of writing struct initialization? For
SubdivCCGCoord
in general I think I've seen this, struct member assignment, and the named initializer list.Not really AFAIK. Others have expressed that they like the named initialization options, since this way it's easy to make a mistake when changing the struct. But I don't see
SubdivCCGCoord
changing without a larger refactor anyway. I hadn't done this before because I didn't useshort
in the grid iteration. Personally I like the single-line initialization and the ability to declare the variable const.