Adds a generic `is_larger` and `get_aspect_scaled_extent` function to
simplify packing logic.
Migrate several packing functions so that they only improve a layout,
and early-exit packing if a better layout already exists.
Fix a `rotate_inside_square` logic error during xatlas packing.
BLI_strncpy_utf8 didn't check for null bytes within bytes stepped
over by the variable length UTF8 encoding.
While a valid UTF8 string wont include these, it's possible Latin1
encoding or a truncated string includes such characters.
In this case, the entire string is copied as it's not the purpose of
this function to correct or strip invalid/truncated encoding,
only to prevent it from happening in the first place.
Use the offset indices pattern to avoid keeping separate arrays for the
offset of a vertex's neighbors and the number of neighbors. This gave
a 9% speedup for the conversion, from 42.9 ms to 39.3 ms.
In vertex extrusion mode, when there are no edge attributes we can avoid
creating a topology map meant for mixing old values. This makes
simulation caching for a curl noise demo file from user Higgsas 10%
faster (from 44s to 40s to calculate 230 frames).
Adds a `remap_pairing` function for node group operators that ensures
the simulation input nodes' `output_node_id` matches the new node are
creating a group, ungrouping a node group, or separating from a group.
Also fixes a crash in the "Group Separate" operator when group
input/output nodes are included in the selection.
Pull Request: https://projects.blender.org/blender/blender/pulls/107807
Issue was that, when UI-related code _is_ requested in foreach_id
processing, `ID_SCR` screen ID type can actually use any kind of ID
(through e.g. the Outliner space).
So `BKE_library_id_can_use_filter_id` had to be updated with a new
parameter (whether UI-related data should be taken into account or not).
The root of the issue was that while reading a new blendfile, the
current `G_MAIN` is still the old one, not the one in which new data is
being read.
Since the remapping callback taking care of UI data during ID remapping
is using `G_MAIN`, it is processing the wrong data, so when deleting the
invalid shapekey (from `BLO_main_validate_shapekeys`), the UI data of
the new bmain would not be properly remapped, causing invalid memory
access later when recomputing user counts (calls to
`BKE_main_id_refcount_recompute`).
This is fixed by adding a new `BKE_id_delete_ex` function that takes
extra remapping options parameter, and calling it from
`BLO_main_validate_shapekeys` with extra option to enforce handling of
UI data by remapping code.
NOTE: At some point we have to check if that whole UI-callback thing is
still needed, would be good to get rid of it and systematically process
UI-related ID pointers like any others. Current situation is... fragile
to say the least.
For realtime use cases, storing the geometry's state in memory at every
frame can be prohibitively expensive. This commit adds an option to
disable the caching, stored per object and accessible in the baking
panel. The default is still to enable caching.
Pull Request: https://projects.blender.org/blender/blender/pulls/107767
Caused by 2fb31f34af.
Since above commit, we are now calling `BKE_mesh_orco_verts_transform`
not only from `psys_face_mat` and `psys_mat_hair_to_orco`, but now also
from `psys_particle_on_dm` > `psys_interpolate_face`, so we get double
transforms with mirror.
Remove the "extra" call in `psys_mat_hair_to_orco`.
Should be backported to 3.3 LTS as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/107804
Avoid storing redundant and unnecessary data in temporary arrays during
face corner normal calculation with custom normals. Previously we used
96 bytes per normal space (`MLoopNorSpace` (64), `MLoopNorSpace *` (8),
`LinkData` (24)), now we use 36 (`CornerNormalSpace` (32), `int` (4)).
This is achieved with a few changes:
- Avoid sharing the data storage with the BMesh implementation
- Use indices to refer to normal fan spaces rather than pointers
- Only calculate indices of all corners in each fan when necessary
- Don't duplicate automatic normal in space storage
- Avoid storing redundant flags in space struct
Reducing memory usage gives a significant performance improvement in
my test files, which is consistent with findings from previous commits
(see 9fcfba4aae). In my test, the time used to calculate
normals for a character model with 196 thousand faces reduced from
20.2 ms to 14.0 ms, a 44% improvement.
Edit mode isn't affected by this change.
A note about the `reverse_index_array` function added here: this is the
same as the mesh mapping functions (for example for mapping from
vertices to face corners). I'm planning on working this area and hoping
to generalize/reuse the implementation in the near future.
Pull Request: https://projects.blender.org/blender/blender/pulls/107592
The new theme setting for the dope sheet (timeline) allows changing the
color of the bar that shows which frames are cached/baked. The
invalid/cached/baked status is differentiated by hardcoded transparency
values. In theory, those could be separate theme settings though.
Pull Request: https://projects.blender.org/blender/blender/pulls/107738
Operations such as assigning or removing weights were simply not
undoable (no previous weights were applied back to the EditLatt). Now
add MDeformVert data to UndoLattice and handle with
appropriate functions during Undo.
Pull Request: https://projects.blender.org/blender/blender/pulls/107776
Blender would fail to link to USD before MaterialX files were
copied to the install targets lib/ directory.
Resolve by including ${LIBDIR}/materialx/lib in link_directories.
looptris were referred to as both tris & faces, sometimes polygons
were referred to as faces too. Was especially error prone with
callbacks that took both a tri and a tri_i arguments.
Sometimes tri_i represented a looptri index, other times the corner of
the triangle from 0-2. Causing expressions such as:
`args->mlooptri[tri].tri[tri_i]`
- Rename tri & tri_index -> looptri_i.
- Rename faces -> looptris.
- Rename face_index/poly_index/poly -> poly_i.
- Declare looptri_i at the start of the loop and reuse it,
in some cases it was declared with args->prim_indices[i] being
used as well.
Change PBVH normal calculation to also update vertices connected to
vertices with an update tag. This is necessary because vertex normals
are the mixed face normals, so changing any face's normal will change
the normals of all connected faces.
This change requires that the PBVH always have a vertex to face
topology map available. In the future this will likely be cached on
meshes though, which will reduce the delay it adds when entering sculpt
mode.
Now, first all face normals are updated, then the normals for
connected vertices are mixed from the face normals. This is a
significant simplification to the whole process, which previously
worked with atomics and normals at the triangle level. Similar changes
changes for regular non-sculpt normal calculation are being worked on
in #105920.
Pull Request: https://projects.blender.org/blender/blender/pulls/107458
In some cases strips may end up with speed factor of 0 which causes
offsets and position to be invalid. The exact cause is unknown, but
most likely caused by `do_versions_sequencer_init_retiming_tool_data()`.
This could possibly happen if 3.6 file is saved with 3.5 version and
then opened again with 3.6 version.
To fix strips, retiming data is removed, start offset reset and speed
factor is set to 1. Previous versioning code is fixed, so speed factor
is never set to 0.
Pull Request: https://projects.blender.org/blender/blender/pulls/107798
Avoid instantiating the templates separately in every translation unit.
This saves 20 KB in my Blender binary. Also remove a timer mistakenly
committed.
After recent Linux library updates. The EMBREE_SYCL_SUPPORT variable that
this relied on was not cached.
Always install the sycl shared libraries regardless of build options, as
we do for other shared libraries.
This saves about 6 ms every update when in edit mode on a 1 million
face grid. For reference, the BMesh to Mesh conversion took 80 ms,
before and after the change.
This was added temporarily during development.
Loading files created in the geometry-nodes-simulation branch (3.5.4
and older) will remove links from simulation zones, which need to be
added back manually.
Pull Request: https://projects.blender.org/blender/blender/pulls/107781
Similare to the Metal backend, Vulkan keeps data of the full texture
around as they will be executed by the same submission. So there are
no benefits to splice a texture into smaller parts, but adds overhead
as more commands are required to be processed.
Pull Request: https://projects.blender.org/blender/blender/pulls/107728
The HSV node in the realtime compositor produces different values from
the CPU compositor in its identity settings.
This happens because the realtime compositor clamped the saturation
value after HSV correction, while the CPU compositor did not, so this
patch unifies that behavior. Additionally, negative values are now
clamped in both the HSV node and Hue correction node to also match the
CPU compositor.
The main goal here is to reduce the number of times thread-local data has
to be looked up using e.g. `EnumerableThreadSpecific.local()`. While this
isn't a bottleneck in many cases, it is when the action performed on the local
data is very short and that happens very often (e.g. logging used sockets
during geometry nodes evaluation).
The solution is to simply pass the thread-local data as parameter to many
functions that use it, instead of looking it up in those functions which
generally is more costly.
The lazy-function graph executor now only looks up the local data if
it knows that it might be on a new thread, otherwise it uses the local data
retrieved earlier.
Alongside with `UserData` there is `LocalUserData` now. This allows users
of the lazy-function evaluation (such as geometry nodes) to have custom
thread-local data that is passed to all the lazy-functions automatically.
This is used for logging now.
The pose library blending code assumed that quaternions would be keyed
in order of `array_index`. This is normally the case when creating a
pose asset, but when manually editing a pose asset Action this
assumption may not hold.
The code still assumes that all FCurves of a single quaternion are
sequential, i.e. are not inter-mixed with other keyed properties. They
just no longer have to be ordered by array index.
Ref: blender-addons/issues#104591
This patch implements the Denoise node for the realtime compositor. The
denoiser executes on the CPU and we pay for the CPU<->GPU round trip to
memory, so this is not realtime, as one might expected. And is just a
temporary implementation until OIDN supports GPU execution.
This is different from the CPU implementation in that it doesn't use the
auxiliary passes if they were not provided, because using an inflated
buffer of an undefined value doesn't make much sense.
Pull Request: https://projects.blender.org/blender/blender/pulls/107375
In Vulkan it is not allowed to allocate a buffer of zero bytes. This
would generate an error. In Blender it is possible that a buffer is zero
bytes. For example when the draw manager is drawing instances and there
are no instanced in the scene.
This PR ensures that at least a single byte is allocated in order to not
fail later on.
Co-authored-by: Jeroen Bakker <j.bakker@atmind.nl>
Pull Request: https://projects.blender.org/blender/blender/pulls/107731