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
The File Output node crashes when saving a 16-bit vector image in an
RGBA image. That's because the OIIO writer assumes 4-channel buffer
while the buffer provided by the node is only 3-channel. To fix this,
the OIIO writer is extended to support all possible combination of
source and target channels.
Pull Request: https://projects.blender.org/blender/blender/pulls/134789
In the past, around the time that 2.80 was released, 4a08b974f4
introduced the idea of filtering out certain editor changes inside
the paint modes and edit mode (e.g. changing brush sizes in the editor).
This commit is the first in a series to attempt to refine this behavior
so that only certain editor settings are filtered out from the undo
stack.
In total, it does the following:
* Adds the Brush datablock to the list of IDs that do not have undo
pushes.
* Adds support to filter out RNA structs that do not have the
`STRUCT_UNDO` property applied (currently, just the 3D Cursor).
This has the following effects:
* Changing brush settings inside the Image Editor no longer causes
undo pushes, becoming consistent with the other paint modes.
* Changing brush settings while in object mode in the outliner data
block view no longer causes undo pushes.
Co-authored-by: Campbell Barton <campbell@blender.org>
When a text string is longer than the available space it can be at a
scrolled offset, so that you can edit text that is wider than its
container. When selected text is deleted we don't update this offset,
so it is possible to have newly pasted text scrolled out of view. This
PR decreases the offset by the amount of the selected string that is
currently out of view.
Pull Request: https://projects.blender.org/blender/blender/pulls/134815
These were reading in "widths" and not adjusting the values when setting
Blender's "radius" properties.
Found while cleaning up the radius API usage as part of another change.
Pull Request: https://projects.blender.org/blender/blender/pulls/134709
Right now this code is only used to convert boolean arrays to bits (e.g. for
faster `IndexMask` generation). This patch extracts a more general function that
converts bytes to bits using a rule that is passed in as parameter. This may
become useful to speedup parsing e.g. CSV files to speedup detection of
delimiters and other special byte values.
This code is already covered by unit tests, so no new tests have been added.
Pull Request: https://projects.blender.org/blender/blender/pulls/134798
This commit moves the initialization of the node-sized accumulation
array out of the parallel loop to avoid odd optimization errors when
differing between debug and release builds as well as errors due to
integer overflow in both builds.
Additionally it only accumulates results from affected nodes.
Pull Request: https://projects.blender.org/blender/blender/pulls/134720
The `init_positions` variable that the `ss.sculpt_persistent_co` member
gets set to was not passed into the corresponding calculation function,
resulting in a no-op.
Pull Request: https://projects.blender.org/blender/blender/pulls/134781
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
The playhead is redrawn as an overlay, so instead of a full region
redraw using `ARegionType.draw()`, at least an overlay only redraw using
`ARegion.draw_overlay()` needs to be triggered.
Any redrawing within a window is skipped if neither the screen, nor any
of its areas or regions are tagged for redraw. So since there are no
other areas or regions to be fully redrawn in this window, no redrawing
will happen. The screen needs to be tagged for redraw, which will skip
most drawing in this case, and just draw the overlays as wanted.
Pull Request: https://projects.blender.org/blender/blender/pulls/134579
When using the Error theme color for widget text color, this has to be
altered to provide sufficient contrast with other content. This was
done with label text color, before recent changes to make these colors
themeable, by blending with text color. This PR makes similar changes
and gives similar results.
Pull Request: https://projects.blender.org/blender/blender/pulls/134807
When changing editors within an area we are currently always setting
the subtype if there are modes. This causes problems when returning to
a previous editor versus starting with the correct one. We have tried
various ways of returning to the old editor, but never quite works.
This PR only sets the subtype if we are creating a new area. If not
just leave it as it was so we naturally return to its old state.
Pull Request: https://projects.blender.org/blender/blender/pulls/134642
During idle time, just moving your mouse into an editor, the Status Bar
only shows operations attached to mouse events. Hovering into
Properties shows an item on the left mouse called "Set Active
Modifier". This is always shown because it is an internal operator
always running in that area. This PR just skips OPTYPE_INTERNAL
operators for this idle display.
Pull Request: https://projects.blender.org/blender/blender/pulls/134782
Move the mask_random function to BLI_index_mask.hh, so it can be shared between curves, grease pencil and point cloud.
Copied/inspired by the curves select code.
Pull Request: https://projects.blender.org/blender/blender/pulls/134624
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
Previously, the code would assert in `BLI_fopen` when the path is relative.
There are two main options to make the path absolute:
1. Always use the path of the current .blend file as base.
2. Is the path of the .blend file "owns" the current node as base. So when
the Import node is part of a linked node tree, the path of the linked .blend
file is used as base.
Both options are useful depending on the specific use-case, but the latter
seems more consistent with other places in Blender. For more advanced
functionality, we might need nodes that give the current .blend file path
and one node to join paths.
Pull Request: https://projects.blender.org/blender/blender/pulls/134794
Previously the object join operator wasn't implemented for the new
curves type. This commit implements the joining by passing the selected
curves geometry as instances to the realize instances function. That way
the complexity of the new code just relates to dealing with objects.
Pull Request: https://projects.blender.org/blender/blender/pulls/134691
This adds:
- support for snapping for the pointcloud object (selection to cursor/
grid, cursor to selection)
- as usual, "Warp" an "Randomize" operators come along "for free" with
this
Pull Request: https://projects.blender.org/blender/blender/pulls/134799
The new CPU compositor in v4.4 is much slower than the old CPU
compositor in v4.3 on Windows. This is because MSVC does not inline many
of the core methods in the Result class of the compositor. To fix this,
we force inline those methods, adding a new macro for inlining methods
in the process, since the existing macro has the static keyword, which
only works for functions, not methods.
Pull Request: https://projects.blender.org/blender/blender/pulls/134748
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
This reimplements the CSV parser used by the (still experimental) Import CSV
node.
Reliability is improved by:
* Properly handling quoted fields.
* Unit tests.
* Generalizing the parser to be able to handle customized delimiter, quote and
escape characters (those are not exposed in the node yet though).
* More accurate detection of column types by actually taking all values of a
column into account instead of only the first row.
Performance is improved by designing the parser in a way that supports
multi-threaded parsing. I'm measuring about 5x performance improvement which
mainly comes from multi-threading. Some files I wanted to use for benchmarking
didn't load in the version that's in `main` but do load fine with this new
version.
The implementation is now split up into two parts:
1. A general CSV parser in `blenlib` that manages splitting a buffer into
records and their fields.
2. Application specific parsing of fields into e.g. floats and integers which
remains in `io/csv/importer`.
This separation simplifies unit testing and makes the core code more reusable.
Pull Request: https://projects.blender.org/blender/blender/pulls/134715
Correct two mistakes in [0] which accidentally assigned
flags to the previously declared parameter as well as assigning an
argument to `prop`, then setting the flags on `parm`.
While it seems that "active_property" only became optional by accident
leave this as-is to avoid breaking scripts.
[0]: 113997a03c
Ref #134379.
This PR adds three SVG Icons. One to represent that an icon is not
found - ICON_NOT_FOUND - so represent when an out-of-range value was
used to specify an icon. The second - ICON_CHAR_NOTDEF - is to
represent that a text character is not found in the specified font or
font stack. The third - ICON_CHAR_REPLACEMENT - is to indicate the
portion of a text string that contains invalid bytes.
Pull Request: https://projects.blender.org/blender/blender/pulls/134008
Conversion was only possible if the active object was editable &
selected, this complicated overriding the operator from Python
since it wasn't enough to override the selection & active-object.
Now it's possible to use bpy.ops.object.convert() from Python
overriding the selected_editable_objects only.
For users the difference isn't so significant:
- Having an active object is no longer required.
- It's possible there are no objects to operate on,
as previously the active object was used to check at least one
object could be converted, although this check wasn't fool-proof
as it didn't check the objects data-type.
Resolves#100664.
Ref !134728.