Commit Graph

21262 Commits

Author SHA1 Message Date
Jacques Lucke d4c868da9f Geometry Nodes: refactor virtual array system
Goals of this refactor:
* Simplify creating virtual arrays.
* Simplify passing virtual arrays around.
* Simplify converting between typed and generic virtual arrays.
* Reduce memory allocations.

As a quick reminder, a virtual arrays is a data structure that behaves like an
array (i.e. it can be accessed using an index). However, it may not actually
be stored as array internally. The two most important implementations
of virtual arrays are those that correspond to an actual plain array and those
that have the same value for every index. However, many more
implementations exist for various reasons (interfacing with legacy attributes,
unified iterator over all points in multiple splines, ...).

With this refactor the core types (`VArray`, `GVArray`, `VMutableArray` and
`GVMutableArray`) can be used like "normal values". They typically live
on the stack. Before, they were usually inside a `std::unique_ptr`. This makes
passing them around much easier. Creation of new virtual arrays is also
much simpler now due to some constructors. Memory allocations are
reduced by making use of small object optimization inside the core types.

Previously, `VArray` was a class with virtual methods that had to be overridden
to change the behavior of a the virtual array. Now,`VArray` has a fixed size
and has no virtual methods. Instead it contains a `VArrayImpl` that is
similar to the old `VArray`. `VArrayImpl` should rarely ever be used directly,
unless a new virtual array implementation is added.

To support the small object optimization for many `VArrayImpl` classes,
a new `blender::Any` type is added. It is similar to `std::any` with two
additional features. It has an adjustable inline buffer size and alignment.
The inline buffer size of `std::any` can't be relied on and is usually too
small for our use case here. Furthermore, `blender::Any` can store
additional user-defined type information without increasing the
stack size.

Differential Revision: https://developer.blender.org/D12986
2021-11-16 10:16:30 +01:00
Hans Goudey 57ed435def Cleanup: Use C++ matrix identity constructor 2021-11-15 23:24:16 -06:00
Richard Antalik 46f5f60c13 Merge branch 'blender-v3.0-release' 2021-11-15 20:33:34 +01:00
Richard Antalik ef8240e64c Fix T91992: Incorrect clip strip image size
When proxy size lower than 100% is used, clip strips are rendered with
incorrect image size.

This is because if proxies aren't enabled in movieclip, it automatically
falls back on rendering original media. Sequencer doesn't have knowledge
about this and since 9c99292a16 it assumes that image is proxy,
because it explicitly requested this size.

Check movieclip flag to see if proxies are enabled.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13080
2021-11-15 20:07:46 +01:00
Jacques Lucke 10a6a540af Cleanup: remove unnecessary functions
Those functions were more useful when `FieldInferencingInterface`
was still declared further down in `node.cc`.
2021-11-15 18:04:03 +01:00
Hans Goudey 8976b72843 Merge branch 'blender-v3.0-release' 2021-11-15 09:10:19 -06:00
Antonio Vazquez c3472cb11c Fix T93074: Gpencil cutter not using flat caps in middle cuts
When cut an stroke using the option Flat Caps, the falt was not done if the cut was done in the middle of the stroke.

Now the flat is applied to the segments created and also some cleanup of the code done.
2021-11-15 12:17:11 +01:00
Jeroen Bakker a5c59fb90e Fix T89260: Eevee crashes with custom node sockets.
Cause of this issue is that Custom Node Sockets info type was
initialized as SOCK_FLOAT when registering. Areas within the core that
would ignore custom socket types by checking its type would use the
socket as being a float type.

When custom node sockets have a property called default_value blender
tries to store it as an internal default value what failed in debug
builds.

This patch will set the socket type to SOCK_CUSTOM when registering a
custom socket type and allow, but skip storage of custom default values.
In this case the default values should already be stored as custom
properies.

Reviewed By: campbellbarton, JacquesLucke

Maniphest Tasks: T89260

Differential Revision: https://developer.blender.org/D13174
2021-11-15 08:13:22 +01:00
Harley Acheson 73047c69ea BLF: Use Floats for Font Point Sizes
Allow the use of floating-point values for font point sizes, which
allows greater precision and flexibility for text output.

See D8960 for more information, details, and justification.

Differential Revision: https://developer.blender.org/D8960

Reviewed by Campbell Barton
2021-11-13 09:39:18 -08:00
Campbell Barton ab9ec193c3 Fix splash screen showing on startup with files loaded by scripts
Suppressing the splash was only done when passing in an argument from
the command line.

Remove G.file_loaded, as it is misleading, only set once on startup,
replace with G.relbase_valid which is used everywhere else to check
if the file path should be used.
2021-11-13 14:05:27 +11:00
Campbell Barton 1143bf281a Cleanup: spelling in comments, comment block formatting 2021-11-13 13:07:13 +11:00
Campbell Barton acc800d24d Cleanup: clang-format 2021-11-13 12:47:18 +11:00
Hans Goudey d845ba481c Fix T91826: Inconsistent node socket name identifier separator
Previously both `.` and `_` were used as separators when finding
a unique name for a socket. This removes the use of `.`, since `_`
was more common. It also does versioning for all of a file's node
trees to make sure that they all use the `_` convention.

Differential Revision: https://developer.blender.org/D13181
2021-11-12 12:22:43 -06:00
Sybren A. Stüvel ddf66cd060 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-12 14:36:55 +01:00
Sybren A. Stüvel b4cfe80547 Assets: Store Action sub-type in asset metadata
Blender 3.0 will only support single-frame Actions in the pose library.
The goal of this patch is to lay the groundwork for making it possible
for the Asset Browser to reject/hide "animation snippet" Action assets.

Determining whether an Action has one or more frames (i.e. whether it
has a single pose or animation) requires inspecting the Action itself,
and thus loading the data-block itself. This would make it impossible to
quickly determine from the asset browser.

To solve this, the Action is inspected before saving, and a
`"is_single_frame"` boolean (well, 0/1 integer) IDProperty is added.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D13202
2021-11-12 14:36:22 +01:00
Bastien Montagne 86ca206db8 Cleanup/document BKE_blender_copybuffer.
* Rename the 'copy' functions to make it clear they belong to the same
  'group' and are to be used together.
* Fix `flag` parameter of `BKE_copybuffer_paste` being a short instead
  of an int.
* Improve documentation.
2021-11-12 10:20:49 +01:00
Campbell Barton aa1c44a113 Merge branch 'blender-v3.0-release' 2021-11-12 18:35:19 +11:00
Campbell Barton 02333544d1 Merge branch 'blender-v3.0-release' 2021-11-12 18:35:13 +11:00
Campbell Barton 1a7757b0bc Fix T91444: Edge Loop Preview fails with two Mirror Modifiers
The mirror modifiers merge option caused unnecessary re-ordering
to the vertex array with original vertices merging into their copies.

While this wasn't an error, it meant creating a 1:1 mapping from input
vertices to their final output wasn't reliable (when looping over
vertices first to last) as is done in
BKE_editmesh_vert_coords_when_deformed.

As merging in either direction is supported, keep the source meshes
vertices in-order since it allows the vertex coordinates to be extracted.
2021-11-12 18:27:47 +11:00
Campbell Barton d612d92630 Cleanup: use term sequence_strip instead of vse_strip 2021-11-12 17:38:58 +11:00
Jacques Lucke 50f32025ac Merge branch 'blender-v3.0-release' 2021-11-11 18:27:31 +01:00
Jacques Lucke 393879f30c Fix: wrong field inferencing with unavailable sockets 2021-11-11 18:26:40 +01:00
Hans Goudey 52c617802f Merge branch 'blender-v3.0-release' 2021-11-11 09:27:42 -06:00
Martijn Versteegh 7aa39b40f4 Fix: Prevent use of uninitialized memory when creating Bezier spline
When Constructing bezier splines from dna, the positions of the
left/right handles were set directly in the internal vectors, by
requesting a reference to them. The problem is that
BezierSpline::handle_positions_left() calls ensure_auto_handles()
before returning the reference. That function does some calculations on
uninitialized memory if the positions array is not yet filled.

Differential Revision: https://developer.blender.org/D13107
2021-11-11 09:25:10 -06:00
Campbell Barton d753ebd40a Cleanup: spelling in comments 2021-11-11 14:59:30 +11:00
Jeroen Bakker a6e4cb092e Merge branch 'blender-v3.0-release' 2021-11-10 13:53:44 +01:00
Jeroen Bakker bc0c06ecbe Fix T91518: crash when recalculating looptris after clearing geometry.
When clearing geometry the runtime mutexes of a mesh were freed. This
resulted in crashes afterwards. The clear geometry is an RNA function so
would only effect when using from scripts.

This patch separates init/freeing of the mutexes from other code so they
can be used when needed.

Reviewed By: mont29

Maniphest Tasks: T91518

Differential Revision: https://developer.blender.org/D13142
2021-11-10 13:50:15 +01:00
Hans Goudey 1f6010e609 Cleanup: Move info_stats.c to C++ 2021-11-09 15:57:58 -06:00
Jacques Lucke a356e4fb3f Merge branch 'blender-v3.0-release' 2021-11-09 17:53:15 +01:00
Jacques Lucke 4f246b8bf9 Fix T92908: print warning when instance recursion limit is reached
Currently we have a fixed instance recursion limit. While we want to lift this
limitation at some point, that is out of scope for a bug fix. For now just print
a warning to make it easier to detect the issue.

Differential Revision: https://developer.blender.org/D13162
2021-11-09 17:52:40 +01:00
Campbell Barton 625349a6bd Cleanup: spelling, C style comments 2021-11-10 00:56:17 +11:00
Campbell Barton 0bcf014bcf Merge branch 'blender-v3.0-release' 2021-11-10 00:38:51 +11:00
Campbell Barton 65c5ebf577 Fix T91923: Save/Apply as Shape Key ignores shape keys
Support virtual modifiers when using applying the modifier as a shape.
2021-11-10 00:33:22 +11:00
Jacques Lucke 41b0820ddd Merge branch 'blender-v3.0-release' 2021-11-09 13:31:33 +01:00
Jacques Lucke 45bd98d4cf Fix T92934: crash rendering with wrong image path
These null checks were missing in rB0c3b215e7d5456878b155d13440864f49ad1f230.

Differential Revision: https://developer.blender.org/D13157
2021-11-09 13:31:01 +01:00
Sybren A. Stüvel cb487b6507 Asset Catalogs: add test for proper shortening of simple names
Catalog simple names are supposed to fit into the DNA field `char
AssetMetaData::catalog_simple_name[64]`, and thus should be shortened
appropriately. This was already happening, but is now also covered by a
test.

No functional changes.
2021-11-09 13:13:30 +01:00
Germano Cavalcante 33beec1cec Cleanup: remove redundant arg when forcing zero initialization 2021-11-08 12:41:30 -03:00
Campbell Barton bb6547cb5f Merge branch 'blender-v3.0-release' 2021-11-09 00:25:49 +11:00
Campbell Barton 393ef4d871 Fix T92481: Memory leak with subdivision surface modifier
Interpolation vertex data on loose edges was writing into already
allocated data.

Resolve this by skipping vertex end-points for custom-data interpolation
which has already been copied from the source mesh.

Reviewed By: sergey

Ref D13082
2021-11-09 00:24:03 +11:00
Bastien Montagne d6e2210935 Fix inconsistent creation of `NodeTreeTypeUndefined` type of node tree
Currently, when creating a new node tree ID, its `typeinfo` is set to
`NodeTreeTypeUndefined`, but its `type` enum value is left to `0`,
aka `NTREE_SHADER`.

This patch adds a new `NTREE_UNDIFINED` value, and use it for
`NodeTreeTypeUndefined` types of node trees.

NOTE: While it is not clear whether that actually fixes issues currently,
quite a bit of code still relies on the value of `type`, so think it
makes sense to sanitize this.

NOTE: Would have been ideal to reserve `0` value to undefined type,
but at this point this is not possible anymore, so chose to use `-2` instead.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13123
2021-11-08 12:24:47 +01:00
Jacques Lucke fc373af8f5 Nodes: store socket declaration reference in socket
Previously, to get the declaration of a socket, one had to go
through `node->declaration`. Now this indirection is not necessary
anymore. This makes it easier to add more per-socket information
into the declaration and accessing it in various places.

Currently, this system is used by socket descriptions and node warnings
for unsupported geometry component types.
2021-11-08 12:24:01 +01:00
Campbell Barton c3f5fca8a2 Cleanup: avoid error prone struct declarations in C++
Reference struct members by name instead relying on their order.
This also simplifies moving back to named members when all compilers
we use support them.
2021-11-08 17:00:36 +11:00
Hans Goudey 42df2a7b57 Cleanup: Grammar in comments 2021-11-07 23:20:29 -06:00
Campbell Barton 0f80602632 Cleanup: remove references to non-existent 'mtexpoly' 2021-11-08 14:14:16 +11:00
Campbell Barton b24a03e635 Cleanup: remove duplicate doc-strings
Internal struct ObTfmBack had out of sync doc-strings
for members duplicated from Object.

Remove the doc-strings as there is this is just temporary storage.
2021-11-08 14:14:15 +11:00
Campbell Barton ed24b7d9a2 Cleanup: spelling in comments 2021-11-08 14:14:14 +11:00
Hans Goudey 892da668dc Cleanup: Clang tidy 2021-11-07 00:39:20 -05:00
Erik 6002914f14 Cleanup: Convert mesh.c to C++
This commit renames mesh.c to mesh.cc and makes
it compile in C++. Can be useful in the future to be able
to use C++ functionality in existing and new functions.

Differential Revision: https://developer.blender.org/D13134
2021-11-06 19:16:37 +01:00
Jacques Lucke f315a46982 Nodes: add preview image storage to node group
This is part of T92811.

Differential Revision: https://developer.blender.org/D13105
2021-11-06 16:43:26 +01:00
Hans Goudey 3211c80a31 Fix T92815: Incorrect handling of evaluated meshes from curves
Evaluated meshes from curves are presented to render engines as
separate instance objects now, just like evaluated meshes from other
object types like point clouds and volumes. For that reason, cycles
should not consider curve objects as geometry (previously it did,
meaning it retrieved a second mesh from the curve object as well
as the temporary evaluated mesh geometry).

Further, avoid adding a curve object's evaluated mesh as data_eval,
since that is special behavior for meshes that is arbitrary. Adding an
evaluated mesh there but not an evalauted pointcloud is arbitrary,
for example. Retrieve the evaluated mesh in from the geometry set
in BKE_object_get_evaluated_mesh now, to support that change.

This gets us closer to a place where all of an object's evaluated data
is stored in geometry_set_eval, and we just have helper functions
to access specific geometry components.

Differential Revision: https://developer.blender.org/D13118
2021-11-05 19:20:47 +01:00
Julian Eisel 8d2a0d9b4c UI: Apply recent theme fixes for Preferences saved in 3.1 builds
Followup to e65230f0c0.

Pablo and I decided it's fine to reset themes again when saved with the
recent 3.1 builds.

This needed to be done a bit careful, since a normal version patch
resetting the theme would've reset the theme for anybody opening
preferences of a 3.0 build (even the final release build) in a 3.1
build. So make sure the theme is at least from a 3.1 build (but not
newer then this commit of course).
2021-11-05 19:00:10 +01:00
Hans Goudey 1bc655c5aa Fix T92815: Incorrect handling of evaluated meshes from curves
Evaluated meshes from curves are presented to render engines as
separate instance objects now, just like evaluated meshes from other
object types like point clouds and volumes. For that reason, cycles
should not consider curve objects as geometry (previously it did,
meaning it retrieved a second mesh from the curve object as well
as the temporary evaluated mesh geometry).

Further, avoid adding a curve object's evaluated mesh as data_eval,
since that is special behavior for meshes that is arbitrary. Adding an
evaluated mesh there but not an evalauted pointcloud is arbitrary,
for example. Retrieve the evaluated mesh in from the geometry set
in BKE_object_get_evaluated_mesh now, to support that change.

This gets us closer to a place where all of an object's evaluated data
is stored in geometry_set_eval, and we just have helper functions
to access specific geometry components.

Differential Revision: https://developer.blender.org/D13118
2021-11-05 11:51:34 -05:00
Hans Goudey aaf86bad87 Merge branch 'blender-v3.0-release' 2021-11-05 11:19:29 -05:00
Hans Goudey c473b2ce8b Fix part of T89313: Attribute search crash during animation playback
During animation playback, data-blocks are reallocated, so storing
pointers to the resulting data is not okay. Instead, the data should
be retrieved from the context. This works when the applied search
item is the "dummy" item added for non-matches. However, it still
crashes for every other item, because the memory is owned by the
modifier value log, which has been freed by the time the exec function
runs.

The next part of the solution is to allow uiSearchItems
to own memory for the search items.
2021-11-05 11:19:12 -05:00
Hans Goudey 212dcd6075 Merge branch 'blender-v3.0-release' 2021-11-05 10:57:04 -05:00
Hans Goudey 594ee5f160 Fix T92848: Crash when joining curves with spline domain attributes
The point domain attributes (stored on splines) are sorted so they
have a consistent order on all splines after the join. However, spline
domain attributes were included in the new order, which didn't work
because the length of the attribute lists didn't match. The simple fix
is to only include point domain attributes in the new order vector.
2021-11-05 10:55:51 -05:00
Pablo Vazquez bbd8d33453 Merge branch 'blender-v3.0-release' 2021-11-05 16:23:56 +01:00
Erik 87e2154daf Fix: Viewport stats wrong for Geometry Nodes instances
In some cases when geometry is created in Geometry Nodes
the viewport stats will show 0 because runtime data is not filled.
This patch sets the runtime data on instances.

Differential Revision: https://developer.blender.org/D12738
2021-11-05 16:19:09 +01:00
Hans Goudey f415b41a94 Merge branch 'blender-v3.0-release' 2021-11-05 09:59:26 -05:00
Hans Goudey 616594fcb1 Fix T92850: Curve to mesh incorrect for single point profiles
For single point splines that weren't at the origin, the results were
incorrect. Now take into account the tilt, radius, etc. just like the
general case.
2021-11-05 09:52:25 -05:00
Pablo Vazquez e65230f0c0 UI: Various theme fixes related to contrast
* Animation channels (Fixes T92612)
* Curve widget (Fixes T92595)
* Pie menu (Fixes T92590)
* Radio and toggle buttons background
* Checkbox background
* Fix highlighted marker name on Dopesheet (text highlight on Dopesheet)


#### Master
{F11697667, size=full}

#### This Patch
{F11697669, size=full}
{F11697849, size=full}
{F11697833, size=full}
{F11697852, size=full}

Reviewed By: #user_interface, campbellbarton, Severin

Maniphest Tasks: T92595, T92612, T92590

Differential Revision: https://developer.blender.org/D13087

# Conflicts:
#	source/blender/blenkernel/BKE_blender_version.h
2021-11-05 15:06:37 +01:00
Campbell Barton 9d2e325694 Cleanup: spelling/typos 2021-11-05 13:38:58 +11:00
Germano Cavalcante df3e30398f Merge branch 'blender-v3.0-release' 2021-11-04 16:56:32 -03:00
Germano Cavalcante e7e3431b29 Cleanup: Move object.c to C++
This is useful to allow the use of features made in C++.

Differential Revision: https://developer.blender.org/D13115
2021-11-04 16:51:37 -03:00
Jacques Lucke 101fa4a425 Merge branch 'blender-v3.0-release' 2021-11-04 18:32:37 +01:00
Jacques Lucke b7260ca4c9 Fix T92799: handle undefined node group type in field inferencing
A group node could reference an undefined group when the group
was linked and its source file was not found on load. The field
inferencing code did not handle that case before.

With this change, the file provided in T92799 loads successfully.
2021-11-04 18:25:48 +01:00
Julian Eisel 8eff1eca52 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-04 14:50:48 +01:00
Jacques Lucke ff4959eeaa Fix T92649: incorrect copying of anonymous attributes in many places
Many modifiers and other places use `CustomData_copy_data` to copy data
between different meshes. This function assumes that assumes that the
source and destination `CustomData` objects are "compatible" in some way.
Usually modifiers use `CustomData_copy` to create a compatible new
`CustomData` on the new mesh. The issue was that the optimization I added
for anonymous attributes broke this compatibility. It avoided copying some
attributes when they are no longer used.

This lead to attributes being copied incorrectly.
D13083 contains ideas for how this could be fixed more generally.
For now I just removed the optimization.

Differential Revision: https://developer.blender.org/D13083
2021-11-04 14:41:56 +01:00
Bastien Montagne 7aaedc09c7 Merge branch 'blender-v3.0-release' 2021-11-03 18:16:16 +01:00
Bastien Montagne c29f9e14e4 Fix T92780: Lost material in case of local object, and missing linked obdata.
By default, when syncing materials slots between object and its obdata,
the amount of slots in obdata is the reference.

Missing linked obdata is replaced by an empty placeholder that has no
material. In that specific case, if we have a valid object ID, we want
to update the (placeholder) obdata's material count from the object one,
and not the other way around.
2021-11-03 18:15:51 +01:00
Julian Eisel e10caf6fe3 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-03 18:07:36 +01:00
Bastien Montagne d17128520d Simplification: Use generic `BKE_object_materials_test` in object liblink code.
Better avoid own specific logic here, when we already have a proper
'API' function for that.
2021-11-03 17:56:25 +01:00
Colin a827864e6b Fix T89709: avoid double node links after delete and reconnect
Differential Revision: https://developer.blender.org/D13062
2021-11-03 17:55:06 +01:00
Julian Eisel 2a88343213 Merge branch 'blender-v3.0-release' 2021-11-03 14:24:33 +01:00
Julian Eisel 0d8f1414a2 Fix access to current preferences when version patching read preferences
The version patch for 0cf9794c7e was checking and setting a data name
using the macros for translation. These would access the current
preferences which can mismatch the ones currently being version patched.
See discussion in 0cf9794c7e for details.

Don't handle translation in this version patch, which is more of a
"nice-to-have" version patch, no functionality depends on it.
2021-11-03 14:23:53 +01:00
Jacques Lucke bdf6665e3a Merge branch 'blender-v3.0-release' 2021-11-03 10:54:53 +01:00
Jacques Lucke 2b12b4cd7d Fix: make sure geometry owns mesh before taking ownership
Differential Revision: https://developer.blender.org/D13075
2021-11-03 10:42:48 +01:00
Campbell Barton 7996b49cb0 Cleanup: spelling 2021-11-03 11:42:07 +11:00
Hans Goudey 8c58838f6a Merge branch 'blender-v3.0-release' 2021-11-02 15:23:59 -05:00
Hans Goudey a72ed0bb7f Cleanup: Improve curve point attribute assert
This properly checks the order of point domain attributes on each
spline, and avoids the map, which makes the code easier to understand.
The assert is also added to realizing instances and the join node.

Differential Revision: https://developer.blender.org/D13071
2021-11-02 15:22:49 -05:00
Hans Goudey 18392cef17 Fix T92652: Joining curves breaks point attribute order
Currently the curve to mesh node relies on the order of attributes being
the same on every spline. This is a worthwhile assumption, because it
will allow removing the attribute name storage duplication on every
spline in the future.

However, the join geometry node broke this order, since it just created
new attributes without any regard to the order. To fix this, I added a
"reorder" step after all the merged attributes have been created, the
types have been joined, etc. It should be possible to change this code
so that the attributes are added with the right order in the first
place, but I would like to do that after refactoring spline attribute
storage, and not for 3.0.

Differential Revision: https://developer.blender.org/D13074
2021-11-02 15:16:52 -05:00
Hans Goudey 5cd1210b52 Merge branch 'blender-v3.0-release' 2021-11-02 13:44:17 -05:00
Hans Goudey 7aa311e539 Cleanup: Add function to get attribute ID from custom data layer 2021-11-02 13:43:54 -05:00
Jacques Lucke ffd3dd6376 Merge branch 'blender-v3.0-release' 2021-11-02 11:17:53 +01:00
Jacques Lucke 0c3b215e7d Images: refactor how failed image load attempts are remembered
Previously, `ImageTile->ok` and `ImageUser->ok` were used to indicate
whether an image failed to load. There were three possible values
which (probably) had the following meanings:
* `0`: There was an error while loading the image. Don't try to load again.
* `1`: Default value. Try to load the image.
* `2`: The image was loaded successfully.

This image-wide flag did not make sense unfortunately, because loading
may work for some frames of an image sequence but not for others.
Remember than an image data block can also contain a movie.

The purpose of the `->ok` flag was to serve as an optimization to avoid
trying to load a file over and over again when there is an error (e.g. the
file does not exist or is invalid). To get the optimization back, the patch
is changing `MovieCache` so that it can also cache failed load attempts.
As a consequence, `ibuf` is allowed to be `NULL` in a few more places.
I added the appropriate null checks.

This also solves issues when image sequences are used with the
Image Texture node in Geometry nodes (also see D12827).

Differential Revision: https://developer.blender.org/D12957
2021-11-02 11:17:12 +01:00
Campbell Barton 21e168069d Merge branch 'blender-v3.0-release' 2021-11-02 19:52:01 +11:00
Campbell Barton 69a7734b75 UI: always show the cursor while transforming the cursor 2021-11-02 19:35:17 +11:00
Hans Goudey 765c2cc6c7 Merge branch 'blender-v3.0-release' 2021-11-01 13:17:54 -05:00
Hans Goudey b6c2deef05 Fix T92662: Curve to mesh start cap invalid topology
rBbe3e09ecec5372f switched the order for vertices referenced by the
start cap's corners, but it failed to account for the offset necessary
for edge indices, since the order changed.
2021-11-01 13:13:44 -05:00
Bastien Montagne 1704a394d8 Fix T92689: Assert loading file with a sound.
Dummy mistake in rBc8c53ceecc30 (boolean inversion).
2021-11-01 16:44:12 +01:00
Bastien Montagne 8fbbd69946 Fix T92629: Crash on mesh separate after rB43bc494892c3.
rB43bc494892c3 switched `BKE_libblock_relink_to_newid` to use new ID
remapping and libquery code.

However, that new code does protect by default against remapping an
objects's data pointer when that object is in Edit mode, since this is
not a behavior that generic BKE code can handle (due to required editing
data for most obdata types when in edit mode).

So specific code that does create new IDs and need remapping in Edit
mode has to pass specific exception flags to remaping code.

This commit adds those remapping flags to `BKE_libblock_relink_to_newid`
and add said exception flag to the remapping call from
`ED_object_add_duplicate` when the object is in edit mode.
2021-11-01 15:46:28 +01:00
Bastien Montagne e85e126e3f IDRemap: Add option to force remapping obdata in edit mode.
In theory we should never allow remapping of Objects' obdata ID pointer
when the object is in Edit mode. But there are some cases were this is
needed, so adding yet another exception option to remapping flags.

Preliminary change to fix T92629.
2021-11-01 15:46:28 +01:00
Sergey Sharybin 64de6ad4fe Fix use-after-free in image code 2021-11-01 15:36:09 +01:00
Julian Eisel 9de4f64197 Fix compile error on Windows
Caused by 7150f919d3. This undid part of 79a88b5e91. Added a comment
for why this include is needed, to avoid this error from happening
again.
2021-11-01 14:44:18 +01:00
Julian Eisel 7150f919d3 Cleanup: Remove unused headers in asset files
Also move system includes first, like we have it elsewhere in Blender.
2021-11-01 13:21:07 +01:00
Sergey Sharybin 9111ea78ac Localize image mutex lock into runtime field of Image datablock
Allows to avoid a global lock being held while reading files from disk,
solving performance issues when Cycles needs to read a lot of packed
images.

Simple test file F11597666

Differential Revision: https://developer.blender.org/D13032
2021-11-01 12:47:03 +01:00
Jacques Lucke a96b2f39b8 Geometry Nodes: improve check if object has geometry set instances
The improves playback speed in my instance heavy scene from ~3.7 fps to ~3.9 fps.
2021-11-01 12:00:41 +01:00
Campbell Barton 1e749d0602 Cleanup: spelling, use C comments 2021-11-01 14:00:58 +11:00
Campbell Barton b99d6e1bed Fix errors in BKE_appdir_font_folder_default
- Missing NULL check for the HOME environment variable.
- The user preference path was written to even when the
  path didn't exist.
2021-11-01 13:43:35 +11:00
Campbell Barton e2937ff24f Merge branch 'blender-v3.0-release' 2021-11-01 13:15:10 +11:00
Campbell Barton a0633e2484 Fix crash when "HOME" environment variable isn't defined
Accessing the default directory in the file selector
would crash if HOME was undefined.

Add BKE_appdir_folder_default_or_root which never returns NULL.
2021-11-01 13:11:48 +11:00
Harley Acheson 02a9377da0 UI: Default Fonts Folder for Mac and Linux
Initial defaults for userdef->fontdir for Mac and Linux.

See D12802 for more details.

Differential Revision: https://developer.blender.org/D12802

Reviewed by Campbell Barton
2021-10-29 17:15:22 -07:00
Bastien Montagne e1db6dc11b Fix crash on undo after recent lib_query refactor.
Forgot that scene uses part of its ID looping code for specific undo
handling.

Caused by rBe3b2f0fd6ff9.
2021-10-29 12:54:32 +02:00
Bastien Montagne c8c53ceecc LibQuery: Remove last 'bool returns' from public API.
Those were used in a very few places to detect whether iteration should
be stopped or not, but one can use `BKE_lib_query_foreachid_iter_stop`
now for that.

Also fix early break handling in embedded IDs processing.

Fix T90922: Fix return policy inconsistency in `scene_foreach_id`.
2021-10-29 11:32:26 +02:00
Bastien Montagne 259731909c LibQuery: Fix potential memleak in recursive case.
In case `library_foreach_ID_link` would return early in recursive
process, it would not properly free its utils data.

Also add proper iteration break in case some sub-calls requested it.

Finally, make this function return a boolean to know whether iteration
should be stopped or not (will be used in future commit to fix this
handling in embedded IDs case).

Part of T90922: Fix return policy inconsistency in `scene_foreach_id`.
2021-10-29 11:32:26 +02:00
Bastien Montagne e3b2f0fd6f LibQuery: Add macro to help break looping when requested.
The new `BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL` execute the given
statement and then check status of `LibraryForeachIDData` data, and
return in case stop of iteration is requested.

This is very similar to the other `BKE_LIB_FOREACHID_PROCESS_` existing
macros, and allows us to properly break iteration when a sub-function
has requested it.

Part of T90922: Fix return policy inconsistency in `scene_foreach_id`.
2021-10-29 11:32:26 +02:00
Bastien Montagne 51c1c1cd93 Fix potential early-return in WM foreach_id process.
Add a function to check if iteration over ID usages should stop (using
internal `IDWALK_STOP` status flag).

Use it in `BKE_LIB_FOREACHID_PROCESS_` macros, and in
`window_manager_foreach_id` to handle properly the active workspace case
(previous code could skip the call to `BKE_workspace_active_set` in case
iteration over ID usages was stopped by callback on that specific ID
usage).

Part of T90922: Fix return policy inconsistency in `scene_foreach_id`.
2021-10-29 11:32:26 +02:00
Bastien Montagne eae59645de Cleanup: Add some comments to some sub-function of `foreach_id` process. 2021-10-29 11:32:26 +02:00
Bastien Montagne 43bc494892 IDManagement: Remove deprecated `BKE_libblock_relink_to_newid` usages.
Move all usages to new `BKE_libblock_relink_to_newid_new`, and rename
that one to `BKE_libblock_relink_to_newid`.

Fix T91413.
2021-10-29 10:45:48 +02:00
Jacques Lucke 1688cb27cd Merge branch 'blender-v3.0-release' 2021-10-29 09:49:48 +02:00
Jacques Lucke cf771807b7 Geometry Nodes: do cache invalidation after writing attributes
This is a better and more general fix for T92511 and T92508 than
the ones that I committed before.

Previously, we tagged caches dirty when first accessing attributes.
This led to incorrect caches when under some circumstances. Now
cache invalidation is part of `OutputAttribute.save()`.

A nice side benefit of this change is that it may make things more
efficient in some cases, because we don't invalidate caches when
they don't have to be invalidated.

Differential Revision: https://developer.blender.org/D13009
2021-10-29 09:28:31 +02:00
Campbell Barton 8eb10de739 Merge branch 'blender-v3.0-release' 2021-10-29 10:53:39 +11:00
Hans Goudey b43077ba3a Fix T92552: Spline evaluation with all points at the origin
In this case, the uniform index sampling loop would fail to assign any
data to the samples, so fill the rest with the largest value possible,
corresponding to the end of the spline. Animation Nodes has the same
fix for this case.
2021-10-28 18:23:55 -05:00
Bastien Montagne 5f1107ffaf Merge branch 'blender-v3.0-release' 2021-10-28 12:01:01 +02:00
Bastien Montagne aebb3d3062 Fix (unreported) potential issue in new `BKE_libblock_relink_to_newid_new`
Remapping code could call collection resync code while processing
remapping, which is a good way to crash by accessing no-more-valid
pointers.

Similar issue as with liboverrides resync, fixed the same way by
preventing any collection resync until whole remapping has been done.

This was probably not an issue in practice in current code, since this
is only used by append code currently, which should not affect
layers/collections in current scene yet.
2021-10-28 11:57:20 +02:00
Dalai Felinto bfd2921d38 Revert "Blender 3.0 bcon3 (beta)"
This reverts commit f7a3450e63.
2021-10-27 18:44:28 +02:00
Dalai Felinto 17efd14682 Merge branch 'blender-v3.0-release' 2021-10-27 18:43:18 +02:00
Dalai Felinto f7a3450e63 Blender 3.0 bcon3 (beta) 2021-10-27 18:41:31 +02:00
Dalai Felinto dab3591588 Blender 3.1 bcon1 - alpha
Bump the version number for the new release cycle.
2021-10-27 18:40:49 +02:00
Dalai Felinto f0a37dc31c Revert "Blender 3.1 bcon1 - alpha"
This reverts commit 7b9e3534cf.

This was supposed to go to master, not the 3.0 branch.
2021-10-27 18:40:02 +02:00
Dalai Felinto 7b9e3534cf Blender 3.1 bcon1 - alpha
Bump the version number for the new release cycle.
2021-10-27 18:38:22 +02:00
Pablo Vazquez bfec984cf8 UI: Theme refresh for Blender v3.0
{F11548100, size=full}

To celebrate the beginning of a new series, it feels like the right time to
give the theme a fresh look while improving on what already works.

The aim of this refresh is to keep a familiar look but with polishing touches
here and there. Like new paint on the walls of your well known house.

The theme for Blender 2.8 was well received but presented a few flaws.

* Transparency on menus and tooltips reduce readability
* Mismatch on certain colors, especially outlines of connected widgets
* Active/open menus highlight was not prominent enough
* Header background mismatch in some editors

At the same time we can make use of new features in 3.0:

* Make panels look like panels again (like in v2.3!)
* Make use of roundness in more widgets
* Since nodes are no longer hard-coded to be transparent, tweak opacity and saturation
* Tweak colors for the new dot grid

This update does not include:

* Meshes in edit mode to match greenish object-data color. This needs tweaks in the code to improve contrast.
* A copy of the Blender 2.8x legacy theme. This could be added to the community themes (shouldn't cost much maintenance, I hope)

There will be certainly small tweaks to do here and there, I've been working using this theme
for months but there can be areas that are missing update. The overall style is presented here.

This commit bumps the file subversion.

Reviewed By: #user_interface, Severin

Differential Revision: https://developer.blender.org/D13008
2021-10-27 18:29:18 +02:00
Jacques Lucke 0d6f2cb303 Cleanup: remove unused function declaration 2021-10-27 15:57:20 +02:00
Jacques Lucke 18b6f0d0f1 Fix T92264: incorrect field inferencing when muting link between reroutes
Previously, muted links were just ignored considered by field inferencing.
Now muted links behave like normal links in the inferencing process.
2021-10-27 12:43:04 +02:00
Jacques Lucke c06a86f99f Fix T92328: crash during field inferencing when there is a link cycle
The toposort did not handle link cycles which it should.
2021-10-27 12:29:59 +02:00
Jacques Lucke 8b15b06b20 Fix: missing cache invalidation when there is only one spline
This fixes T92511, but there is still the more general problem
described in T92508.
2021-10-27 11:02:49 +02:00
Bastien Montagne 16e1b18dd8 Cleanup: Rename `scene.c`'s `FOREACHID_PROCESS` macro to `FOREACHID_PROCESS_IDSUPER`.
Follow-up of rBf11ed418e5fa.
2021-10-27 09:15:21 +02:00
Campbell Barton a3b785bc08 Cleanup: clang-format, clang-tidy, spelling 2021-10-27 15:55:36 +11:00
Germano Cavalcante 3e3ff1a464 Revert "Revert "Eevee: support accessing custom mesh attributes""
This reverts commit e7fedf6dba.

And also fix a compilation issue on windows.

Differential Revision: https://developer.blender.org/D12969
2021-10-26 18:23:59 -03:00
Ray Molenkamp e7fedf6dba Revert "Eevee: support accessing custom mesh attributes"
This reverts commit 03013d19d1.

This commit broke the windows build pretty badly and I don't
feel confident landing the fix for this without review.

Will post a possible fix in D12969 and we'll take it from there.
2021-10-26 14:49:22 -06:00
Hans Goudey 7d3d09b69c Geometry Nodes: Get and set nodes for ID attribute
These nodes allow accessing and changing the stable/random ID used
for motion blur with instances and stable randomness.

Since rB40c3b8836b7a, the stable ID is a built-in attribute, so to be
consistent and allow changing it in the node tree like other built-in
attributes, it has get and set nodes.
2021-10-26 15:40:57 -05:00
Julian Eisel 0cf9794c7e Assets: Rename "Default" asset library to "User Library"
Feedback was that "Default" is a bit of a weird name, so switching it to "User
Library". Added versioning code which won't be entirely bullet proof (e.g. will
also rename libraries named "Default" by the user), but it doesn't have to be.

Addresses T90298.
2021-10-26 21:01:44 +02:00
Jacques Lucke 0bfae1b120 Geometry Nodes: geometry component type warning system
Previously, every node had to create warnings for unsupported input
geometry manually. Now this is automated. Nodes just have to specify
the geometry types they support in the node declaration.

Differential Revision: https://developer.blender.org/D12899
2021-10-26 20:00:10 +02:00
Hans Goudey be3e09ecec Fix: Inverted normal for one curve to mesh cap 2021-10-26 12:59:46 -05:00
Hans Goudey 9fa304bf13 Geometry Nodes: Only create instance IDs when they exist
Instance IDs serve no purpose for rendering when they aren't stable from
one frame to the next, and if the index is used in the end anyway, there
is no point in storing a vector of IDs and copying it around.

This commit exposes the `id` attribute on the instances component,
makes it optional-- only generated by default with the distribute points
on faces node.

Since the string to curves node only added the index as each instance's
ID, I removed it. This means that it would be necessary to add the ID
data manually if the initial index actually helps (when deleting only
certain characters, for example).

Differential Revision: https://developer.blender.org/D12980
2021-10-26 12:50:39 -05:00
Kévin Dietrich 03013d19d1 Eevee: support accessing custom mesh attributes
This adds generic attribute rendering support for meshes for Eevee and
Workbench. Each attribute is stored inside of the `MeshBufferList` as a
separate VBO, with a maximum of `GPU_MAX_ATTR` VBOs for consistency with
the GPU shader compilation code.

Since `DRW_MeshCDMask` is not general enough, attribute requests are
stored in new `DRW_AttributeRequest` structures inside of a convenient
`DRW_MeshAttributes` structure. The latter is used in a similar manner
as `DRW_MeshCDMask`, with the `MeshBatchCache` keeping track of needed,
used, and used-over-time attributes. Again, `GPU_MAX_ATTR` is used in
`DRW_MeshAttributes` to prevent too many attributes being used.

To ensure thread-safety when updating the used attributes list, a mutex
is added to the Mesh runtime. This mutex will also be used in the future
for other things when other part of the rendre pre-processing are multi-threaded.

`GPU_BATCH_VBO_MAX_LEN` was increased to 16 in order to accommodate for
this design.

Since `CD_PROP_COLOR` are a valid attribute type, sculpt vertex colors
are now handled using this system to avoid to complicate things. In the
future regular vertex colors will also use this. From this change, bit
operations for DRW_MeshCDMask are now using uint32_t (to match the
representation now used by the compiler).

Due to the difference in behavior for implicit type conversion for scalar types
between OpenGL and what users expect (a scalar `s` is converted to
`vec4(s, 0, 0, 1)` by OpenGL, vs. `vec4(s, s, s, 1)` in Blender's various node graphs) ,
all scalar types are using a float3 internally for now, which increases memory usage.
This will be resolved during or after the EEVEE rewrite as properly handling
this involves much deeper changes.

Ref T85075

Reviewed By: fclem

Maniphest Tasks: T85075

Differential Revision: https://developer.blender.org/D12969
2021-10-26 18:29:30 +02:00
Hans Goudey 8ddfdfd2b2 Geometry Nodes: Handle multiple grids in the volume to mesh node
In future use cases, a volume can contain many grids that represent the
density information. In this case, it's better if the volume to mesh node
creates a mesh based on all of the grids in the volume.

This is also a benefit to share-ability, since one doesn't have to
specify the grid name in the node. Instead, in the future we can have
a way to split particular grids into separate volumes, if only one
grid should be considered.

The code changes are relatively simple:
 - Move the old volume to mesh node to the legacy folder.
 - Run the volume to mesh node on all instance geometry, like elsewhere.
 - Make the blenkernel's volume to mesh API a bit more specific.

Differential Revision: https://developer.blender.org/D12997
2021-10-26 11:25:44 -05:00
Brecht Van Lommel a90cb41cb9 Cleanup: clang-format 2021-10-26 16:35:26 +02:00
Jacques Lucke fd477e738d Geometry Nodes: remove reference to anonymous attributes in tooltips
This changes socket inspection for fields according to T91881.

Differential Revision: https://developer.blender.org/D13006
2021-10-26 15:32:01 +02:00
Bastien Montagne f11ed418e5 Cleanup: LibQuery: Rename `BKE_LIB_FOREACHID_PROCESS` to `BKE_LIB_FOREACHID_PROCESS_IDSUPER`.
More in-line name with the rest of that macro-based API, especially
since this will be extended in the future.
2021-10-26 10:40:36 +02:00
Bastien Montagne fe68b54edb Cleanup: `else` after `continue`. 2021-10-26 10:28:52 +02:00
Bastien Montagne 9ba22bd1f7 Fix crash in liboverride/pointcache handling code after recent changes.
In some cases code would try to access NULL pointer.

Reported by @dfelinto, thanks.
2021-10-26 10:13:44 +02:00
Bastien Montagne ee743204b0 Cleanup: build warnings.
`NULL` instead of `nullptr` in cpp code, and `else` statements after
returns.
2021-10-26 09:52:08 +02:00
Hans Goudey e463d2c16f UI: Change node editor grid into a dot grid
This patch makes the background grid of the node editor a grid of dots
instead of lines. This makes the background look a bit more subtle and
reduces visual complexity. The dots are meant to provide a reference
when panning and zooming. Based on the design of @pablovazquez, and
a patch originally authored by @fabian_schempp.

The "Grid Levels" controls how many levels of dots are drawn. As the
editor zooms in, the higher levels of dots fade in, making them closer
together visually. The zoom factor at which each grid starts and ends
fading in is controllable in the code, and could be tweaked further
in the future. The new default value is 7, out of a range from 0 to 9.

Differential Revision: https://developer.blender.org/D10345
2021-10-25 21:50:05 -05:00
Germano Cavalcante a84f1c02d2 Assets: Snapping with visual feedback while dragging
The drag and drop feature of objects in 3D View has been modified to include:
- Snap the object being dragged.
- Visual feedback through a box and the placement tool grid.

Maniphest Tasks: T90198

Differential Revision: https://developer.blender.org/D12912
2021-10-25 11:57:26 -03:00
Hans Goudey bc2f4dd8b4 Geometry Nodes: Add "Fill Caps" option to curve to mesh node
This adds an option to fill the ends of the generated mesh for
each spline combination with an N-gon. The resulting mesh is
manifold, so it can be used for operations like Boolean.

Differential Revision: https://developer.blender.org/D12982
2021-10-25 09:10:44 -05:00
Sybren A. Stüvel cdcca917cf Tests: assets, add BKE callback init/finalize to test setup/teardown
Add calls to `BKE_callback_global_init()` and `BKE_callback_global_finalize()`
to ensure unit tests mimick Blender (and don't trip the assertions added
in rBbeea601e7253).

No functional changes to Blender.
2021-10-25 14:21:43 +02:00
Julian Eisel 4100a79219 Assets: Add Author field to asset metadata
This is information you'd typically want to be visible in the UI. It's optional
of course, so if not relevant, it can just remain unset.
2021-10-25 13:51:14 +02:00
Julian Eisel e7bea3fb6e Assets/IDs: Don't generate previews for object types with no real geometry
Object types like empties, cameras or lamps will just end up as empty preview
images. We can think about ways to visualize them still, but meanwhile, don't
create such an empty preview.

Differential Revision:  https://developer.blender.org/D10334

Reviewed by: Bastien Montagne, Sybren Stüvel
2021-10-25 13:33:16 +02:00
Jacques Lucke 039094c1ec Geometry Nodes: new Image Texture node
This adds a new image texture node for geometry nodes. It does not
reuse the same node that is used in shading, because we want to be
able to expose the image and frame as sockets.

There is a known update issue when a movie or image sequence is
used. That will be fixed separately (also see D12957).

Currently, the image socket is just a pointer to an Image ID data block.
This can contain single images but also movies and image sequences.
In the future, the definition of an image socket can be expanded to
include images that are generated from scratch in the node tree.
For more details read the discussion in D12827.

Some of the code is a direct port from cycles and should be cleaned
up a bit in the future. For example `image_cubic_texture_lookup`.

For still images, the frame input is ignored. Otherwise, the frame
has to be in a valid range for the node to work. In the future we
may add e.g. automatic looping functionality.

Differential Revision: https://developer.blender.org/D12827
2021-10-25 13:03:57 +02:00
Sybren A. Stüvel 892e5f4a9f Asset Catalogs: be more accepting of backslashes as separators
Asset Catalog Paths should only contain forward slashes as separators, but
now the UI is more resilient to people using blackslashes instead.

Manifest Task: T90553
2021-10-25 12:37:35 +02:00
Sybren A. Stüvel 550cbec5c4 Cleanup: asset catalog path test, improve sub-test separation
Put related lines in a block of their own, such that each block doesn't
have access to the variables of the previous blocks.

This makes it easier to correctly copy-paste some tests, as the compiler
forces you to update the code afterwards.
2021-10-25 12:37:35 +02:00
Sybren A. Stüvel beea601e72 BKE Callbacks: more explicit initialisation check
Add static boolean to track whether the callbacks system has been
initialised. This makes it possible to make the `BKE_callback_remove()`
function more noisy in case of programming errors, and avoids accessing
`funcstore->alloc` when `funcstore` was potentially already freed.

Thanks @campbellbarton for pointing this out.
2021-10-25 12:08:08 +02:00
Jeroen Bakker 8e56f3e8a3 Image: Fix Crash During Undo.
Fixes T91294.
2021-10-25 11:41:49 +02:00
Jacques Lucke 665657812d Cleanup: quiet asan warning because of uninitialized variable 2021-10-24 18:20:06 +02:00
Campbell Barton 1411118055 Cleanup: spelling in comments 2021-10-24 21:04:04 +11:00
Erik Abrahamsson dc2524eaae Geometry Nodes: Rename node "String Substring"
This patch renames the node "String Substring" to "Slice String"
to conform to the "verb first" naming convention.
Default length is also changed to 10 to make it easier for users
to understand what the node does.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D12931
2021-10-24 11:43:54 +02:00
Jarrett Johnson 3af597d16b Geometry Nodes: Add Instances to Points Node
This node takes a geometry set with instances as input and outputs
points located on the origins of the top level of instances in the
geometry set (not nested instances). It also has position and radius
inputs to allow overriding the default, and a selection input to only
generate points for some instances.

The use case for this node is a method to use geometry proximity on
instance origins, but in a more generic way that is flexible and useful
in other situations.

Differential Revision: https://developer.blender.org/D12893
2021-10-23 00:01:59 -05:00
Hans Goudey 1d9e2dc954 Fix: Cyclic single point bezier splines have multiple evaluated points
Because `segment_is_vector` didn't handle the combined cyclic and
single control point case, it returned false, that the "segment" should
have the resolution evaluated point count. To avoid checking the size in
every call, add an assert for the size and check it elsewhere.
2021-10-22 17:13:26 -05:00
Alexander Gavrilov cca811de98 Fix test print wording that confuses build bot highlighting. 2021-10-22 18:26:12 +03:00
Sybren A. Stüvel 85312f2236 Asset Browser: Show "orphaned" assets in "Unassigned" catalog
Show assets that have an unknown catalog ID assigned in the "Unassigned"
catalog.

Another catalog named "Orphans" was considered as well, but that would
clash with the usual handling of Blender (discarding orphan data on
save) and thus that idea was discarded.

Manifest Task: T91949
2021-10-22 16:32:05 +02:00
Sybren A. Stüvel 70aad5f498 Asset Catalogs: support reloading without losing local changes
Keep track of unsaved asset catalog changes, in a more granular way than
just one boolean per asset library. Individual catalogs can now be
marked with a flag `has_unsaved_changes`. This is taken into account
when reloading data from the catalog definition file (CDF):

- New catalog in CDF: gets loaded
- Already-known catalog in CDF:
    - local unsaved changes: on-disk catalog is ignored
    - otherwise: on-disk catalog replaces in-memory one
- Already-known catalog that does not exist in CDF:
    - local unsaved changes: catalog is kept around
    - otherwise: catalog is deleted.

Because this saving-is-also-loading behaviour, the "has unsaved changes"
flags are all stored in the undo buffer; undoing after saving will not
change the CDF, but at least it'll undo the loading from disk, and it'll
re-mark any changes as "not saved".

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D12967
2021-10-22 16:31:32 +02:00
Jacques Lucke 0c16ac9ddf Cleanup: restore alphabetic ordering 2021-10-22 15:27:10 +02:00
Dorian 781289e31f Geometry Nodes: add Boolean and Integer Input nodes
These nodes just output a single value of their respective types,
making it possible to control multiple inputs with the same value.

Differential Revision: https://developer.blender.org/D12932
2021-10-22 15:01:28 +02:00
Bastien Montagne 65dbeb1d81 Fix T90638: Inconsistent object data behavior when link-duplicating collections.
Camera, lattice and speaker object types were missing there own proper
`USER_DUP_` flags, leading to not properly handling duplication of their
object data.

NOTE: We could probably simply opions here, by using categories (like
'GEOMETRY', 'SHADING', etc.) instead of exact object types. But this is
beyond bugfix scope.
2021-10-22 12:35:40 +02:00
Campbell Barton 05ab3356a7 Cleanup: spelling in comments, use C style comments 2021-10-22 10:28:56 +11:00
Hans Goudey 7b9319adf9 Geometry Nodes: Update bounding box to work on individual instances
This commit makes the bounding box node work on each unique geometry
(including instances) individually instead of making one large bounding
box for everything. This makes the node much faster, and is often the
desired result anyway. For the old behavior, a realize instances node
can be used in front of this node (versioning adds it automatically).

The min and max outputs now only output the values from the realized
geometry.

Differential Revision: https://developer.blender.org/D12951
2021-10-21 11:51:56 -05:00
Sybren A. Stüvel 16c79d3b82 Asset Catalogs: add test for backslashed catalog paths
No functional changes necessary, test already succeeds.
2021-10-21 16:23:56 +02:00
Sybren A. Stüvel 4b48b1079d Asset Catalogs: refresh simple name when renaming catalog
When renaming an asset catalog, also update its simple name.

Catalogs will most likely be created from within Blender, so via the
catalog tree in the asset browser. Here catalogs are always named
"Catalog" until the user renames them, which was reflected in all simple
names being "Catalog".
2021-10-21 16:06:14 +02:00
Sybren A. Stüvel 5ccec8ec6b Asset Catalogs: treat first-loaded catalog as main catalog
When there are multiple catalogs with the same path (so different UUIDs
all mapped to the same catalog path), treat the first-loaded one as the
main catalog for that path, and the rest as aliases.

This ensures that the UUID of a catalog (as chosen in the tree UI and thus
interacted with by users) is stable, regardless of whether by some coincidence
later another catalog with the same UUID is created.
2021-10-21 15:53:16 +02:00
Sybren A. Stüvel 9a1fce698b Cleanup: rename & restructure `AssetCatalogPathCmp`
Rename `AssetCatalogPathCmp` to `AssetCatalogLessThan`:
- it compares more than paths (so no more `Path` in the name), and
- performs a less-than operation (so no more `Cmp` in the name).

Also restructure its code to make an extra upcoming comparison easier to
add.

No functional changes.
2021-10-21 15:53:16 +02:00
Bastien Montagne 7681326acd IDManagement: Assign current Main's lib to newly created IDs.
This is mainly for doversion code, when it needs to create new IDs those
should be considered as part of the same library as the current Main's
one.

No practical changes are expected here, this is more of a general
consistency fix, and a pre-requisite for {T92333}.
2021-10-21 15:22:35 +02:00
Philipp Oeser ab0195c78f Fix T92169: "View Selected" on Custom Boneshape with transform wrong
Since the introduction in rBfc5bf09fd88c, `BKE_pose_minmax` was not
taking these custom transforms into account (making "View Selected"
ignoring these as well and focusing on the bone instead).

Now consider these transforms in `BKE_pose_minmax`.

Maniphest Tasks: T92169

Differential Revision: https://developer.blender.org/D12942
2021-10-21 14:39:42 +02:00
Bastien Montagne 641a5be50e IDManagement: Add option to clear asset data when making ID local.
When appending an asset from the asset browser, its asset data needs to
be cleared.

However, linking an asset (or regular append from the file browser)
should not clear such data. In linking case, it would be there again
after a blend file reload anyway.

So this commit introduces a new `BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR`
option.

NOTE: in case the appended ID needs to be copied from its linked data
(instead of making the later directly local), asset data is lost anyway
since it is never copied with the ID currently.

Ref. {T91749} and D11768.
2021-10-21 12:55:15 +02:00
Hans Goudey 6b761c59d2 Fix: Empty id attribute on curve control points
No virtual array should be returned instead of returning an empty span.
2021-10-20 17:45:14 -05:00
Hans Goudey 3f8b45d8d1 Fix: Builtin curve attributes unavailable
After the addition of the `id` attribute in rB40c3b8836b7a, the `exists`
function assumed that all attributes were stored in the custom data.
2021-10-20 16:54:04 -05:00
Hans Goudey 704d077d8f Fix: Crash when retrieving output "id" attribute
The attribute provider needs to handle the case where the data is stored
with just a data type, and the case where it is stored with a name.
2021-10-20 13:15:37 -05:00
Hans Goudey 40c3b8836b Geometry Nodes: Make Random ID a builtin attribute, remove sockets
In order to address feedback that the "Stable ID" was not easy enough
to use, remove the "Stable ID" output from the distribution node and
the input from the instance on points node. Instead, the nodes write
or read a builtin named attribute called `id`. In the future we may
add more attributes like `edge_id` and `face_id`.

The downside is that more behavior is invisible, which is les
expected now that most attributes are passed around with node links.
This behavior will have to be explained in the manual.

The random value node's "ID" input that had an implicit index input
is converted to a special implicit input that uses the `id` attribute
if possible, but otherwise defaults to the index. There is no way to
tell in the UI which it uses, except by knowing that rule and checking
in the spreadsheet for the id attribute.

Because it isn't always possible to create stable randomness, this
attribute does not always exist, and it will be possible to remove it
when we have the attribute remove node back, to improve performance.

Differential Revision: https://developer.blender.org/D12903
2021-10-20 10:54:54 -05:00
Hans Goudey 334a8d9b3e Geometry Nodes: Fields version of Curve to Points node
This commit adds an updated version of the curve to points that
supports fields. Only the position and radius are transferred
by default now, which should improve performance. The other outputs
like tangent and rotation are outputted with anonymous attributes.

I took the opportunity to change a few other small things:

 - Name geometry sockets "Curve" and "Points" like other nodes.
 - Remove the radius multiple of 0.1, which was confusing.

Thanks to @Johnny Matthews (guitargeek) for an initial patch.

Differential Revision: https://developer.blender.org/D12887
2021-10-20 10:25:49 -05:00
Bastien Montagne e00bf04c0f Fix T89771: Cloth disk cache is not read on library overrides when original linked data is already set to use 'Disk Cache'
Yet another try at that hairy issue... See comment in commit for
details, essentially this extend the workaround introduced in Objects'
`lib_override_apply_post` callback to try to also properly 're-use'
`OUTDATED` and `BAKED` flags from old source liboverride into new
destination one.
2021-10-20 17:21:30 +02:00
Hans Goudey 990b912fd7 Cleanup: Add check whether to remove an anonymous atttribute
Add a higher level check that can be used instead of checking whether
the attribute ID is anonymous and checking whether it has any strong
references.
2021-10-20 09:57:54 -05:00
Bastien Montagne 3435ea014d Cleanup: unused parameters, `nullptr` instead of `NULL` in cpp code... 2021-10-20 14:56:18 +02:00
Alexander Gavrilov 16eafdadf6 Fix precision issues and a bug in vec_roll_to_mat3_normalized.
When the input vector gets close to -Y, y and theta becomes totally
unreliable. It is thus necessary to compute the result in a different
way based on x and z. The code already had a special case, but:

- The threshold for using the special case was way too low.
- The special case was not precise enough to extend the threshold.
- The special case math had a sign error, resulting in a jump.

This adds tests for the computation precision and fixes the issues
by adjusting the threshold, and replacing the special case with one
based on a quadratic Taylor expansion of sqrt instead of linear.

Replacing the special case fixes the bug and results in a compatibility
break, requiring versioning for the roll of affected bones.

Differential Revision: https://developer.blender.org/D9551
2021-10-20 12:58:19 +03:00
Gaia Clary df445cc571 Fix T82455: vec_roll_to_mat3_normalized returns NaN when nor close to -Y.
In this case theta is completely unsafe to use, so a different
threshold based on x and z has to be used to avoid division by zero.

Ref D9551
2021-10-20 12:58:19 +03:00
Alexander Gavrilov dfa1c7e554 Split and extend unit tests for vec_roll_to_mat3_normalized.
Separate the huge test into huge logical parts and add more cases
to check. Also add a utility to check that the matrix is orthogonal,
with arbitrary epsilon values and calculations in double.

A couple of tests deliberately fail, to be fixed in following commits.

Ref D9551
2021-10-20 12:58:19 +03:00
Campbell Barton b280699078 Cleanup: use elem macros 2021-10-20 11:16:43 +11:00
Campbell Barton 967fec6883 Cleanup: sort cmake file lists 2021-10-20 09:17:46 +11:00
Hans Goudey d7b4350749 Fix T92354: Missing raycast node in geometry nodes add menu
Was removed by mistake in rB0a6cf3ed0c64
2021-10-19 16:27:37 -05:00
Erik Abrahamsson a83b405a45 Geometry Nodes: Replace String node
This commit adds a node that can be used to find and replace strings
inside of the input string. One initial use case is to have an easier
way to add line breaks to strings to the string to curves node.

Differential Revision: https://developer.blender.org/D12721
2021-10-19 15:27:47 -05:00
Sybren A. Stüvel 823996b034 Asset Browser: Improved workflow for asset catalog saving
No longer save asset catalogs on blendfile save. Instead:

- extend the confirmation prompt for unsaved changes to show unsaved
  catalogs.
- In the confirmation prompt, make catalog saving explicit & optional,
  just like we do it for external images. {F10881736}
- In the Asset Browser catalog tree, show an operator icon to save the
  catalogs to disk. It's grayed out if there are no changes to save, or
  if the .blend wasn't saved yet (required to know where to save the
  catalog definitions to). {F10881743}

Much of the work was done by @Severin and reviewed by me, then we
swapped roles.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D12796
2021-10-19 18:07:22 +02:00
Sybren A. Stüvel b6c3b41d41 Cleanup: use nullptr in C++ 2021-10-19 18:05:02 +02:00
Sybren A. Stüvel a7ade57e11 Asset Catalogs: allow creating catalog in unsaved blend file
Allow creating a new asset catalog in a yet-to-be-saved blend file. The
problem was caused by `AssetLibrary` not having an `AssetCatalogService`
right after creation; only after loading data from disk was this
instance created. It's now always there.
2021-10-19 16:55:46 +02:00
Sybren A. Stüvel 79a88b5e91 Fix compilation error about undefined `PATH_MAX` 2021-10-19 16:47:17 +02:00
Hans Goudey 0a6cf3ed0c Geometry Nodes: Fields version of the raycast node
This patch includes an updated version of the raycast node that uses
fields instead of attributes for inputs instead of outputs. This makes
the node's UI much clearer. It should be faster too, since the
evaluation system for fields provides multi-threading.

The source position replaces the input geometry (since this node is
evaluated in the context of a geometry like the other field nodes).

Thanks to @guitargeek for an initial version of this patch.

Differential Revision: https://developer.blender.org/D12638
2021-10-19 09:01:39 -05:00
Sybren A. Stüvel 9a1d75e0b9 Asset Library Service: make insensitive to trailing slashes
Make `AssetLibraryService::get_asset_library_on_disk(path)` insensitive
to trailing slashes; i.e. `get_asset_library_on_disk("/path")` and
`get_asset_library_on_disk("/path/¨)` will now return the same
`AssetLibrary*`.
2021-10-19 15:53:11 +02:00
Sybren A. Stüvel a7075a30e2 BKE_callback_remove: prevent crash on Blender exit
`BKE_callback_remove` now checks whether the callback actually is known,
before trying to remove it.

`BKE_blender_atexit()` runs after `BKE_callback_global_finalize()`. When
an at-exit callback tried to unregister its BKE callbacks, these would
already be unregistered, causing a crash of Blender when exiting,
2021-10-19 15:53:11 +02:00
Hans Goudey 219058c213 Geometry Nodes: Remove implicit realizing and conversion
This commit removes the implicit conversion from points to a mesh
that used to happen before the next modifier. It also removes the
implicit realizing of instances that happened before another modifier.

Now we have specific nodes for both of these operations, the
implicit conversions make less sense, and implicit instance
realizing has already been removed in other nodes.

This adds another geometry nodes modifier before modifiers that would
have realized instances implicitly before. Currently adding another
data-block during versioning after linking means that an assert needs
to be changed. That should be made unnecessary by T92333.

Differential Revision: https://developer.blender.org/D12722
2021-10-19 08:39:10 -05:00
Brecht Van Lommel 7fa6794037 Fix failing view layer tests after recent changes to naming convention 2021-10-19 14:55:06 +02:00
Brecht Van Lommel 9e9d003a82 Render: change view layer name convention to ViewLayer_001 to avoid OpenEXR issues
Some compositing applications do not support spaces and dots in layer names, and change
these to other symbols on import. This causes various compatibility issues, including
with Cryptomatte metadata. While technically those could be considered bugs in the
Cryptomatte implementation of other software, where they are not properly accounting for
that layer renaming, it's not ideal.

The OpenEXR channel naming convention is "layer.pass.channel". We get away with dots in
the layer name since we parse this from right to left, but it's a weak assumption.

Now we don't forbid using spaces or dots, and existing files are unchanged. But at
least by default names will be compatible, and hopefully other software catches up in
time to support more flexible layer names.

Ref T68924
2021-10-19 14:30:45 +02:00
Brecht Van Lommel 8e8932c8ff Render: use "_" as delimiter in AOV names to avoid issues with OpenEXR
OpenEXR uses "." to separate layers/passes/channels, so using AOV.001 is
a problem. Other applications will not be able to parse it correctly.

Default to AOV_001 instead, and don't allow using dots in AOV names.

Fixes T89991
Ref T73266
Ref D12871
2021-10-19 12:59:05 +02:00