The main goal of these changes are to improve static (i.e. build-time)
checks on whether a given data can be allocated and freed with `malloc`
and `free` (C-style), or requires proper C++-style construction and
destruction (`new` and `delete`).
* Add new `MEM_malloc_arrayN_aligned` API.
* Make `MEM_freeN` a template function in C++, which does static assert on
type triviality.
* Add `MEM_SAFE_DELETE`, similar to `MEM_SAFE_FREE` but calling
`MEM_delete`.
The changes to `MEM_freeN` was painful and useful, as it allowed to fix a bunch
of invalid calls in existing codebase already.
It also highlighted a fair amount of places where it is called to free incomplete
type pointers, which is likely a sign of badly designed code (there should
rather be an API to destroy and free these data then, if the data type is not fully
publicly exposed). For now, these are 'worked around' by explicitly casting the
freed pointers to `void *` in these cases - which also makes them easy to search for.
Some of these will be addressed separately (see blender/blender!134765).
Finally, MSVC seems to consider structs defining new/delete operators (e.g. by
using the `MEM_CXX_CLASS_ALLOC_FUNCS` macro) as non-trivial. This does not
seem to follow the definition of type triviality, so for now static type checking in
`MEM_freeN` has been disabled for Windows. We'll likely have to do the same
with type-safe `MEM_[cm]allocN` API being worked on in blender/blender!134771
Based on ideas from Brecht in blender/blender!134452
Pull Request: https://projects.blender.org/blender/blender/pulls/134463
With the brush assets project, brushes were moved from being local to
the working blendfile to being linked from asset libraries. This breaks
the Image Paint 'Clone' brush, as it has a brush property that links to
other Image datablocks.
To support this functionality, this commit adds the corresponding
properties into the `ImagePaintSettings` struct so that it is stored
locally with the images that will be used by the tool, inside the main
blendfile.
The source image property is shared with the 3D version of the 'Clone'
brush instead of adding a separate field to preserve old behavior.
Notably, this has the following limitations:
* If clone brush assets have been made and shared with external packs,
they would not work out of the box with linked image assets.
* Despite these settings being stored on the scene, they are populated
inside the tool window under "Brush Settings" which is potentially
misleading. However, this is already the case for the 3D version of
the brush, so further UI refinement will happen outside of this PR.
* Users will be unable to use separate images simultaneously for the
Image editor and the 3D viewport, unlike in pre-4.3 versions. This
can be adjusted in the future if it is a critical workflow.
Because the intended design and functionality of this tool is currently
questionable, this commit opts to make these changes instead of doing
further design to support both accessing data on the brush and on the
scene.
Pull Request: https://projects.blender.org/blender/blender/pulls/134474
The previous attempt to restore this behavior was in
0a2d5d5801
That commit introduced clearing the related `SculptSession` variables
when the paint BVH was freed to avoid bad behaviors seen in 4.2 and
prior. However, this solution is somewhat incorrect, as the prior state
of this data is not necessarily restored when the BVH is recreated,
unlike other temporary mapping data.
This results in the persistent base data being cleared occasionally with
no indication to the user that this is happening, causing the setting to
appear to be inactive.
To fix this, this commit makes a few changes:
* Removes clearing this data in the `BKE_sculptsession_free_pbvh`
function.
* Initializes the displacement arrays to the same size as the position
and normal array.
* Introduce new variables to track the saved multires grid size so
that it is not deleted, only considered invalid when the topology
changes.
Pull Request: https://projects.blender.org/blender/blender/pulls/134780
Though "Point Cloud" written as two words is technically correct and should be used in the UI, as one word it's typically easier to write and parse when reading. We had a mix of both before this patch, so better to unify this as well.
This commit also renames the editor/intern/ files to remove pointcloud_ prefix.
point_cloud was only preserved on the user facing strings:
* is_type_point_cloud
* use_new_point_cloud_type
Pull Request: https://projects.blender.org/blender/blender/pulls/134803
Restriction of the nodes api to clearly define never-null function arguments.
Side effects: some assertions and null-check (with early return) were removed.
On the caller side is ensured to never derefer null to pass argument (mainly in RNA).
In addition, one pointer argument now actually a return type.
By-reference return types instead of pointers going to be separate kind of
change since also imply of cleaning up variables created from reference.
Also good future improvement would be to mark a copy-constructor as
explicit for DNA node types.
Pull Request: https://projects.blender.org/blender/blender/pulls/134627
Keeping these as linked datablocks to the brush does not match the idea
that assets should generally be appended, and leads to some confusing
situations with linked materials on objects. Now use either a local
material with matching weak library reference or make a local copy if
it does not exist yet.
This also add weak library references to the materials in the 2D Animation
template, so they will be reused.
A problem is that weak library references include a full path to assets
blend files, including the Blender version for the essentials assets files.
This means weak library references do not work across platforms and
Blender versions.
Another known limitation is that if the (linked) Brush Asset material is
edited, and there is already a local copy of it, this local copy will
remain unchanged and will be used by future strokes as well.
Ref #131186
Pull Request: https://projects.blender.org/blender/blender/pulls/134226
Add a `--profile-gpu` launch argument.
When set, it generates a profile in the Trace Event Format with CPU and
GPU metrics based on GPU debug scopes.
https://profilerpedia.markhansen.co.nz/formats/trace-event-format/
The profiles are best viewed at https://ui.perfetto.dev/
Notes:
- The profiler captures everything form app start to exit.
- Being JSON based the profiles can become relatively large, but they
compress very well.
- Only OpenGL profiling is supported for now, but the report formatting
code can be shared across backends.
Pull Request: https://projects.blender.org/blender/blender/pulls/133557
This reverts commit afec64739a.
The commit introduces a regression where opening the Asset Browser opens
the File Browser instead, same for other editor sub-types, see
blender/blender#134630.
blender/blender!134642 proposes a different solution and reverts this,
which I prefer too. Better to the revert separately from trying a
different fix for the initial bug, makes reviewing easier too.
This reverts 06a2617107.
Commit has introduced few errors from user perspective (#134277) and
python side (#134380). Best to revert it now then handle the bug fixes later.
The error in #134380 was due to `context.layer_collection` and
`active_layer_collection` returning excluded collection.
Pull Request: https://projects.blender.org/blender/blender/pulls/134546
Note: The point cloud bounding box is not being updated once the points are deleted.
This is a known issue with BKE_pointcloud_nomain_to_pointcloud and Hans is looking into it.
Code inspired/built based on the Delete Geometry node.
Pull Request: https://projects.blender.org/blender/blender/pulls/134622
Previously we generally expected CustomData layers to have implicit
sharing info, but we didn't require it. This PR clarifies that we do
require layers with non-null data to have implicit sharing info. This
generally makes code simpler because we don't have to have a separate
code path for non-shared layers. For example, it makes the "totelem"
arguments for layer freeing functions unnecessary, since shared data
knows how to free itself. Those arguments are removed in this PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/134578
The warning to check if two numbers are nearly equal when comparing
floats didn't take negative numbers into account, causing -1.0 & 0.0
for e.g. to be considered not equal but close.
This also resolves a divide by zero.
The issue is that the existing curves did not have an explicitly set radius.
When adding new curves with an explicit radius, the radius of the old curves was
initialized to 0 and thus becoming invisible. This patch changes it so that all
the existing curves do get a default radius. The `radius_for_write` methods is
currently only used in places that overwrite the entire array, so adding the
default there shouldn't affect anything unintentionally.
Pull Request: https://projects.blender.org/blender/blender/pulls/134445
When calling the `lookup_or_add` functions on `MutableAttributeAccessor`
we need to make sure that the writer is actually created and the call
did not fail.
This fixes many of the instances where we would use an unchecked
attribute writer and potentially crash.
Pull Request: https://projects.blender.org/blender/blender/pulls/134413
This fixes the (unreported) issue where solo'ing an NLA track would only
play back animation when _any_ of the tracks were unmuted.
Some code considered a track to be muted when its `NLATRACK_MUTED` flag
was set regardless of the `NLATRACK_SOLO` flag, whereas other code did
consider the `NLATRACK_SOLO` flag.
Now all the code is consistent with what actual animation evaluation is
doing.
Pull Request: https://projects.blender.org/blender/blender/pulls/134500
Caused by 81a63153d0.
Previously this was done by BKE_objects_materials_sync_length_all.
Now that function only adds a tag when it actually does something.
This implements the memorization of the previous state of a space's
subtype for those that have multiple modes. Introduces an optional
space_subtype_prev_get callback, implemented for SPACE_ACTION,
SPACE_FILE, SPACE_GRAPH, SPACE_IMAGE and SPACE_NODE. This means we
can always return to the previous mode.
Pull Request: https://projects.blender.org/blender/blender/pulls/133846