Fix #127077: Edit voxel size op unpredictable with large/small meshes #127109

Merged
Philipp Oeser merged 2 commits from lichtwerk/blender:127077 into main 2024-09-05 16:31:24 +02:00
Member

If voxel sizes were big, code could run into clamping at 1.0f, making it
look like nothing was happening, also even though the "step size" was
taking into account the initial voxels size (only in relative mode,
absolute mode was, well... absolute, no matter what object this was
happening on, also see 5946ea938a).

So previously, a reasonable voxels size could not achieved using this
operator for e.g. a terrain-size mesh.

Now code allows for bigger/smaller meshes to behave predictably.
This is done by storing a reasonable min and max voxel size (this is
taken from the bounding plane which is also displayed to the user),
making the max the length of the longer side of the bounding plane and
the min a fraction of it (based on VOXEL_SIZE_EDIT_MAX_GRIDS_LINES --
smaller voxels would not display anyways...)

Based on the above, we can have a reasonable range to base the change on
which is done moving the mouse.
Because this is more predictable than before, we can even remove the
relative mode (dont think it makes too much sense now anymore).

If voxel sizes were big, code could run into clamping at 1.0f, making it look like nothing was happening, also even though the "step size" was taking into account the initial voxels size (only in relative mode, absolute mode was, well... absolute, no matter what object this was happening on, also see 5946ea938a07bf95c7682af919ee33c715e1fa42). So previously, a reasonable voxels size could not achieved using this operator for e.g. a terrain-size mesh. Now code allows for bigger/smaller meshes to behave predictably. This is done by storing a reasonable min and max voxel size (this is taken from the bounding plane which is also displayed to the user), making the max the length of the longer side of the bounding plane and the min a fraction of it (based on `VOXEL_SIZE_EDIT_MAX_GRIDS_LINES` -- smaller voxels would not display anyways...) Based on the above, we can have a reasonable range to base the change on which is done moving the mouse. Because this is more predictable than before, we can even remove the `relative` mode (dont think it makes too much sense now anymore).
Philipp Oeser added 1 commit 2024-09-03 15:56:55 +02:00
If voxel sizes were big, code could run into clamping at 1.0f, making it
look like nothing was happening, also even though the "step size" was
taking into account the initial voxels size (only in relative mode,
absolute mode was, well... absolute, no matter what object this was
happening on, also see 5946ea938a).

So previously, a reasonable voxels size could not achieved using this
operator for e.g. a terrain-size mesh.

Now code allows for bigger/smaller meshes to behave predictably.
This is done by storing a reasonable min and max voxel size (this is
taken from the bounding plane which is also displayed to the user),
making the max the length of the longer side of the bounding plane and
the min a fraction of it (based on `VOXEL_SIZE_EDIT_MAX_GRIDS_LINES` --
smaller voxels would not display anyways...)

Based on the above, we can have a reasonable range to base the change on
which is done moving the mouse.
Because this is more predictable than before, we can even remove the
`relative` mode (dont think it makes too much sense now anymore).
Philipp Oeser requested review from Julien Kaspar 2024-09-03 15:57:10 +02:00
Philipp Oeser requested review from Sean Kim 2024-09-03 15:57:16 +02:00
Philipp Oeser added this to the Sculpt, Paint & Texture project 2024-09-03 15:57:23 +02:00
Sean Kim reviewed 2024-09-04 01:47:41 +02:00
Sean Kim left a comment
Member

Minor nits, still need to test this behaviorally though

Minor nits, still need to test this behaviorally though
@ -415,3 +406,1 @@
d = d * 0.0005f;
cd->relative_mode = false;
}
d *= cd->voxel_size_min * 0.25f;
Member

Was this 0.25f value just determined experimentally?

Was this `0.25f` value just determined experimentally?
Author
Member

This gives the same "speed" for the default cube.
cd->voxel_size_min is 0.002f for the default cube and previously we multiplied (hardcoded) with 0.0005f

This gives the same "speed" for the default cube. `cd->voxel_size_min` is `0.002f` for the default cube and previously we multiplied (hardcoded) with `0.0005f`
Sean-Kim marked this conversation as resolved
@ -516,6 +506,12 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
}
/* Set reasonable min/max voxel sizes to clamp to. */
Member

As is this comment doesn't seem particularly helpful; I think if any part warrants a comment it'd be stating that we cap the min size based on the point where we cant visually display any more info.

As is this comment doesn't seem particularly helpful; I think if any part warrants a comment it'd be stating that we cap the min size based on the point where we cant visually display any more info.
Sean-Kim marked this conversation as resolved
Philipp Oeser added 1 commit 2024-09-04 10:28:28 +02:00
improve comment
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
8c1a68c50a
Sean Kim approved these changes 2024-09-04 22:45:39 +02:00
Sean Kim left a comment
Member

Behavior here seems sane to me in testing both the provided mesh in the bug report and on a default cube. I think I'd still prefer if @JulienKaspar took a look as well before merging this in case there is some reason we would want to keep the old "Relative Mode" or if this behaves weirdly for some other usecases that I'm unaware of.

Behavior here seems sane to me in testing both the provided mesh in the bug report and on a default cube. I think I'd still prefer if @JulienKaspar took a look as well before merging this in case there is some reason we would want to keep the old "Relative Mode" or if this behaves weirdly for some other usecases that I'm unaware of.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR127109) when ready.
Julien Kaspar approved these changes 2024-09-05 14:59:20 +02:00
Julien Kaspar left a comment
Member

I think this works well. It's true that the relative mode is not really needed anymore then.

I think this works well. It's true that the relative mode is not really needed anymore then.
Philipp Oeser merged commit 4221f827cf into main 2024-09-05 16:31:24 +02:00
Philipp Oeser deleted branch 127077 2024-09-05 16:31:32 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
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 Assignees
4 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#127109
No description provided.