Commit Graph

99470 Commits

Author SHA1 Message Date
Germano Cavalcante
16228f2d71 Fix #107830: missing snap indication in measure tool
Error happened because the activated snap state was different from the
one being drawn.

So create a utility that activates the correct state.
2023-05-11 11:43:02 -03:00
Sybren A. Stüvel
64f9a30cbd Test: actually use the right matrix for unit test
No functional changes, just a test working in debug mode too ;-)
2023-05-11 16:38:17 +02:00
Ray Molenkamp
53bccfe34a CMake/Win: fftw adjust for filename changes in 3.6
Preparation for the the 3.6 library update landing.

The filenames for these libs will change a little bit and 3.6 will add
new library for the fp32 version of fftw.
2023-05-11 08:36:33 -06:00
Bastien Montagne
6f3cf1e436 LibOverride: Fix resync process no properly tagging newly used linked data as directly linked.
LibOverride resync process would not properly 'make local' newly created
overrides (copied from their linked reference). The main consequence was
that some linked data used by these new liboverrides would not be
properly tagged as directly linked.

While this would not be an issue in current codebase, this was breaking
upcomming readfile undo refactor, since some linked data did not get
their local 'placeholder reference' data written in memfile blendfiles.

NOTE: this is more of a quick fix, whole handling of library data in
complex copying cases like that need some more general work, see #107848
and #107847.
2023-05-11 15:55:57 +02:00
Kevin C. Burke
061712fcc6 Add ORIENTATION_PARENT icon
Add ORIENTATION_PARENT icon for Parent Orientation enum

The Parent orientation was introduced in 5c4b0c98d3.

Pull Request: https://projects.blender.org/blender/blender/pulls/107763
2023-05-11 14:50:15 +02:00
Sybren A. Stüvel
39ba60e88d Math: add unit test for mat3_normalized_to_quat_fast
Add a unit test for the fix in 98334b8f7d

No functional changes.
2023-05-11 14:29:48 +02:00
Jeroen Bakker
809a5aa418 Vulkan: Initial Graphics Pipeline
Initial graphic pipeline targeting. The goal of this PR is to have an initial
graphics pipeline with missing features. It should help identifying
areas that requires engineering.

Current state is that developers of the GPU module can help with the many
smaller pieces that needs to be engineered in order to get it working. It is not
intended for users or developers from other modules, but your welcome to learn
and give feedback on the code and engineering part.

We do expect that large parts of the code still needs to be re-engineered into
a more future-proof implementation.

**Some highlights**:
- In Vulkan the state is kept in the pipeline. Therefore the state is tracked
  per pipeline. In the near future this could be used as a cache. More research
  is needed against the default pipeline cache that vulkan already provides.
- This PR is based on the work that Kazashi Yoshioka already did. And include
  work from him in the next areas
  - Vertex attributes
  - Vertex data conversions
  - Pipeline state
- Immediate support working.
- This PR modifies the VKCommandBuffer to keep track of the framebuffer and its
  binding state(render pass). Some Vulkan commands require no render pass to be
  active, other require a render pass. As the order of our commands on API level
  can not be separated this PR introduces a state engine to keep track of the
  current state and desired state. This is a temporary solution, the final
  solution will be proposed when we have a pixel on the screen. At that time
  I expect that we can design a command encoder that supports all the cases
  we need.

**Notices**:
- This branch works on NVIDIA GPUs and has been validated on a Linux system. AMD
  is known not to work (stalls) and Intel GPUs have not been tested at all. Windows might work
  but hasn't been validated yet.
- The graphics pipeline is implemented with pixels in mind, not with performance. Currently
  when a draw call is scheduled it is flushed and waited until it is finished drawing, before
  other draw calls can be scheduled. We expected the performance to be worse that it actually
  is, but we expect huge performance gains in the future.
- Any advanced drawing (that is used by the image editor, compositor or 3d viewport) isn't
  implemented and might crash when used.
- Using multiple windows or resizing of window isn't supported and will stall the system.

Pull Request: https://projects.blender.org/blender/blender/pulls/106224
2023-05-11 13:01:56 +02:00
Sybren A. Stüvel
98334b8f7d Fix #107745: Matrix conversion can produce non-unit quaternion
Due to cumulative floating point errors the quaternions produced by
`mat3_normalized_to_quat_fast()` could be non-unit length. This is now
detected, and quaternions are normalised when necessary.

This is a slight roll-back of 756538b4a1,
which removed the normalisation altogether, but did introduce this issue.
2023-05-11 12:28:04 +02:00
Jeroen Bakker
8aff713270 Vulkan: Convert VertexBuffer to Contain Supported Attributes
Vulkan doesn't have a conversion from uint32_t/int32_t to float. It does
have conversions from 16/8 bits. Main reason is that Vulkan expects that
there is no benefit when converting 32 bits from one type to the other
and should be solved by passing the right data type.

In Blender however this isn't the case as there are benefits on other
GPU backends (OpenGL for example).

This PR adds helper function to check if conversion is needed and
perform any conversions in place. It also implements the function to
upload vertex buffers to the GPU.

NOTE: Test cases have been added to validate this, but they are not
able to run on the Vulkan backend just yet, because they require the
graphics pipeline to be available.

Pull Request: https://projects.blender.org/blender/blender/pulls/107733
2023-05-11 12:23:23 +02:00
Campbell Barton
d9293ca478 Fix missing include, unused argument warning 2023-05-11 17:46:23 +10:00
Campbell Barton
575c3f3b25 BLI_string: replace UTF8 skip table & macros with functions
Using a function that operates on ranges instead of the lookup table
makes BLI_strncpy_utf8 around 2.8x faster in my tests.
2023-05-11 17:35:34 +10:00
Jeroen Bakker
a9c1d47255 GPU: Added Tests For Blend state And Immediate Mode
This PR adds several tests to GTest for testing blend states
and immediate mode. The immediate mode test are basic and will
be extended in the near future.

The tests have been developed in order to get the first pixel on
screen for the Vulkan backend. In the first phase of this goal we
had to validate that everything was working as expected without
being able to validate it by starting Blender.

Pull Request: https://projects.blender.org/blender/blender/pulls/107834
2023-05-11 09:15:39 +02:00
Jeroen Bakker
a0ea40034b Vulkan: Make ShaderInput Optional
ShaderInput lookup used to be explicit as in we know for sure that the
shader input exists. This was guarded by a assert. During development
of the graphics pipeline we came to the conclusion that this isn't
always the case due to its late bindings of resources.

This PR Makes the shader input lookup return an optional result.
This result can then be checked depending on the area where it is used
to validate the existence.

Pull Request: https://projects.blender.org/blender/blender/pulls/107735
2023-05-11 08:44:57 +02:00
Omar Emara
6698e8f4a0 Realtime Compositor: Implemenet Plane Track Deform node
This patch implements the Plane Track Deform node for the realtime
compositor. The implementation is mostly similar to the Corner Pin node,
but it is generalized to multiple homography matrices to take motion
blur into account.

Pull Request: https://projects.blender.org/blender/blender/pulls/107811
2023-05-11 07:16:24 +02:00
Chris Blackbourn
ccb2dbddac UV: Simplify packer, improving performance, efficiency and fixing bugs
Adds a generic `is_larger` and `get_aspect_scaled_extent` function to
simplify packing logic.

Migrate several packing functions so that they only improve a layout,
and early-exit packing if a better layout already exists.

Fix a `rotate_inside_square` logic error during xatlas packing.
2023-05-11 17:13:05 +12:00
Campbell Barton
cc9678b5fe Fix BLI_strncpy_utf8 over-read for code points containing a null byte
BLI_strncpy_utf8 didn't check for null bytes within bytes stepped
over by the variable length UTF8 encoding.

While a valid UTF8 string wont include these, it's possible Latin1
encoding or a truncated string includes such characters.

In this case, the entire string is copied as it's not the purpose of
this function to correct or strip invalid/truncated encoding,
only to prevent it from happening in the first place.
2023-05-11 11:44:38 +10:00
Chris Blackbourn
8612dfea44 Cleanup: format 2023-05-11 12:08:28 +12:00
Hans Goudey
da43c42e40 Cleanup: Avoid redundant attribute adding in extrude node
These attributes already exist, not need to use the "or_add" function.
2023-05-10 15:27:27 -04:00
Hans Goudey
143ca272bd Geometry Nodes: Slightly optimize mesh to curve node
Use the offset indices pattern to avoid keeping separate arrays for the
offset of a vertex's neighbors and the number of neighbors. This gave
a 9% speedup for the conversion, from 42.9 ms to 39.3 ms.
2023-05-10 15:24:12 -04:00
Hans Goudey
5b5e6a846a Geometry Nodes: Extrude: Skip topology map with no edge attributes
In vertex extrusion mode, when there are no edge attributes we can avoid
creating a topology map meant for mixing old values. This makes
simulation caching for a curl noise demo file from user Higgsas 10%
faster (from 44s to 40s to calculate 230 frames).
2023-05-10 15:24:12 -04:00
Ray Molenkamp
3958f4cb02 Cleanup: Fix build warning with MSVC
This cleans up the following warning

BLI_mempool.c(291):warning C4100: 'pool':unreferenced formal parameter

Warning introduced by c1d4b6f339
2023-05-10 12:59:11 -06:00
Ray Molenkamp
2158c92d9b CMake/Windows: Install FFMpeg 6.0 dlls when available
Needed for the 3.6 library update.
2023-05-10 12:18:54 -06:00
Lukas Tönne
3913d22757 Fix #107779: Support simulation zone remapping in node group operators
Adds a `remap_pairing` function for node group operators that ensures
the simulation input nodes' `output_node_id` matches the new node are
creating a group, ungrouping a node group, or separating from a group.

Also fixes a crash in the "Group Separate" operator when group
input/output nodes are included in the selection.

Pull Request: https://projects.blender.org/blender/blender/pulls/107807
2023-05-10 17:56:23 +02:00
Iliya Katueshenock
939f7e8010 Fix: Empty built-in attributes are duplicated by some nodes
The attributes API does not have the error that a null attribute
does not exist and requires a new layer to be created.

Pull Request: https://projects.blender.org/blender/blender/pulls/107814
2023-05-10 17:40:37 +02:00
Bastien Montagne
de21a0c901 Fix (unreported) remapping code wrongly skipping UI data when it should not.
Issue was that, when UI-related code _is_ requested in foreach_id
processing, `ID_SCR` screen ID type can actually use any kind of ID
(through e.g. the Outliner space).

So `BKE_library_id_can_use_filter_id` had to be updated with a new
parameter (whether UI-related data should be taken into account or not).
2023-05-10 16:36:29 +02:00
Bastien Montagne
ade83b21d1 Fix (unreported) crash in readfile code when deleting an invalid shapekey.
The root of the issue was that while reading a new blendfile, the
current `G_MAIN` is still the old one, not the one in which new data is
being read.

Since the remapping callback taking care of UI data during ID remapping
is using `G_MAIN`, it is processing the wrong data, so when deleting the
invalid shapekey (from `BLO_main_validate_shapekeys`), the UI data of
the new bmain would not be properly remapped, causing invalid memory
access later when recomputing user counts (calls to
`BKE_main_id_refcount_recompute`).

This is fixed by adding a new `BKE_id_delete_ex` function that takes
extra remapping options parameter, and calling it from
`BLO_main_validate_shapekeys` with extra option to enforce handling of
UI data by remapping code.

NOTE: At some point we have to check if that whole UI-callback thing is
still needed, would be good to get rid of it and systematically process
UI-related ID pointers like any others. Current situation is... fragile
to say the least.
2023-05-10 16:35:49 +02:00
Hans Goudey
8efd6d5f82 Geometry Nodes: Make simulation caching optional
For realtime use cases, storing the geometry's state in memory at every
frame can be prohibitively expensive. This commit adds an option to
disable the caching, stored per object and accessible in the baking
panel. The default is still to enable caching.

Pull Request: https://projects.blender.org/blender/blender/pulls/107767
2023-05-10 16:01:38 +02:00
Philipp Oeser
c7e9932c46 Fix #107677: Hair particle edit wrong on object with mirror modifier
Caused by 2fb31f34af.

Since above commit, we are now calling `BKE_mesh_orco_verts_transform`
not only from `psys_face_mat` and `psys_mat_hair_to_orco`, but now also
from `psys_particle_on_dm` > `psys_interpolate_face`, so we get double
transforms with mirror.

Remove the "extra" call in `psys_mat_hair_to_orco`.

Should be backported to 3.3 LTS as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/107804
2023-05-10 15:16:18 +02:00
Philipp Oeser
179c419115 Fix #107608 : Changing color for simulation zone doesn't save
This looks like a missing version bump for 0de54b84c6, now added.
Also included the change for 493c4dd65b here.

Pull Request: https://projects.blender.org/blender/blender/pulls/107808
2023-05-10 15:06:50 +02:00
Jacques Lucke
db6eda6c60 Geometry Nodes: show simulated frames only when there is a simulation
Previously, the timeline would sometimes show cached frames even when
there is no simulation zone in the node tree.
2023-05-10 14:41:37 +02:00
Hans Goudey
17d161f565 Mesh: Reduce custom normal calculation memory usage
Avoid storing redundant and unnecessary data in temporary arrays during
face corner normal calculation with custom normals. Previously we used
96 bytes per normal space (`MLoopNorSpace` (64), `MLoopNorSpace *` (8),
`LinkData` (24)), now we use 36 (`CornerNormalSpace` (32), `int` (4)).
This is achieved with a few changes:
- Avoid sharing the data storage with the BMesh implementation
- Use indices to refer to normal fan spaces rather than pointers
- Only calculate indices of all corners in each fan when necessary
- Don't duplicate automatic normal in space storage
- Avoid storing redundant flags in space struct

Reducing memory usage gives a significant performance improvement in
my test files, which is consistent with findings from previous commits
(see 9fcfba4aae). In my test, the time used to calculate
normals for a character model with 196 thousand faces reduced from
20.2 ms to 14.0 ms, a 44% improvement.

Edit mode isn't affected by this change.

A note about the `reverse_index_array` function added here: this is the
same as the mesh mapping functions (for example for mapping from
vertices to face corners). I'm planning on working this area and hoping
to generalize/reuse the implementation in the near future.

Pull Request: https://projects.blender.org/blender/blender/pulls/107592
2023-05-10 14:41:10 +02:00
Jacques Lucke
493c4dd65b Geometry Nodes: add theme option for simulated frames in timeline
The new theme setting for the dope sheet (timeline) allows changing the
color of the bar that shows which frames are cached/baked. The
invalid/cached/baked status is differentiated by hardcoded transparency
values. In theory, those could be separate theme settings though.

Pull Request: https://projects.blender.org/blender/blender/pulls/107738
2023-05-10 14:19:27 +02:00
Philipp Oeser
d6092a6c36 Fix #107670: Lattice undo misses vertex group weights data
Operations such as assigning or removing weights were simply not
undoable (no previous weights were applied back to the EditLatt). Now
add MDeformVert data to UndoLattice and handle with
appropriate functions during Undo.

Pull Request: https://projects.blender.org/blender/blender/pulls/107776
2023-05-10 09:23:40 +02:00
Omar Emara
fc7b5f993b Cleanup: Follow naming conventions for Plane Track node 2023-05-10 09:51:47 +03:00
Campbell Barton
ed5dee857e Fix blender failing to link WITH_USD when building for the first time
Blender would fail to link to USD before MaterialX files were
copied to the install targets lib/ directory.
Resolve by including ${LIBDIR}/materialx/lib in link_directories.
2023-05-10 16:25:17 +10:00
Campbell Barton
0d171bc5be Cleanup: quiet enumerated type warning 2023-05-10 14:44:12 +10:00
Campbell Barton
ee09d75e80 Cleanup: naming of looptri indexing variables
looptris were referred to as both tris & faces, sometimes polygons
were referred to as faces too. Was especially error prone with
callbacks that took both a tri and a tri_i arguments.
Sometimes tri_i represented a looptri index, other times the corner of
the triangle from 0-2. Causing expressions such as:
`args->mlooptri[tri].tri[tri_i]`

- Rename tri & tri_index -> looptri_i.
- Rename faces -> looptris.
- Rename face_index/poly_index/poly -> poly_i.
- Declare looptri_i at the start of the loop and reuse it,
  in some cases it was declared with args->prim_indices[i] being
  used as well.
2023-05-10 14:21:39 +10:00
Campbell Barton
0168c4b893 Cleanup: remove unused "dds" directory
Missing from [0] which duplicates some code into format_dds.cc.

[0]: aa3bdfd76a
2023-05-10 12:35:41 +10:00
Campbell Barton
46479f41e1 Cleanup: quiet dangling-reference warnings with GCC13 2023-05-10 12:06:27 +10:00
Richard Antalik
bb51cdedb7 Cleanup: Clang-format 2023-05-09 22:47:57 +02:00
Hans Goudey
ac02f94caf Fix #107123: Refactor sculpt normal calculation to require vert poly map
Change PBVH normal calculation to also update vertices connected to
vertices with an update tag. This is necessary because vertex normals
are the mixed face normals, so changing any face's normal will change
the normals of all connected faces.

This change requires that the PBVH always have a vertex to face
topology map available. In the future this will likely be cached on
meshes though, which will reduce the delay it adds when entering sculpt
mode.

Now, first all face normals are updated, then the normals for
connected vertices are mixed from the face normals. This is a
significant simplification to the whole process, which previously
worked with atomics and normals at the triangle level. Similar changes
changes for regular non-sculpt normal calculation are being worked on
in #105920.

Pull Request: https://projects.blender.org/blender/blender/pulls/107458
2023-05-09 22:36:30 +02:00
Richard Antalik
c9be925f7d Fix #107289: Sound strips are invisible and overlap
In some cases strips may end up with speed factor of 0 which causes
offsets and position to be invalid. The exact cause is unknown, but
most likely caused by `do_versions_sequencer_init_retiming_tool_data()`.

This could possibly happen if 3.6 file is saved with 3.5 version and
then opened again with 3.6 version.

To fix strips, retiming data is removed, start offset reset and speed
factor is set to 1. Previous versioning code is fixed, so speed factor
is never set to 0.

Pull Request: https://projects.blender.org/blender/blender/pulls/107798
2023-05-09 22:14:17 +02:00
Hans Goudey
3a0d17ceea Cleanup: Correct commet about curves bounds
Missing from 97a8bb450c
2023-05-09 13:03:08 -04:00
Hans Goudey
3f44b24cf2 BLI: Use inline instead of static for bounds functions
Avoid instantiating the templates separately in every translation unit.
This saves 20 KB in my Blender binary. Also remove a timer mistakenly
committed.
2023-05-09 12:54:55 -04:00
Ray Molenkamp
d65d9f4b97 CMake/Windows: Install materialX render dll's when available
This is in preparation for the 3.6 library update landing on windows.
2023-05-09 10:21:32 -06:00
Hans Goudey
6323d56eb5 Mesh: Tag no loose verts and edges when converting from BMesh
This saves about 6 ms every update when in edit mode on a 1 million
face grid. For reference, the BMesh to Mesh conversion took 80 ms,
before and after the change.
2023-05-09 12:13:09 -04:00
Sybren A. Stüvel
8ce040cf1a Anim: avoid increasing NULL pointer
Avoid calling `next++` when `next` is `NULL`.

In practice this should be a non-functional change, but it avoids ASAN
messages.
2023-05-09 16:05:40 +02:00
Lukas Tönne
263bf63509 Cleanup: Remove versioning for simulation zone socket identifiers
This was added temporarily during development.
Loading files created in the geometry-nodes-simulation branch (3.5.4
and older) will remove links from simulation zones, which need to be
added back manually.

Pull Request: https://projects.blender.org/blender/blender/pulls/107781
2023-05-09 15:15:40 +02:00
Clément Foucault
4436909c1d Workbench-Next: Fix shader compilation
Was a missing case from recent fix:
aa31d9be80
2023-05-09 14:37:13 +02:00
Jeroen Bakker
a68c78a3ee Vulkan: Don't Use Tiled Drawing
Similare to the Metal backend, Vulkan keeps data of the full texture
around as they will be executed by the same submission. So there are
no benefits to splice a texture into smaller parts, but adds overhead
as more commands are required to be processed.

Pull Request: https://projects.blender.org/blender/blender/pulls/107728
2023-05-09 14:12:44 +02:00