Mesh: Reimplement and unify topology maps #107861
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#107861
Loading…
Reference in New Issue
No description provided.
Delete Branch "HooglyBoogly/blender:cleanup-unify-mesh-maps"
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?
Combine the newer less efficient C++ implementations and the older
less convenient C functions. The maps now contain one large array of
indices, split into groups by a separate array of offset indices.
Though performance of creating the maps is relatively unchanged, the
new implementation uses 4 bytes less per source element than the C
maps, and 20 bytes less than the newer C++ functions (which also
had move overhead with larger N-gons). The usage syntax is simpler
than the C functions as well.
The reduced memory usage is helpful for when these maps are cached
in the near future. It will also allow sharing the offsets between
maps for different domains like vertex to corner and vertex to face.
A simple
GroupedSpan
class is introduced to make accessing thetopology maps much simpler. It combines offset indices and a separate
span, splitting it into chunks in an efficient way.
@blender-bot build
@blender-bot build
@ -226,3 +223,1 @@
MEM_SAFE_FREE(vlmap_);
MEM_SAFE_FREE(vlmap_mem_);
}
~MeshFairingContext() override {}
Remove destructor because it's empty.
@ -95,0 +97,4 @@
* store many grouped arrays, without requiring many small allocations, giving the general benefits
* of using contiguous memory.
*/
template<typename T> struct GroupedSpan {
My only very small concern with this type is that some might use multiple
GroupSpan
which all use the sameoffsets
. In this case, it would be more efficient to lookup the range from the offsets only once. This is still possible of course, just a little less obvious.Yeah, good point. Probably not necessary but I added a note in the classes description mentioning that.
@ -95,0 +104,4 @@
GroupedSpan() = default;
GroupedSpan(OffsetIndices<int> offsets, Span<T> data) : offsets(offsets), data(data)
{
BLI_assert(offsets.total_size() == data.size());
Use
this->
when refering to public data members.@ -95,0 +107,4 @@
BLI_assert(offsets.total_size() == data.size());
}
Span<T> operator[](const int64_t vert_index) const
vert_index
->index
@ -95,0 +112,4 @@
return data.slice(offsets[vert_index]);
}
bool is_empty() const
Also add a
size
andindex_range
method.@ -174,10 +174,6 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
SCULPT_vertex_random_access_ensure(ss);
if (!ob->sculpt->pmap) {
I wonder if this is used as a check for emptyness or so and the code below depends on that, just a thought.
Generally I think these are fairly paranoid checks and more likely hide bugs because some code didn't ensure the map was created before the operator was run. Removing them should be fine, and works in my tests.
@ -577,10 +577,6 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
if (!ss->pmap) {
Might also be used as a check to detect the no-polygon case.
@ -141,2 +139,2 @@
}
return map;
bke::mesh::build_vert_to_edge_map(edges, verts_num, r_offsets, r_indices);
const OffsetIndices<int> offsets(r_offsets);
Can you use
GroupedSpan
here?Not without a
MutableGroupedSpan
, which I wanted to avoid for now.@ -143,0 +142,4 @@
for (const int vert : range) {
MutableSpan<int> neighbors = r_indices.as_mutable_span().slice(offsets[vert]);
for (const int i : neighbors.index_range()) {
neighbors[i] = bke::mesh::edge_other_vert(edges[neighbors[i]], vert);
Unrelated, but just noticed that here. Think
edge_other_vert
could be implemented in a branchless way (when the error case can be ignored, which it can in many cases).other_vert = edge.v1 + edge.v2 - query_vert
I wonder if we would care about potential overflow in that case. I guess it's crazy for a mesh to have 1-2 billion edges or so, but maybe it's possible.
@blender-bot build