Pointers to hide status layers and custom data are removed,
since they can be accessed from the mesh as necessary.
Usage of other arrays has been reduced, so the pointers
can eventually be removed.
The reasoning is the same as some other commits in this area:
the goal is less duplication of state, and a more focused design
of the responsibilities of the PBVH class.
Some of the changes are fairly noisy, since we need to add
arguments to functions in a few places. On the nicer side of
things, some functions for syncing the state can be removed.
Not retrieving hide layers with write access also has performance
implications in some cases, since it means the original arrays can
be reused without a copy when they're shared.
This improves the early out in the mesh case so that it isn't
repeated for every node. Also simplifies using more local
variables that are specific to a certain PBVH type (in this
case, switching to the C++ attribute API and retrieving the
vertex visibility status that way).
- CTX_wm_region(C) must be NULL checked as it's not checked in the
poll function.
- Add back the removed flag, note it's dirty.
- Replace ternary operators with min/max.
Prefer the name 'hit_result' since 'result' was sometimes used for
a vector of GPUSelectResult and is often used a functions return value.
Use hit_results for the span/vector and hit_result for a single hit.
Also assign struct members for new GPUSelectResult as it reads better
and avoids depending on struct order.
- Pass Span by value. It is a small struct, and passed by reference
it acts as a pointer to a pointer.
- Remove unnecessary `= {}`. Vector has a default constructor.
- Use initializer list Span constructor to avoid temporary array.
Pull Request: https://projects.blender.org/blender/blender/pulls/115635
These are just duplicates of the pointers in `SubdivCCG`, which are
already quickly accessible. Keeping track of the state is too complex
and bloats the responsibilities of the PBVH too much.
This commit aim at making the behaviors of `BLI_rename` and
`BLI_rename_overwrite` more consistent and coherent across all
supported platforms.
* `BLI_rename` now only succeeds in case the target `to` path does not
exists (similar to Windows `rename` behavior).
* `BLI_rename_overwrite` allows to replace an existing target `to` file
or (empty) directory (similar to Unix `rename` behavior).
NOTE: In case the target is open by some process on the system, trying
to overwrite it will still fail on Windows, while it should succeed on
Unix-like systems.
The main change for Windows is the usage of `MoveFileExW`
instead of `_wrename`, which allows for 'native support' of file
overwrite (using the `MOVEFILE_REPLACE_EXISTING` flag). Directories
still need to be explicitly removed though.
The main change for *nix systems is the use of `renamex_np` (OSX) or
`renameat2` (most Linux systems) to allow forbidding renaming to an
already existing target in an 'atomic' way.
NOTE: While this commit aims at avoiding the TOC/TOU problem as
much as possible by using available system's primitives for most
common cases, there are some situations where race conditions
(filesystem changes between checks on FS state, and actual rename
operation) remain possible.
Pull Request: https://projects.blender.org/blender/blender/pulls/115096
Parallelize the implementation and move constant checks out of hot
loops. Only push undo steps for PBVH nodes that actually have changed
hide status. Optimize the "show all" case to remove the hide attributes.
For timings, I recorded some information on a 16 million vertex mesh:
- Hide masked (1/4 of mesh): 171 ms to 33 ms
- Hide small box: 13 ms to 14 ms
- Show all with small box hidden: 226 ms to 10 ms
- Show with all visible: 173 ms to 0.36 ms
There are a few other visbility operators that aren't affected:
- SCULPT_OT_face_set_invert_visibility
- SCULPT_OT_reveal_all
- SCULPT_OT_face_set_change_visibility
In separate steps, they should be moved to use the same structure, or
maybe even removed in the case of "reveal all".
I expect the "gather, change hidden verts, scatter" steps for each node
could be made a bit more efficient, they do some redundant work.
But it was also a simple way to share a reasonable amount of code.
Use multithreading, plus make the non-float / non-separate luma
calculations faster by avoiding byte->float->byte conversions
back and forth.
On a 4K resolution sequencer display, time taken to calculate the
waveform (Windows, Ryzen 5950X):
- regular images: 127.0ms -> 6.4ms
- regular images, separate colors: 160.3ms -> 13.1ms
- float images: 86.2ms -> 11.1ms
- float images, separate colors: 162.9ms -> 17.4ms
This also fixes curious "one black pixel row" in the middle of the
waveform, which was caused by the code spreading 256 possible luma
values over "off by one" vertical range:
Pull Request: https://projects.blender.org/blender/blender/pulls/115579
Exposed by 383a145a19.
Think the issue actually started in cfa53e0fbe, since then the new
destination normals were only filled from the first array copy onwards
(probably hidden by some recalculation of normals somewhere?).
In any case, starting the destination normals array with what we have
from the input mesh normals and then resizing the array (instead of
reinitializing it from scratch) fixes this.
Pull Request: https://projects.blender.org/blender/blender/pulls/115612
The grease pencil draw tool would still do a lot of smoothing
even if the active smoothing factor was set to 0.0.
This was because the screen space coordinates were always pre-blurred
before being passed to the curve fitting. Even if the curve fitting
outputs a line that fits the input exactly, it would still use the pre
smoothed coordinates.
The fix makes sure to use the smoothing factor in the influence
of the pre-blur. This way, no pre-blur is used when the factor is 0
and the lines will be smoothed much less.
Note that we always do some smoothing to avoid artifacts such
as pixel-grid-aligned lines etc.
When keyframing with the `Only Insert Needed` flag enabled,
the code was able to delete keyframes in certain cases.
This behavior is removed and replaced with the following rules.
* If there is a key on the current frame, and it has the same value, skip it.
* If there is no key, but the FCurve evaluates to the same value, skip it.
* Add a key in all other cases.
Remove that functionality for consistency and simplify the code around it.
Pull Request: https://projects.blender.org/blender/blender/pulls/115360
This patch adds a number of utilities to handle texture formats and
their relation to result types and precisions. This is needed for future
work, and also unifies the places one needs to update when adding a new
result type.
Between Blender versions, properties of some operators may be removed.
When this happens, when importing the keymap from the previous version,
a series of warnings may appear in the console. For example:
```
Warning: property 'alt_navigation' not found in item 'TRANSFORM_OT_translate'
Warning: property 'alt_navigation' not found in item 'TRANSFORM_OT_rotate'
Warning: property 'alt_navigation' not found in item 'TRANSFORM_OT_resize'
Warning: property 'alt_navigation' not found in item 'VIEW3D_OT_edit_mesh_extrude_move_normal'
...
```
Therefore, it seems to be convenient to edit these properties when
versioning.
This commit implements a `remove_properties` utility that makes this
removal simpler.
Pull Request: https://projects.blender.org/blender/blender/pulls/114936
You could already do overshoot via the mouse, but it was arbitrarily
disallowed when entering values numerically. This simply lifts that
restriction so that numerical input is capable of the same things as
dragging the mouse.
Importantly, the operator slider code already appropriately clamps
both mouse and numerical input when needed. So the checks and clamping
removed in this commit simply aren't needed, and removing them just
makes numerical input get constrained exactly the same as mouse input.
Pull Request: https://projects.blender.org/blender/blender/pulls/115534
This patch implements a new mechanism for compositor results to wrap
external images, such as those cached in the static cache manager.
Thereby enabling zero cost use of those resources, which previously
needed a copy at each evaluation.
Pull Request: https://projects.blender.org/blender/blender/pulls/115574