Commit Graph

4430 Commits

Author SHA1 Message Date
Ray Molenkamp b683bcc46c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any bf_intern_clog paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115323
2023-11-24 17:12:24 +01:00
Jason Fielder 18f7d158fe GPU: cleanup texture view usage flags
Texture usage flag `GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW`
was originally implemented and used too conservatively for many
cases in which the underlying API flags were not required.

Renaming to `GPU_TEXTURE_USAGE_FORMAT_VIEW` to reflect
the only essential use case for when a texture view is initialized with
a different texture format to the source texture. Texture views can
still be created without this flag when mip range or base level is
adjusted,

This flag is still required by stencil views and internally by the Metal
backend for certain feature support such as SRGB render toggling.

Patch also includes some small changes to the Metal backend to
adapt to this new compatibility and correctly capture all texture view
use-cases.

Related to #115269

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/115300
2023-11-24 15:21:00 +01:00
Hans Goudey 02a95198d2 Fix: GPv3: Missing curve type counts update in hard erasor 2023-11-22 14:35:53 -05:00
Hans Goudey e28a782dbe GPv3: Avoid unnecessarily creating cyclic attribute in hard erasor
If the attribute didn't already exist (none of the initial curves
were cyclic), none of the result curves will be cylic either.
2023-11-22 14:35:53 -05:00
Hans Goudey f3ba4115f2 Cleanup: Slightly generalize attribute gather function
Move implementation to array_utils namespace, use function
to gather all attributes at once.
2023-11-22 14:35:53 -05:00
Falk David 6064e726d4 Fix: GPv3: Stutter while drawing
While drawing, the line beeing drawn would seemingly only update once
in a while. This was because there was a bug in the interpolation
function that would write the value being interpolated from
directly to the destination as the first value.
In our case, we only wanted to write new values (so
we need to exclude the first one).

Making sure the interpolation always excludes the value
interpolated from, fixes the drawing stutter issue.
2023-11-21 12:45:44 +01:00
Hans Goudey 301731692e Cleanup: Access sculpt attributes with C++ attribute API
Access masks and face sets through the `BKE_attribute.hh` API. This
us more flexibility long term, and makes code a bit simpler in the
meantime.
2023-11-20 13:14:34 -05:00
Hans Goudey 9781600d68 Cleanup: Remove sculpt session mask pointer
This was only used in one place. Adding the name lookup to
`SCULPT_vertex_mask_get` is not good long term, but the use
of that function can be removed too.
2023-11-20 13:14:34 -05:00
Hans Goudey f2bcd73bd2 Mesh: Move sculpt mask to a generic attribute
Store paint masks as generic float attributes, with the name
`".sculpt_mask"`. This is similar to 060a534141, which made
the same change for face sets. The benefits are general
consistency, nicer code, and more support in newer areas
that deal with attributes like geometry nodes.

The RNA API is replaced with one created in Python. The new
API only presents a single layer as an attribute class, so it
should be simpler to use in general:
- Before: `object.data.vertex_paint_masks[0].data[0].value`
- After: `object.data.vertex_paint_mask.data[0].value`

Pull Request: https://projects.blender.org/blender/blender/pulls/115119
2023-11-20 17:42:01 +01:00
Hans Goudey b63e31df57 Fix #115170: Sculpt mode crash
If there isn't an evaluated mesh, use the original.
2023-11-20 07:45:52 -05:00
Hans Goudey 41f9f2753a Refactor: Mesh: Include wrapper positions in bounds result
Avoid the need to call the separate `BKE_mesh_wrapper_minmax` function
that dealt with the edit mesh wrapper. This makes the API inconsistent,
since other mesh functions don't implicitly deal with the wrapper.
But the bounds are a bit of a special case anyway in regard
to the GPU subdivision wrapper already, and this is much more
convenient in the rest of the refactors for #96968.
2023-11-19 18:36:19 -05:00
Hans Goudey ee9265710a Cleanup: Use C++ BitVector for sculpt boundary info 2023-11-19 15:13:03 -05:00
Hans Goudey c56912eade Cleanup: Acess geometry bounds more directly
Similar commits:
- 4eeabd274e
- 6301775f48
- ab9716f058
2023-11-17 00:41:37 +01:00
Hans Goudey 4d7274b7f4 Cleanup: Use C++ types for crazyspace deform storage
Use float3, float3x3, and Array for data used for mesh crazyspace
calculation. Propagate the change wherever necessary to not add
more casting to the old C types.

Because `ObjectRuntime` (and therefore `DEGObjectIterData`) became
non-trivial structs, the code that swaps iterators for RNA depsgraph
object iteration had to be changed a bit to be more friendly to C++
memory semantics.

Pull Request: https://projects.blender.org/blender/blender/pulls/114998
2023-11-16 18:29:52 +01:00
Philipp Oeser 7f33a743d8 Fix #114963: Image Editor - Fill Tool doesn't work as expected
Caused by 406cfd214a.

Was only filling a single pixel.

Some pointer magic wasnt working after culprit commit.
Now changed to a more common way of accessing.

Pull Request: https://projects.blender.org/blender/blender/pulls/114989
2023-11-16 17:08:13 +01:00
Hans Goudey 3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Hans Goudey 31c1207c1a Fix #114830: Sculpt line project inverted
Caused by 44b79af4fc
2023-11-16 10:31:58 +01:00
Pratik Borhade 4ee531cf26 Fix #114848: Crash when adding specular texture slot in texture paint mode
This is because the idname for specular node is changed in 1d265eed5d.
Hence `nodeFindSocket` was returning invalid socket.

Pull Request: https://projects.blender.org/blender/blender/pulls/114884
2023-11-16 09:55:53 +01:00
Hans Goudey 4bcdc57fc8 Refactor: Move object runtime data to separate allocation
Move object runtime data to a separate header and allocate it separately
as `blender::bke::ObjectRuntime`. This is how node, mesh, curves, and
point cloud runtime data is stored.

Benefits:
- Allow using C++ types in object runtime data
- Reduce space required for Object struct in files
- Increase conceptual separation between DNA and runtime data
- Remove the need to add manual padding in runtime data
- Include runtime struct definition only in files that require it

Pull Request: https://projects.blender.org/blender/blender/pulls/113957
2023-11-15 18:46:07 +01:00
Hans Goudey 805e6b7525 Cleanup: Use enum class for ModifierTypeType 2023-11-14 10:03:56 +01:00
Hans Goudey 7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Hans Goudey 583bd9662e Cleanup: Remove C header from C++ math header
Remove some redundancy between headers, more fully
separate the C++ headers from the older C headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/114705
2023-11-11 21:09:54 +01:00
Sergey Sharybin 43c2c1844f Cleanup: Remove unused arguments from sculpt automasking API
Pull Request: https://projects.blender.org/blender/blender/pulls/114674
2023-11-09 16:15:54 +01:00
Sergey Sharybin 9125848f2a Cleanup: Remove unused pointer to PBVH node
Pull Request: https://projects.blender.org/blender/blender/pulls/114672
2023-11-09 15:57:35 +01:00
Sergey Sharybin a4f4cb6c4a Cleanup: Sculpt, use C++ types for PBVH proxy node API
- Use float3 for coordinates inside of proxy
- Use Vector for storing coordinates and proxy nodes
- Use MutableSpan in the API to access proxy nodes

Pull Request: https://projects.blender.org/blender/blender/pulls/114638
2023-11-09 11:00:58 +01:00
Sergey Sharybin c3609ec435 Cleanup: Sculpt, use C++ vector types in internal types
Only converted value types in the structures.

The pointer values are left unchanged as it requires more careful look
to avoid possible alignment mismatch.

Function arguments are left unchanged as well.

Only float[3] is converted as the float[4] will likely need to be
converted to some C++ rotation class. And float[4][4] often did not
compile when change is only done in the header.

Pull Request: https://projects.blender.org/blender/blender/pulls/114636
2023-11-09 10:05:24 +01:00
Aras Pranckevicius 13dbeac13c cleanup: remove "sa" acos/asin/sqrt functions and use "safe_" variants
Cleanup talked about in the previous semi-related PR, #114501

- saacos, saasin, sasqrt have been 100% identical to saacosf,
  saasinf, sasqrtf since 2012.
- For all the above, there exist more intuitively named safe_acosf,
  safe_asinf, safe_sqrtf that do the same thing, so switch all code to those.

Pull Request: https://projects.blender.org/blender/blender/pulls/114593
2023-11-07 19:49:01 +01:00
Campbell Barton 611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Campbell Barton aaf05c2497 Cleanup: various C++ changes (use nullptr, function style casts) 2023-11-07 11:35:16 +11:00
Hans Goudey 44b79af4fc Cleanup: Sculpt: Simplify face and face set iteration
This commit removes knowledge about face sets from the PBVH,
and changes iteration over faces to not depend on the PBVH face
iterator abstraction. Though this adds slightly more boilerplate to
iteration over faces, it makes the whole process more data oriented
and allows use of index-based utilities like `gather` and `scatter`
in the mesh case, and simpler iteration over BMesh faces for
dynamic topology.

Setting face sets is now specialized per PBVH type in a few places
in a similar way. The general goal is to reduce branching and function
calls at the lowest level of hot loops, and to make code more aware
of the data structures it uses, both for performance and clarity.

Since the remaining uses of the face iterator are removed,
the iterator itself is removed too.

Related commits:
- 97f2b01ea9
- 756dea7ca1
- a6a2af5fdd

Pull Request: https://projects.blender.org/blender/blender/pulls/114417
2023-11-03 10:27:38 +01:00
Falk David 91db8fc5a0 GPv3: Multi-frame editing
Adds a new scene tool setting `use_grease_pencil_multi_frame_editing`.

The `foreach_*_drawing` functions are moved to the `ed::greasepencil` namespace in the editor, since they are now context sensitive and depend on the toolsetting. They are now named `retrieve_editable_drawings` and `retrieve_visible_drawings` and return
an array of drawings instead of calling a callback function.

Pull Request: https://projects.blender.org/blender/blender/pulls/114283
2023-11-02 17:10:59 +01:00
Hans Goudey d8f59dce26 Merge branch 'blender-v4.0-release' 2023-11-02 16:41:40 +01:00
Hans Goudey db5cae78b7 Fix: Sculpt redo crash after undoing addition of mask
Fixes a crash in the following case:
Enter sculpt mode -> draw face set -> draw sculpt -> undo * 3 -> redo * 3
2023-11-02 16:40:38 +01:00
Hans Goudey 6935cd0798 BLI: Add "scatter" array_utils function
This function, the opposite of `gather`, would have been useful a
few times in the past. For now, just use it once in sculpt undo code.
2023-11-02 16:33:11 +01:00
Hans Goudey fbd49adfc4 Sculpt: Dyntopo: Consider all vertices in face set brush
4e87b3004b made the logic to require all vertices in the face
to be covered by the brush. However, the behavior is closer to the non-
BMesh version if only one of the face's vertices needs to be in "inside".

Pair-reviewed in person with Sergey
2023-11-01 18:33:17 +01:00
Hans Goudey 756dea7ca1 Cleanup: PBVH: Remove redundant storage of face set metadata
These two values are already stored in the mesh, and they have no
relation to the PBVH's goal as an acceleration structure. Similar to
a6a2af5fdd, remove the values from the PBVH and
just access them from the mesh as necessary.

Pair-reviewed in person with Sergey
2023-11-01 18:20:43 +01:00
Sergey Sharybin 4e87b3004b Sculpt: Implement face set brush for dyntopo
The implementation follows the logic of the face set brush for the
faces and grids type of PBVH, with the similar weak part of iterating
over entire mesh at the start of a stroke.

The difference in the behavior is that face needs to be fully covered
by the brush in order to have face set assigned to it (while for the
other types of the PBVH face gets assigned its face set if any of its
vertices are covered). The main reason for this is that this seems to
avoid boundaries being too wiggly.

The auto-masking is not fully integrated into this brush yet. Doing so
is possible, but seems to require deeper re-considerations of the way
how automasking accesses original data and how it is fetched from an
undo node. It worth noting that auto-masking is something that needs
to be looked into for all brushes to make it supported in the dynamic
topology mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/113357
2023-10-31 15:14:31 +01:00
Brecht Van Lommel 39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Campbell Barton ce027579e0 Merge branch 'blender-v4.0-release' 2023-10-27 11:53:46 +11:00
Campbell Barton 585f43064a Fix edit-mode undo leaving edit-mode with multiple windows
With two or more windows, edit-mode undo assumed it was
possible to load the undo state into the current scene.

When multiple windows are used this is not always the case.
Edit-mode undo steps now store the scene used to create them
which is used to read undo data back into this scene
(when it's shown in a window). Otherwise the current context is used.
2023-10-27 11:50:07 +11:00
Falk David 4d453ca1c0 Fix: GPv3: Erasing when object is not at the origin
When the object was transformed, the eraser would no longer work.
This was because the transformation of the positions to screen space
did not take the transforms into account.
This fix adds the transforms to the erasing operation.
2023-10-25 10:24:35 +02:00
Campbell Barton 5d3ce7c679 Merge branch 'blender-v4.0-release' 2023-10-25 15:43:18 +11:00
Hans Goudey 692292536f Fix #113665: Sculpt mode does not unshare color attribute data
When retrieving a color attribute to paint it, the layer data needs to
be unshared so that it doesn't modify data from separate meshes.
In the past I think we've unknowingly avoided this problem by porting
code to the new attribute API. I've been refactoring `PBVH` and
`SculptSession` to make that possible (removing the long-lived
layer pointers in the two structs). But that wouldn't fit as a bug fix.
In the meantime, make sure the color attribute data is un-shared
and separate "for read" and "for write" versions of the function.

Pull Request: https://projects.blender.org/blender/blender/pulls/114119
2023-10-24 20:19:14 +02:00
Sergey Sharybin 92a19747f0 Sculpt: Add timing information for BMesh PBVH
The goal is to make it possible to have more or less reliable way
to perform performance comparisons of changes in algorithms used
in dynamic topology.

This change allows to run Blender with the following arguments:

  blender --log "sculpt.detail,pbvh.bmesh" --log-level 2

and see timing of dynamic topology flood-fill operation, as well as
individual timings of edge subdivision/collapsing.

Pull Request: https://projects.blender.org/blender/blender/pulls/114099
2023-10-24 14:37:54 +02:00
Philipp Oeser 4ce55752ae Merge branch 'blender-v4.0-release' 2023-10-24 13:14:19 +02:00
Philipp Oeser a48d4184b5 Fix #114094: Mask by Color brush has stopped working
Caused by 97f2b01ea9.

Above commit refactored code in a way that it was always early out
(always comparing the current mask value to itself and not the new mask
value).

Pull Request: https://projects.blender.org/blender/blender/pulls/114101
2023-10-24 13:11:27 +02:00
Hans Goudey f2627a55ee Fix #114053: Sculpt visibility broken after undo
Caused by 3e81f66998, The `BLI_BITMAP_TEST` macro
is very flexible and seems to compile with `BitVector` as well.
2023-10-24 12:31:15 +02:00
Falk David ddd4c2ae76 Fix: GPv3: Crash when drawing
This should fix one of the remaining crashes while drawing.
The issue was that we would try to write to an out-of-bounds
memory location.

This fixes the issue and also cleans up the code a bit more,
adding more comments and using better names.
2023-10-23 19:41:49 +02:00
Falk David e1c3a00103 GPv3: Draw strokes relative to the object origin
The drawing plane was at the world origin not the object origin.
This still needs to use the correct drawing plane in the future,
but it's a good step in the right direction.
2023-10-23 19:41:49 +02:00
Falk David 567cc7cf9f Fix: GPv3: Make sure to call `.save()` on attribute writer
In the draw tool in the `process_extension_sample` we would
create an `GSpanAttributeWriter` to initialize the default values for
the new points, but we would return early for curve attributes.
This return needs to happen before we create the `GSpanAttributeWriter`.
2023-10-23 10:44:02 +02:00