Fix #106993: Slowness with Orbiting around select + Mesh Symmetry #107203

Merged
Germano Cavalcante merged 2 commits from mano-wii/blender:fix_106993 into main 2023-04-21 20:07:16 +02:00

The issue happens because the algorithm used to calculate the center of
the selection first needs to create a TransData array. In this array,
the code calculates the "mirrored" elements which can be quite slow in
dense meshes.

So replace this slow algorithm used for calculating the pivot point with
the fast algorithm used to calculate the position of transform gizmos.


A simpler solution would be to skip creating those "mirrored" TransData. But I noticed that transform code has two algorithm to calculate selection center:

  • One is fast and is used for gizmos
  • The other is the one already mentioned and used in several other parts of the Blender code

Therefore, the solution proposed here is to separate the specific part of the code to calculate the position of the gizmos and use this code instead.

The gizmo's code is intertwined with calculating bounds and orientation, so to separate it out it was necessary to create a "foreach" function that takes a callback.

The original code of transform Gizmos is from @ideasman42. Therefore adding as a reviewer.
I'm also adding @HooglyBoogly as reviewer for C++ styling questions (if needed).

The issue happens because the algorithm used to calculate the center of the selection first needs to create a TransData array. In this array, the code calculates the "mirrored" elements which can be quite slow in dense meshes. So replace this slow algorithm used for calculating the pivot point with the fast algorithm used to calculate the position of transform gizmos. ---- A simpler solution would be to skip creating those "mirrored" TransData. But I noticed that transform code has two algorithm to calculate selection center: - One is fast and is used for gizmos - The other is the one already mentioned and used in several other parts of the Blender code Therefore, the solution proposed here is to separate the specific part of the code to calculate the position of the gizmos and use this code instead. The gizmo's code is intertwined with calculating bounds and orientation, so to separate it out it was necessary to create a "foreach" function that takes a callback. The original code of transform Gizmos is from @ideasman42. Therefore adding as a reviewer. I'm also adding @HooglyBoogly as reviewer for C++ styling questions (if needed).
Germano Cavalcante requested review from Campbell Barton 2023-04-21 04:46:26 +02:00
Germano Cavalcante requested review from Hans Goudey 2023-04-21 04:46:27 +02:00
Campbell Barton requested changes 2023-04-21 05:32:11 +02:00
Campbell Barton left a comment
Owner

Made an initial review, although I didn't dig into details.

Please note in the commit log why there was poor performance and what was changed to resolve this.
(this is noted below the --- so it may be enough to include this in the commit log).

Unless you have concerns or there is an area you think calls for a second opinion, I'll trust your judgement on this change.

Made an initial review, although I didn't dig into details. Please note in the commit log why there was poor performance and what was changed to resolve this. _(this is noted below the `---` so it may be enough to include this in the commit log)._ Unless you have concerns or there is an area you think calls for a second opinion, I'll trust your judgement on this change.
@ -488,3 +474,1 @@
static void protectflag_to_drawflags_pchan(RegionView3D *rv3d,
const bPoseChannel *pchan,
short orientation_index)
static int gizmo_3d_foreach_selected(const bContext *C,

As this function is reasonably involved, it would be good to add a doc-string giving an overview of the function and the parameters.

As this function is reasonably involved, it would be good to add a doc-string giving an overview of the function and the parameters.
@ -491,0 +475,4 @@
const short orient_index,
const bool use_curve_handles,
const bool use_only_center,
const float (**r_mat)[4],

Pass r_ prefixed arguments last.

Pass `r_` prefixed arguments last.
@ -491,0 +477,4 @@
const bool use_only_center,
const float (**r_mat)[4],
short *r_drawflags,
void *data,

By convention, the data pointer is typically the after the callback that uses it (although this kind of thing might be worth documenting).

By convention, the `data` pointer is typically the after the callback that uses it (although this kind of thing might be worth documenting).
@ -503,3 +485,1 @@
protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE, &rv3d->twdrawflag);
}
}
const auto calc_tw_center_with_matrix = [](const float co[3],

This name doesn't seem correct anymore, calc_tw_center_with_matrix is simply calling callback which might calculate anything.

This name doesn't seem correct anymore, `calc_tw_center_with_matrix` is simply calling `callback` which might calculate anything.
@ -506,0 +485,4 @@
const auto calc_tw_center_with_matrix = [](const float co[3],
const bool use_matrix,
const float matrix[4][4],
void (*callback)(const float co[3], void *data),

Prefer the term user_data, as it's clearer the data is caller-defined (data is vague).

Prefer the term `user_data`, as it's clearer the data is caller-defined (`data` is vague).
mano-wii marked this conversation as resolved
Germano Cavalcante force-pushed fix_106993 from b645fa4f2a to 374700ee74 2023-04-21 17:07:35 +02:00 Compare
Germano Cavalcante added 1 commit 2023-04-21 17:17:55 +02:00
Germano Cavalcante merged commit 968ecf6f8b into main 2023-04-21 20:07:16 +02:00
Germano Cavalcante deleted branch fix_106993 2023-04-21 20:07:17 +02:00
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107203
No description provided.