Commit Graph

139952 Commits

Author SHA1 Message Date
Sean Kim
810fee35f3 Fix #126074: Sculping on a non-basis shape key modifies mesh
This commit prevents writing to the mesh when sculpting on a non-basis
shape key. Prior to this, we incorrectly were applying changes to the
base mesh, even though those changes were not visible with the shape
keys still active, causing new shape keys to have a copy of the deformed
mesh data.

Pull Request: https://projects.blender.org/blender/blender/pulls/126107
2024-08-09 22:34:25 +02:00
Hans Goudey
ae13fb5a53 Refactor: Sculpt: Various cleanups in relax brush
- Use `Vector::remove_if` rather than custom "filter" functions copying
  data to new vectors.
- Pass `float3` by const reference.
- Reorder arguments to pass constant/operation-global arguments first,
  also using consistent order for mesh data arrays.
- Use const for some `Object` arguments.
- Initialize zero `float3` in a simpler way.
- Simplify neighbor averaging by checking for empty vectors first.
- Use more standard grids index variable names
- Remove `BLI_NOINLINE` from functions called for every element, more
  consistent usage in general.

Pull Request: https://projects.blender.org/blender/blender/pulls/126145
2024-08-09 21:37:58 +02:00
Philipp Oeser
3e5751c726 Fix: Animation Editors Dopesheet RNA paths incomplete/wrong
Somewhat similar to !125365, !126035 and !125963 (but more specialized
for Dopesheet), this PR adds the missing "areas[x].spaces[x]" subpath to
an Animation Editor (Graph, Dopesheet, NLA) `Dopesheet` struct and its
properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/126132
2024-08-09 20:00:15 +02:00
Hans Goudey
4349d6b766 Fix #126101: Crash with lines generated by geometry nodes grid node
The grid geometry creation incorrectly tagged the mesh with no loose edges
or vertices, breaking invariants of the caches that are relied on elsewhere.
2024-08-09 13:49:06 -04:00
Jesse Yurkovich
3c394d39f2 Fix: USD: Write sparse attribute data correctly
The common code which writes out attribute data was seemingly not
performing the right sequence of calls for the UsdUtilsSparseValueWriter
to actually write sparse data.

See PR for a test file and .usda files produced with 4.1 and now with
this change applied.

Pull Request: https://projects.blender.org/blender/blender/pulls/126113
2024-08-09 19:48:52 +02:00
Jesse Yurkovich
5835ea1eaf Build: C++20: Properly implement some definitions of operator==
Several `operator==` methods were mis-implemented; they were not defined
as `const` when implemented as part of the class rather than as friends.
C++20 is more strict about this now.

Example errors: https://godbolt.org/z/h8G5jaoha

Ref #125881

Pull Request: https://projects.blender.org/blender/blender/pulls/126121
2024-08-09 19:48:05 +02:00
Jesse Yurkovich
67eef274ee Build: C++20: Replace the removed std::shared_ptr::unique API
C++20 removes the `std::shared_ptr::unique()` API with the suggestion to
use the `use_count()` method instead.

Note that we are using the unique/use_count APIs in a way that is
generally cautioned against though our usage patterns may be fine.

See: https://en.cppreference.com/w/cpp/memory/shared_ptr/unique
Example errors: https://godbolt.org/z/1j3zzd1hP

Ref #125881

Pull Request: https://projects.blender.org/blender/blender/pulls/126120
2024-08-09 19:47:29 +02:00
Clément Foucault
4d17c674af Overlay-Next: Add debug group to edit mesh 2024-08-09 19:20:59 +02:00
Falk David
e2ade82b41 Annotations: Revert removal of some API functions
These were removed by cc28ad8dcf
but shouldn't have been.

Since these are used by some addons to e.g. add new
annotation layers, it's better to keep them around.

Pull Request: https://projects.blender.org/blender/blender/pulls/126096
2024-08-09 17:28:30 +02:00
Clément Foucault
2c275aec87 Overlay-Next: Mesh Edit Mode
This includes the port of the edit edge shader to the new
primitive expansion API, removing split codepath and
code duplication.

Some of the shader code is duplicated for keeping the
legacy engine untouched.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/125921
2024-08-09 16:29:59 +02:00
Laurynas Duburas
e5805ba07d Overlay-Next: Force Field
Overlay-Next version of force field.

Rel #102179

#109059 was used as a reference.

Pull Request: https://projects.blender.org/blender/blender/pulls/126060
2024-08-09 16:26:17 +02:00
Laurynas Duburas
4505b854f7 Overlay-Next: Relation
Overlay-Next version of relations.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/125894
2024-08-09 16:25:38 +02:00
Hans Goudey
1079be11b3 Fix: More GPU subdivision crashes with loose edges
Because the previous fix stopped creating these VBOs when they
would be empty we need more null checks. Alternatively still
creating them but not binding them might be a better solution
but just adding null checks seems like the simpler approach
right now.

Pull Request: https://projects.blender.org/blender/blender/pulls/126073
2024-08-09 15:53:04 +02:00
Clément Foucault
bd9ce206db Fix: DRW: Missing vnor attribute on edit mesh cage
Fixes ae85b54ffc
2024-08-09 15:27:53 +02:00
Pratik Borhade
4d572b216f Fix #126131: GPv3: Crash when deleting everything in edit mode
Assert in debug build, allocated vertex buffer has garbage data when
total points in the drawing are zero, Nothing is copied to vertex buffers
from `copy_transformed_positions()`. To fix the crash, exit early when
the number of points is zero and execute `DRW_shgroup_call_no_cull`
macro when batch is non-null.

Pull Request: https://projects.blender.org/blender/blender/pulls/126134
2024-08-09 15:23:10 +02:00
Lukas Tönne
f313fb4709 Fix #125970: GPv3 primitive tool is not initializing selection attribute
The primitive tool uses the `CurvesGeometry::resize` function which
leaves the end of the range uninitialized. The
`fill_attribute_range_default` function must be used to ensure all
existing attributes are initialized for the new points.

Pull Request: https://projects.blender.org/blender/blender/pulls/126127
2024-08-09 15:06:43 +02:00
Aras Pranckevicius
983687ebfc Tests: extend OBJ test coverage for #126065 2024-08-09 14:49:17 +03:00
Scurest
86e7668b11 Fix #117367: OBJ importer does not correctly import vertex colors when not all vertices have them
Lift certain incorrect assumptions about the order of vertices in
an OBJ file when processing vertex colors, which could lead to
missing or randomly permuted colors.

Replaces the list-of-blocks representation, attuned to assumptions
that the verts in an object form a contiguous subrange, with a
flat array better suited for random-access.

Co-authored-by: scurest <scurest@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/126065
2024-08-09 08:53:49 +02:00
Clément FOUCAULT
58d04bfa7c Fix: DRW: Missing vnor attribute on edit mesh and edges
Fixes commit ae85b54ffc
2024-08-09 08:30:32 +02:00
Clément FOUCAULT
a6ec643229 Fix: DRW: Missing data upload
Only the `vert_len == 0` is invalid.

Fixes #126097
2024-08-09 08:18:51 +02:00
Clément FOUCAULT
724112d51d Fix: DRW: Missing default enabled program point size
This state should always be enabled for internal reasons.
2024-08-09 08:16:21 +02:00
Clément FOUCAULT
ae85b54ffc Fix: DRW: Missing vnor attribute on edit mesh and edges
This resulted in the lack of fresnel effect on dense meshes
in edit mode when GPU subdiv was not used.
2024-08-09 08:16:21 +02:00
Hans Goudey
0250596f5b Cleanup: Sculpt: Remove more unnecessary shape key flushing
Similar to 3acb5ae41b.
2024-08-08 15:56:38 -04:00
Hans Goudey
72b5fd677b Cleanup: Sculpt: Use C++ Array for fake neighbor indices 2024-08-08 15:56:38 -04:00
Hans Goudey
a2e3abd2d0 Refactor: Sculpt: Fake neighbor data creation
Part of #118145.
As noted in a comment, this algorithm has O(n^2) runtime which is quite
bad. Ideally we would be able to look into a better solution at some point,
but I just refactored the existing algorithm here.
2024-08-08 15:56:38 -04:00
Hans Goudey
68146fe479 Fix: Sculpt pose brush incorrectly accumulates translations
Use the same fix as the mesh filter and add a comment so it's reusable
in other places too.
2024-08-08 15:56:38 -04:00
Jesse Yurkovich
c862d40e09 Fix: USD: Ensure animated velocities are loaded correctly in rare case
If velocity attributes are the only thing being animated, we would fail
to add the cache modifier. This prevents velocity attribute data from
being updated as the timeline changes.

This is a rather rare case. Typically if velocity is changing that would
imply the positions of the mesh are also changing, and the positions
will add the modifier correctly in that case.

Pull Request: https://projects.blender.org/blender/blender/pulls/126105
2024-08-08 21:54:18 +02:00
Hans Goudey
3acb5ae41b Cleanup: Sculpt: Remove unnecessary deform flushing function
We now deform the active shape key and other original data while deforming
the evaluated/deformed positions, rather than before, when we delayed that to
afterwards and affected the entire mesh no matter the area sculpted. This is all
handled by `write_translations` now.
2024-08-08 12:29:50 -04:00
Hans Goudey
f09395c69e Refactor: Sculpt: Refactor relax mesh filter
Part of #118145.
This is an intermediate step. Next the relax functions will be shared
with the brush. For now just getting rid of the iteration macro is
worth it.

Pull Request: https://projects.blender.org/blender/blender/pulls/126099
2024-08-08 18:19:54 +02:00
Falk David
0e2ef7f6f1 Geometry Nodes: Default opacity value in "Curves to Grease Pencil" node
When a curve instance did not have a "opacity" attribute, the default would be 0.
This meant that when creating Grease Pencil layers from scratch, the user
would need to manually write a "opacity" attribute.

Now the default value is 1, so that this step is no longer necessary.
2024-08-08 17:58:26 +02:00
Hans Goudey
8c04261644 Cleanup: Sculpt: Pass vertex instead of iterator struct to relax function 2024-08-08 11:39:59 -04:00
Sean Kim
f11b650767 Refactor: Add SCULPT_vertex_attr_get overloads
* Adds overloads for different vertex types
* Cleans up original code

Pull Request: https://projects.blender.org/blender/blender/pulls/126070
2024-08-08 16:57:38 +02:00
Sergey Sharybin
0549be7128 Libs: macOS: Update Python version to 3.11.9
Ref #125241

Pull Request: https://projects.blender.org/blender/blender/pulls/126085
2024-08-08 16:49:59 +02:00
Jacques Lucke
29edcef5c9 Fix #125670: Regression: Setting parent to triangle changes object location
This fixes two things:
* Pass the evaluated object into `BKE_object_as_kdtree` instead of the original
  one. `BKE_object_as_kdtree` uses functions on the object which are only
  expected to be executed on evaluated objects, such as
  `BKE_object_get_mesh_deform_eval`. Note that this is the only place where
  `BKE_object_as_kdtree` is used.
* Tag depsgraph at the end of setting parent. This way,
  `BKE_object_get_evaluated_mesh` will return the correct mesh instead of null.
  It was returning null because it the object is not in a fully evaluated state
  if it just has been tagged as requiring an update.

Pull Request: https://projects.blender.org/blender/blender/pulls/126086
2024-08-08 16:42:53 +02:00
Omar Emara
f2fcbc3330 Cleanup: Format 2024-08-08 17:36:23 +03:00
Hans Goudey
d99e6f82da Cleanup: Move some sculpt mode functions to C++ namespace 2024-08-08 10:11:52 -04:00
Pratik Borhade
9ca6e049a7 GPv3: Draw Mode: Context menu
Right click context menu has been missing in gpv3 draw mode.
Similar to gp legacy, this includes color picker, active layer etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/125964
2024-08-08 16:03:09 +02:00
Sergey Sharybin
ce6454d02f Fix #126005: x64 Blender on Apple Silicon doesn't render properly in Cycles GPU
The GPU packed state is a static check from the Cycles core perspective,
and it is disabled for non-Apple Silicon GPUs. However, the Metal kernel
always used packed integrator.

This change makes it so the Host and Device side checks for the Host CPU
are aligned, and that Device-side packed state check does not differ from
the Host side.

Pull Request: https://projects.blender.org/blender/blender/pulls/126082
2024-08-08 16:01:23 +02:00
Bastien Montagne
9106383a52 Fix #99875: Reserve 0 SDNA struct index for raw data.
This commit essentially adds a fake SDNA struct info at struct index
`0`, ensuring that no actual SDNA struct will use that identifier from
now on.

Pull Request: https://projects.blender.org/blender/blender/pulls/125730
2024-08-08 15:56:33 +02:00
Hans Goudey
006f954f5c Sculpt: Refactor area normal/center sampling
Part of #118145.
Structure the sampling code more like the brush code, processing the
distances for all vertices in a node at the same time. However, because
this is such a common code path, I compromised a bit on the code's
simplicity to improve performance, mostly by avoiding the use of more
local arrays like we often do for brushes, and also by skipping loop
iterations when the factor is zero. Avoiding the square root for filtered
vertices had a large performance impact of about 5-10% for example.

This is the last use of the sculpt brush test functions and structs which
allows removing them, completing a large part of the overall refactor.

The newly added `_sq` versions of the distance functions are deduplicated
from the non-square versions by separating the square roots to a separate
loop at the end. In my testing that had a ~1% performance cost, though
with variable timing results. I hope that smaller nodes will remove
that cost in the future.

Some rough numbers with the brush benchmark file:
Before: 0.471->0.476s
Without the filtered sqrt: ~0.5-0.53s
After: ~0.473-0.475s

Pull Request: https://projects.blender.org/blender/blender/pulls/126058
2024-08-08 15:41:59 +02:00
Omar Emara
f40cf759c7 Compositor: Add experimental option for new CPU compositor
This patch introduces a new experimental option for the new CPU
compositor under development. This is to make development easier such
that it happens directly in main, but the compositor is not expected to
work and will probably crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/125960
2024-08-08 15:40:06 +02:00
Jacques Lucke
d74d8ceb23 Cleanup: move BKE_packedFile.h to C++
Part of #103343.
2024-08-08 15:13:20 +02:00
Falk David
2eba062ac0 GPv3: Add initial tests for Python API
This adds some initial tests for the Grease Pencil Python API:
 - Testing Grease Pencil ID
 - Testing Grease Pencil layer API

Pull Request: https://projects.blender.org/blender/blender/pulls/126090
2024-08-08 14:42:24 +02:00
YimingWu
3f5d380365 Fix #125897: Use cyclic when handling curves selection
Curves selection didn't take cyclic into account, so when using box/
circle/lasso selections they won't trigger if only the "closing" segment
on a cyclic curve is touched. Now the code properly handles those
situations.

Pull Request: https://projects.blender.org/blender/blender/pulls/125900
2024-08-08 14:12:09 +02:00
Eoin Mcloughlin
5ee7d02840 Fix #91369: Remove physics constraint references to avoid crash on undo
Fixes #91369, where a pointer to a deleted btTypedConstraint instance
was being dereferenced, causing a crash.

What was happening was:
1. When the animation starts the first time, BKE_rigidbody_rebuild_sim
  eventually calls btDiscreteDynamicsWorld::addConstraint, which in turn
  will store a pointer to the btTypedConstraint in
  btRigidBody::m_constraintRefs for each body in the constraint
2. When undoing, the btDynamicsWorld is deleted, then the Object
  containing the btTypedConstraint (taking the btTypedConstraint with
  it) - however, the pointer to the btTypedConstraint is still in the
  btRigidBody!
3. When playing the animation a second time, rigidbody_update_simulation
  will rebuild the simulation, which causes RB_body_delete to be called,
  which iterates over all the body's m_constraintRefs and dereferences
  the deleted pointer.

Co-authored-by: Eoin Mcloughlin <hkeoin@eoinrul.es>
Pull Request: https://projects.blender.org/blender/blender/pulls/126079
2024-08-08 14:05:14 +02:00
Omar Emara
149825bc2a Fix #125946: Crash when adding compositor node
Blender crashes when adding any Color compositor node when both the
viewport and the interactive compositors are active at the same time.
This is caused by a threading issue where both threads try to compile
the same GPU material at the same time.

To fix this, we protects GPU material pass compilation using a mutex.

Pull Request: https://projects.blender.org/blender/blender/pulls/126084
2024-08-08 13:54:22 +02:00
Falk David
c5f95c8e2c Cleanup: Formatting 2024-08-08 13:05:14 +02:00
Falk David
1b2b47d6d7 Fix: GPv3: Python API: Wrong argument type in remove function
The `bpy.data.grease_pencils_v3.remove()` function expected the wrong
`ID` type as an input.
2024-08-08 13:03:21 +02:00
Sergey Sharybin
7e9776a167 Fix #125863: Crash baking textures with Cycles Metal
The issue was caused by an attempt to write buffer pass which is
actually supposed to be calculated as compositing (either summing
direct/indirect lights, optionally diving by albedo).

The fact that the crash was only observed on Metal is a lucky
con-incident: it just happened to be so that writing at offset
-1 to the render buffer did not trigger obvious issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/126057
2024-08-08 12:08:35 +02:00
Jacques Lucke
2e412e683b Tools: improve gdb frame filter for lazy functions 2024-08-08 12:02:00 +02:00