Refactor: Select Engine: Draw actual indices instead of 'Original Indices' #119977
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#119977
Loading…
Reference in New Issue
No description provided.
Delete Branch "mano-wii/blender:draw_select_id_cleanup"
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?
The selection engine renders a uint texture with the selectable mesh indices.
When these meshes have modifiers, the original index is used for the texture.
However this does not seem to be necessary. The real mesh indexes can be used in the texture and, only at the end, the original index can be retrieved on the CPU itself.
Advantages of this approach:
I thought of this when investigating #119932.
To fix #119932 more conveniently, it would be interesting to select the real edge of an evaluated mesh and then use the original index on that edge.
How is this a "Cleanup"? At the very least it's a refactor, or a performance improvement. But it seems to add complexity everywhere in most places in this diff.
@ -17,6 +17,7 @@ enum MeshForeachFlag {
void BKE_mesh_foreach_mapped_vert(
const Mesh *mesh,
const bool use_orig_index,
const
doesn't have meaning in the declaration for arguments passed by value@ -94,3 +94,3 @@
DRW_shgroup_call_no_cull(face_shgrp, geom_facedots, ob);
}
*r_face_offset = initial_offset + em->bm->totface;
*r_face_offset = initial_offset + mesh->faces_num;
Seems this change is unrelated? Or it's a bug fix that could be applied separately?
This change is related, since this offset indicates the number of indexes of the object.
Before we only had the original indices, now we have the real indices that can be greater or less than the original indices.
em->bm->totface
: number of original indicesmesh->faces_num
: number real of indicesIn fact, since we have changes to the DRW API and performance,
Refactor
is the correct one.I try to prioritize the name
Cleanup
when there are no functional changes and the changes are more localized, (even when adding complexity to the code), but this time I exaggerated.Cleanup: Select Engine: Draw actual indices instead of 'Original Index'to Refactor: Select Engine: Draw actual indices instead of 'Original Indices'The PR was mixing two changes:
This increased changes too much and made review difficult.
The PR is now edited to only have the changes in the DRW manager.
This change is a nice simplification.
@ -70,2 +70,3 @@
bool DRW_select_buffer_elem_get(uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type);
bool DRW_select_buffer_elem_get(
uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type, const bool use_orig_index);
const bool
->bool
@ -435,2 +438,4 @@
}
if (use_orig_index) {
Object *object = select_ctx->objects[base_index];
Use const pointers for the object and mesh
@ -436,1 +439,4 @@
if (use_orig_index) {
Object *object = select_ctx->objects[base_index];
Mesh *mesh_eval = BKE_object_get_evaluated_mesh(object);
How does this work for GPU subdivision where this lazily calculates the CPU mesh?
The code was actually forcing the generation of the subdivided mesh to be accessed by the CPU. And the edge orig_index was all zeros. Problem fixed now.
@ -437,0 +440,4 @@
if (use_orig_index) {
Object *object = select_ctx->objects[base_index];
Mesh *mesh_eval = BKE_object_get_evaluated_mesh(object);
const int *orig_index = reinterpret_cast<const int *>(
reinterpret_cast
->static_cast
@ -437,0 +441,4 @@
Object *object = select_ctx->objects[base_index];
Mesh *mesh_eval = BKE_object_get_evaluated_mesh(object);
const int *orig_index = reinterpret_cast<const int *>(
CustomData_get_layer(elem_type == SCE_SELECT_FACE ? &mesh_eval->face_data :
It would be better to split this to a separate function that takes the elem_type and returns a custom data reference
Actually didn't mean to accept yet
There was an error with Subdivision.
It should now be all OK.
@ -396,0 +401,4 @@
case SCE_SELECT_EDGE:
return &mesh_eval->edge_data;
case SCE_SELECT_VERTEX:
default:
I don't think there should be a default case here. Better to add
BLI_assert_unreachable();
andreturn nullptr
outside of the switch.@blender-bot build
Unfortunately I had to revert the commit because I failed to adjust the functions that generate bitmap with the original indexes:
DRW_select_buffer_bitmap_from_circle
DRW_select_buffer_bitmap_from_poly
DRW_select_buffer_bitmap_from_rect
Adapting these functions is more complicated than it seems, as it can cause performance penalties if the CPU has to be used to convert the buffer to original indices :\
It still seems worth doing, since it changes the performance cost from every single redraw to only when selection happens.