The special case that just returns a span was incorrect on the point
domain. It shouldn't apply in that case since the input indices are
meant to be curve indices.
Pull Request: https://projects.blender.org/blender/blender/pulls/138506
Symptoms were drivers still being active while others seemingly
disabled. Indices in the RNA path up to the `ANIM_remove_driver` call
are correct, so it is not entirely clear to me why this goes wrong, but
forcing an update by tagging animation resolves the issue.
NOTE from @dr.sybren : Without this fix, the old copy-for-evaluation
is still there, which still has the driver (because it's a copy)
NOTE: seems we are not handling ND_FCURVES_ORDER anywhere?
Pull Request: https://projects.blender.org/blender/blender/pulls/138490
This converts the public `uiLayoutPanelProp` function to an object oriented
API (`uiLayout::panel_prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.
Pull Request: https://projects.blender.org/blender/blender/pulls/138501
Avoid initializing passes (and requesting their shaders) unless they're
actually needed.
Reduces the number of compiled Overlay shaders at startup
from 70 to 22.
Improves startup times.
Pull Request: https://projects.blender.org/blender/blender/pulls/138457
OpenVDB has a voxel size limit defined by the determinant of the grid
transform, which is equivalent to a uniform voxel size of
`sqrt3(3e-15) ~= 1.44e-5`.
The `mesh_to_density_grid` function was using an arbitrary threshold of
`1.0e-5` for the uniform voxel size.
In this case the voxel size is `~1.343e-5` so it passes the Blender
threshold but crashes in OpenVDB.
This fix adds some convenience functions to check for valid grid voxel
size and transform based on the same determinant metric. This is now
employed consistently in the mesh_to_density_grid, mesh_to_sdf_grid, and
points_to_sdf_grid functions to avoid exceptions in OpenVDB.
MOD_volume_to_mesh, node_geo_volume_to_mesh, BKE_mesh_remesh_voxel have
not been modified, since they have their own error checks with larger
thresholds.
Pull Request: https://projects.blender.org/blender/blender/pulls/138481
The "Active Element" node would return early if the mode was
not `OB_MODE_EDIT`.
For Grease Pencil, we want to be able to query the active layer index
from any mode.
This changes the logic to only return early for the `Point`, `Edge`,
and `Face` element if the mode is not edit mode.
Pull Request: https://projects.blender.org/blender/blender/pulls/138491
This avoid manual code duplication and readability issues.
This is implemented as simple copy pasting of the function
with the different argument count, calling the overload with
the next argument count for each overload.
A `#line` directive is added to each line make sure errors
still make sense and refer to the original line.
Example:
```cpp
int func(int a, int b = 0, const int2 c = int2(1, 0))
{
/* ... */
}
```
Gets expanded to:
```cpp
int func(int a, int b, const int c)
{
/* ... */
}
int func(int a, int b)
{
return func(a, b, int2(1, 0));
}
int func(int a)
{
return func(a, 0);
}
```
Rel #137446
Pull Request: https://projects.blender.org/blender/blender/pulls/138254
Changing the ndof-center without changing `rv3d->dist` can cause a
strange situation when ndof-center can move from a closer object to
orbiting around an object that's farther away - however it's impossible
to zoom to that object.
Ref: !138096
These functions are trivial and shouldn't add the cost of a call.
They appeared in profiles, which they shouldn't since they mostly
just return access to member variables. Inlining them reduces
the backend's overhead when sculpting.
Also reserve a Vector before repeated appending.
Pull Request: https://projects.blender.org/blender/blender/pulls/138349
In the `grease_pencil_wire_batch_ensure` when computing the indices,
the function was using `points_by_curve` instead of
`evaluated_points_by_curve`.
Now the correct indices are used.
Pull Request: https://projects.blender.org/blender/blender/pulls/138489
Implementation of #137341
This adds support for using references to any variable in a local scope
inside the shader codebase.
Example:
```cpp
int a = 0;
int &b = a;
b++; /* a == 1 */
```
Using `auto` is supported for reference definition as the type is not
preserved by the copy paste procedure. Type checking is done by the
C++ shader compilation or after the copy paste procedure during shader
compilation. `auto` is still unsupported for other variable declarations.
Reference to opaque types (`image`, `sampler`) are supported since
they are never really assigned to a temp variable.
This implements all safety feature related to the implementation being
copy pasting the definition string. That is:
- No `--`, `++` operators.
- No function calls.
- Array subscript index needs to be int constants or constant variable.
The copy pasting does not replace member access:
`auto &a = b; a.a = c;` becomes `b.a = c;`
The copy pasting does not replace function calls:
`auto &a = b; a = a();` becomes `b = a();`
While limited, this already allows for nicer syntax (aliasing) for
accessing SSBOs and the potential overhead of a copy semantic:
```cpp
ViewMatrices matrices = drw_view_buf[0];
matrices.viewmat = float4x4(1);
drw_view_buf[0] = matrices;
```
Can now be written as;
```cpp
ViewMatrices &matrices = drw_view_buf[0];
matrices.viewmat = float4x4(1);
```
Which expands to;
```cpp
drw_view_buf[0].viewmat = float4x4(1);
```
Note that the reference semantic is not carried through function call
because arguments are transformed to `inout` in GLSL. `inout` has
copy semantic but it is often implemented as reference by some
implementations.
Another important note is that this copy-pasting doesn't check if a
symbol is a variable. It can match a typename. But given that our
typenames have different capitalizations style this is unlikely to be
an issue. If that issue arise, we can add a check for it.
Rel #137446
Pull Request: https://projects.blender.org/blender/blender/pulls/138412
There is similar issue as what was fixed in autopep8 with the initial
LFS migration: `git ls-tree` running to gather all files contains files
with non-ascii names, such as some non-latin utf-8 files in the tests.
Decode the ls-tree using utf-8 for C code format as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/138488
Blender would crash in the "Set Spline Resolution" when the
Grease Pencil object had a bezier curve and the resolution is
changed.
This was because the triangle cache of the drawing wasn't
recomputed after the number of evaluated points changed.
This patch ensures that the "Show In Front" and "Use Lights" options
in the Grease Pencil Add operator are respected for all object types,
not just those using the Line Art modifier (e.g. GREASE_PENCIL_LINEART_*).
Pull Request: https://projects.blender.org/blender/blender/pulls/138422
Allows basic usage of templated functions.
There is no support for templated struct.
Benefit:
- More readable than macros in shader sources.
- Compatible with C++ tools.
- More sharing possible with host C++ code.
Requirements/Limitations:
- No default arguments to template parameters.
- Must use explicit instantiation for all variant needed.
- Explicit instantiation needs to **not** use argument deduction.
- Calls to template needs to have all template argument explicit
or all implicit.
- Template overload is not supported (redefining the same template
with different template argument or function argument types).
Currently implemented as Macros inside the build-time pre-pocessor,
but that could change to copy-paste to allow better error reporting.
However, the Macros keep the shader code reduced in the final binary
and allow different file to declare different instantiation.
The implementation is done by declaring overloads for each explicit
instantiation.
If a template has arguments not present in function
arguments, then all arguments **values** are appended to the
function name. The explicit template callsite is then modified to use
`TEMPLATE_GLUE` which will call the correct function. This is
why template argument deduction is not supported in this case.
Rel #137446
Pull Request: https://projects.blender.org/blender/blender/pulls/137441
Previously, only the node name was taken into account. However, this
is not practical, because the user usually renames the label instead of the
name and it makes sense to show the user-defined name in the context path.
Previously, when the viewer node or node group name changes,
the change was not updated directly in the spreadsheet. It was
only updated later when the viewer path changed entirely.
This worked in e.g. Blender 4.0 but was broken at some point accidentally.
Now, the context path in the spreadsheet contains the names of node
groups again.
This converts the public `uiLayoutPanel` function to an object oriented
API (`uiLayout::panel`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.
Pull Request: https://projects.blender.org/blender/blender/pulls/138461
In vertex & face modes the selection remained visible when the UV
opacity was zero (or near zero).
In those cases applying the opacity to the edge selection makes sense,
however in edge-select mode this caused UV's to become invisible.
- Use "select_{vert/edge/face}_" convention for UV's
matching edit-mesh naming.
- Rename `show_face_` to `show_face_overlay_` for 3D & UV views.
- Rename `show_face_dots_` to `select_face_dots_` since they're
they display selection and aren't used in object mode.
The same value was used to show selected UV faces & object mode face
overlays. This made logic a little more difficult to follow as the
same value was set & used differently based on the context.
Movieclip can output buffer with smaller resolution than scene
resolution, but this was not handled in `strip_raw_image_size_get()`.
Small downside of this change is, that if movieclip source file can not
be read, its width and height is initialized to `IMG_SIZE_FALLBACK`.
So this may be confusing to users, but this would be quite rare
scenario.
Pull Request: https://projects.blender.org/blender/blender/pulls/138352
This feature allows you to change postion of origin/pivot for images
without changing their position.
It is implemented as property of transform operator. It is activated
by pressing `Ctrl + .` shortcut.
Move Origin item was also added to transform menu.
Origin can be snapped to 3x3 grid on strip image. This represents
most usual anchor points.
Ref: #134251
Pull Request: https://projects.blender.org/blender/blender/pulls/134206
Previously sync-select in edge-select mode behaved in much the same
way as vertex selection, since a selected edge could cause a vertex
on an a disconnected UV island to be selected.
Now single vertices are no longer considered selected when the
Sticky-Mode is set to "Location" (the default).
Notes on changes when sync-select is enabled:
- The main change from a user perspective is edge & face select modes
show the selected edges.
- This resolves a problem in edge & face selection modes where it wasn't
possible to differentiate between a selected edge and two selected
vertices on either side of an unselected edge.
This adds an Import VDB node. It loads all the grids from a .vdb file and hence
outputs a Volume geometry instead of an individual grid.
The grids are cached through the existing volume grid file cache, so they are
automatically deduplicated when volume grids are loaded from files in other
ways.
Pull Request: https://projects.blender.org/blender/blender/pulls/138380
When a new node tree becomes active based on the context, the node editor was
not centered on the new tree. This can easily lead to the situation where there
is no node visible, and the user first has to search for the nodes.
The reason for this is unexpectedly special:
* `snode_set_context` calls `ED_node_tree_start` which adds the `NC_SCENE |
ND_NODES` notifier.
* Typically, this would update the `View2D` of the region in
`node_area_listener`.
* However, `snode_set_context` is called from
`wm_event_do_refresh_wm_and_depsgraph` which happens after(!) the listeners
run. Therefore, the node editor is redrawn before the listener is handled.
* During redraw, the stored view center is overridden. When it is later used in
the listener, the value is lost already.
This patch solves this by updating the view center eagerly when opening changing
what node tree is visible, instead of trying to it lazily where the required
information might be lost already.
Pull Request: https://projects.blender.org/blender/blender/pulls/138389
Both fields have the RNA value defined with a max size of `MAX_NAME`,
despite the underlying DNA value being a dynamic length string.
To fix this, remove the length restriction for the operator.
Pull Request: https://projects.blender.org/blender/blender/pulls/138377
Avoid initializing supbasses (and requesting their shaders) unless
they're actually needed.
Reduces the number of compiled Workbench shaders at startup
from 27 to 9.
Improves startup times.
Pull Request: https://projects.blender.org/blender/blender/pulls/138456
1. Do most of the work in creating meshes in parallel (i.e. everything that
can happen on the non-Main mesh object)
2. Faster creation of transform F-Curves using the same machinery as
!137004 (mostly speeds up animated characters import)
3. Make ufbx do FBX file parsing itself in parallel
Generally makes import 2x-5x faster, more detailed timings in the PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/138367
Currently, the import nodes always reimport on each evaluation. This patch adds
support for caching the loaded geometries. This is integrated with
`BLI_memory_cache.hh` and thus also takes the cache size limit into account. If
an imported file is modified on disk, the cache is invalidated. However,
Geometry Nodes will not automatically reevaluate when a file changes, so the
user would have to trigger the evaluation in some other way.
This is an alternative solution to #124369. The main benefits are that the cache
invalidation happens automatically and that the cache system is more general and
does not have to know about e.g. the different file types.
Caching speeds up node setups that heavily rely on import nodes significantly.
Pull Request: https://projects.blender.org/blender/blender/pulls/138425
This adds a version of `BKE_id_new_nomain` that takes the ID type parameter as
template argument. This allows the function the return the newly created ID with
the correct type, removing the need to use `static_cast` on the call-site.
To make this work, I added a static `id_type` member to every ID struct. This
can also be used to create a similar API for other id management functions in
future patches.
```cpp
// Old
Mesh *mesh = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, "Mesh"));
// New
Mesh *mesh = BKE_id_new_nomain<Mesh>("Mesh");
```
Pull Request: https://projects.blender.org/blender/blender/pulls/138383
Note: this is a partial fix, that makes NEE and forward path consistent
only when `max_transparent_bounce > 0`. It is much more involved to make
forward path tracing support a max transparent bounce of 0, but since we
don't expect people to set up a very low number of transparent bounces,
it is less important to support that specific case.
Pull Request: https://projects.blender.org/blender/blender/pulls/138098