Refactor: resolution_scale in graph_draw.cc #111037

Merged
Christoph Lendenfeld merged 5 commits from ChrisLend/blender:reafactor_graph_draw_res_scale into main 2023-08-17 14:25:25 +02:00

Recent patches added a variable resolution_scale
This variable defines how many points on the x or y axis to add.
However I find the name confusing.

Instead of that, change it to pixels_per_unit
and move the points_per_pixel factor
to calculate_bezt_draw_resolution

This makes also sense in context of #110788: Animation: Graph Editor - Don't draw keys if they are too close to each other

no functional changes

Recent patches added a variable `resolution_scale` This variable defines how many points on the x or y axis to add. However I find the name confusing. Instead of that, change it to `pixels_per_unit` and move the `points_per_pixel` factor to `calculate_bezt_draw_resolution` This makes also sense in context of [#110788: Animation: Graph Editor - Don't draw keys if they are too close to each other](https://projects.blender.org/blender/blender/pulls/110788) no functional changes
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-08-11 11:20:18 +02:00
Christoph Lendenfeld added 1 commit 2023-08-11 11:20:26 +02:00
Christoph Lendenfeld requested review from Nathan Vegdahl 2023-08-11 11:20:35 +02:00
Member

Both names feel about equivalently clear to me: they both give an idea of what it is, but don't define it precisely. So I'm happy for it to be changed if you think it's better, but I don't have a strong opinion myself.

Having said that, if we want to increase clarity here (which is never a bad idea) I think a doc comment on the function explaining its functionality and parameters would be more effective.

Both names feel about equivalently clear to me: they both give an idea of what it is, but don't define it precisely. So I'm happy for it to be changed if you think it's better, but I don't have a strong opinion myself. Having said that, if we want to increase clarity here (which is never a bad idea) I think a doc comment on the function explaining its functionality and parameters would be more effective.
Christoph Lendenfeld added 1 commit 2023-08-11 11:42:11 +02:00
Author
Member

@nathanvegdahl good idea. Added a comment as well

@nathanvegdahl good idea. Added a comment as well
Christoph Lendenfeld added 1 commit 2023-08-11 11:43:22 +02:00
Nathan Vegdahl reviewed 2023-08-11 13:11:33 +02:00
@ -1008,3 +1008,3 @@
}
static blender::float2 calculate_resolution_scale(View2D *v2d)
/** Calculate how many points are needed per unit of the visible range of the View2D based on its
Member

Maybe:

Calculate how many sample points per unit (in both dimensions) are needed to draw curves with adequate resolution in the given View2D, based on the size of the view's units in pixels.

That way it's a little clearer what kind of points we're talking about and for what purpose.

I'm also realizing that it feels to me like the variable points_per_pixel should either be a function parameter, or it shouldn't exist at all (i.e. just substitute 1.0, and then the function becomes pixels_per_unit()). Maybe that's too much for what's supposed to be a tiny PR, though.

Maybe: > Calculate how many sample points per unit (in both dimensions) are needed to draw curves with adequate resolution in the given View2D, based on the size of the view's units in pixels. That way it's a little clearer what kind of points we're talking about and for what purpose. I'm also realizing that it feels to me like the variable `points_per_pixel` should either be a function parameter, or it shouldn't exist at all (i.e. just substitute 1.0, and then the function becomes `pixels_per_unit()`). Maybe that's too much for what's supposed to be a tiny PR, though.
Author
Member

Good point changing it to pixels_per_unit
That is actually what I need for #110788 as well

The points_per_pixel I'd like to keep but that can be moved into the calculate_bezt_draw_resolution function
If I set that to 1 it would make 4 times the amount of points impacting performance

Yes the patch bloated a bit, but it is for good reason :)

Good point changing it to `pixels_per_unit` That is actually what I need for #110788 as well The `points_per_pixel` I'd like to keep but that can be moved into the `calculate_bezt_draw_resolution` function If I set that to 1 it would make 4 times the amount of points impacting performance Yes the patch bloated a bit, but it is for good reason :)
nathanvegdahl marked this conversation as resolved
Christoph Lendenfeld added 1 commit 2023-08-11 14:54:33 +02:00
Christoph Lendenfeld changed title from Refactor: Rename variable in graph_draw.cc to Refactor: resolution_scale in graph_draw.cc 2023-08-11 14:57:39 +02:00
Author
Member

I've changed the function to calculate_pixels_per_unit
the points_per_pixel I've moved to the function calculate_bezt_draw_resolution
I think that makes much more sense

I verified that the resolution returned from calculate_bezt_draw_resolution is the same as before. So it stays at no functional changes

I've changed the function to `calculate_pixels_per_unit` the `points_per_pixel` I've moved to the function `calculate_bezt_draw_resolution` I think that makes much more sense I verified that the resolution returned from `calculate_bezt_draw_resolution` is the same as before. So it stays at no functional changes
Nathan Vegdahl requested changes 2023-08-14 14:38:14 +02:00
Nathan Vegdahl left a comment
Member

Just a couple of comments that are now out of date (I think?) and can be removed at this point. Other than that, looks good to me!

Just a couple of comments that are now out of date (I think?) and can be removed at this point. Other than that, looks good to me!
@ -1009,2 +1012,3 @@
static blender::float2 calculate_resolution_scale(View2D *v2d)
/** Calculate how many points are needed per unit of the visible range of the View2D based on its
* pixel size. */
Member

This doc comment feels out of date to me now. And the name of the function is now pretty self-documenting.
So I'd say just remove the doc comment. (Either that or update it, but I don't think that's necessary.)

This doc comment feels out of date to me now. And the name of the function is now pretty self-documenting. So I'd say just remove the doc comment. (Either that or update it, but I don't think that's necessary.)
nathanvegdahl marked this conversation as resolved
@ -1011,3 +1015,4 @@
static blender::float2 calculate_pixels_per_unit(View2D *v2d)
{
/* The resolution for bezier forward diff in frame/value space. This ensures a constant
* resolution in screen-space. */
Member

This comment is also outdated, I think, and can just be removed.

This comment is also outdated, I think, and can just be removed.
nathanvegdahl marked this conversation as resolved
Christoph Lendenfeld added 1 commit 2023-08-17 10:37:51 +02:00
Christoph Lendenfeld requested review from Nathan Vegdahl 2023-08-17 10:37:55 +02:00
Author
Member

@nathanvegdahl removed both comments. Feels good to do so because it means the code is more self explaining :)

@nathanvegdahl removed both comments. Feels good to do so because it means the code is more self explaining :)
Nathan Vegdahl approved these changes 2023-08-17 12:25:26 +02:00
Nathan Vegdahl left a comment
Member

Looks good to me!

Looks good to me!
Christoph Lendenfeld merged commit 2b30d26ae9 into main 2023-08-17 14:25:25 +02:00
Christoph Lendenfeld deleted branch reafactor_graph_draw_res_scale 2023-08-17 14:25:27 +02:00
Sign in to join this conversation.
No reviewers
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#111037
No description provided.