Commit Graph

25306 Commits

Author SHA1 Message Date
Hans Goudey
76dc180c3d Cleanup: Remove unused return argument from "ensure mask" function 2023-11-20 13:45:34 -05:00
Hans Goudey
e9db14b3d8 Mesh: Copy small caches when moving mesh data to Main database
For a 16 million vertex mesh, when there are no loose vertices or edges,
copying that information to new original mesh saves 100ms after applying
a modifier on a Ryzen 7950X.
2023-11-20 13:25:29 -05: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
Philipp Oeser
e2fbcb4632 Fix #115167: crash opening files with missing fonts on disk
Check for linked fonts not found on disk.

Pull Request: https://projects.blender.org/blender/blender/pulls/115168
2023-11-20 18:34:32 +01: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
Jeroen Bakker
c9ba4f694b Cleanup: Make format 2023-11-20 14:19:16 +01:00
Philipp Oeser
85ffb71e44 Fix #115105: Edge Crease Doesn't Transfer
Caused by e5ec04d73c

Since above commit, the edge crease is a named attribute and considered
a "fake" customdata layer (similar to bevel weights or UV seams --
`CD_FAKE`). Thus, a special case in
`data_transfer_layersmapping_generate` has to be added for
`CD_FAKE_CREASE`.

Pull Request: https://projects.blender.org/blender/blender/pulls/115180
2023-11-20 13:32:23 +01:00
Jacques Lucke
a976cf4876 Cleanup: reduce boilerplate for equality operators for structs
Pull Request: https://projects.blender.org/blender/blender/pulls/115088
2023-11-20 09:39:13 +01: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
48c6e682e0 Cleanup: Remove unnecessary extern "C" in legacy GP header 2023-11-19 17:32:02 -05:00
Hans Goudey
86cb5307ea Cleanup: Remove unnecessary references to BoundBox
Ongoing refactoring #96968 is working to reduce usage of this struct.
2023-11-19 17:31:20 -05:00
Hans Goudey
8792f73446 Fix: Error in previous crazy space cleanup 2023-11-19 16:48:04 -05:00
Hans Goudey
ee9265710a Cleanup: Use C++ BitVector for sculpt boundary info 2023-11-19 15:13:03 -05:00
Hans Goudey
a0b9865aa6 Cleanup: Simplify crazyspace loop over mesh corners
Use functions to retrieve the next and previous corners
in a face. The complexity of tracking them manually isn't
worth it here. Also standardize naming a bit and use a
C++ BitVector instead of the C equivalent.

Pull Request: https://projects.blender.org/blender/blender/pulls/115146
2023-11-19 18:31:37 +01:00
Lukas Tönne
c845233d1c Nodes: Move ValueOrField struct into blenkernel
This struct is currently defined in the `functions` module but not actually used there. It's only used by the geometry nodes module, with an indirect dependency from blenkernel via simulation zone baking. This scope is problematic when adding grids as socket data, which should not be part of the functions module.

The `ValueOrField` struct is now moved to blenkernel, so it can be more easily extended to other kinds of data that might be passed around by geometry nodes sockets in future. No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115087
2023-11-18 13:11:39 +01:00
Hoshinova
0b11c591ec Nodes: Merge Musgrave node into Noise node
This path merges the Musgrave and Noise Texture nodes into a single
combined Noise Texture node. The reasoning is that both nodes
intrinsically do the same thing, which is the layering of Perlin noise
derivatives to produce fractal noise. So the patch de-duplicates code
and unifies the use of fractal noise for the end use.

Since the Noise node had a Distortion input and a Color output, while
the Musgrave node did not, those are now available to the Musgrave types
as new functionalities.

The Dimension input of the Musgrave node is analogous to the Roughness
input of the Noise node, so both inputs were unified to follow the same
behavior of the Roughness input, which is arguable more intuitive to
control. Similarly, the Detail input was slightly different across both
nodes, since the Noise node evaluated one extra layer of noise. This was
also unified to follow the behavior of the Noise node.

The patch, coincidentally fixes an unreported bug causing repeated
output for certain noise types and another floating precision bug
#112180.

The versioning code implemented with this patch ensures backward
compatibility for both the Musgrave and Noise Texture nodes. When
opening older Blender files in Blender 4.1 the output of both nodes are
guaranteed to always be exactly identical to that of Blender files
created before the nodes were merged in all cases.

Forward compatibility with Blender 4.0 is implemented by #114236.
Forward compatibility with Blender 3.6 LTS is implemented by #115015.

Pull Request: #111187
2023-11-18 09:40:44 +01:00
Iliya Katueshenock
8149678d5e Geometry Nodes: use dynamic declaration for some nodes
This changes a bunch of nodes that have a data type drop-down to using a dynamic
node declaration that changes based on the selected data type instead of always having
all sockets. This greatly simplifies the code and is less weird than having suffixes on
socket identifiers.

Backward compatibility and forward compatibility remain due to #113497 and #113984.

One user-visible change is that changing the data type in these nodes does not break
the link anymore.

It may be necessary to bring back some functionality from link-drag-search afterwards.

Pull Request: https://projects.blender.org/blender/blender/pulls/113553
2023-11-17 16:23:34 +01:00
Antonio Vazquez
00b04e1030 GPv3: Fix Remove Material Slot and Unused Slots
There was two problems because these operators were not supported in GPv3:

* If you remove the slot, the material was not reassigned and the material index attribute could get a wrong index. This also affected the unused slots.
* The Unused Materials operator was executed, but it was doing nothing because there was not support for new GPv3 object.

This PR adds support for new Grease Pencil object.

Pull Request: https://projects.blender.org/blender/blender/pulls/114850
2023-11-17 10:37:56 +01:00
Hans Goudey
865929d4b1 Cleanup: Retrieve sculpt mask without write access
This may reduce memory usage because the mask data wouldn't
have to be duplicated between the evaluated and original mesh.
2023-11-17 10:29:02 +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
Hans Goudey
807c076e28 Cleanup: Remove unused edit mesh cage bounding box cache
Unused after ffaf3e30ef.
These days there are better ways to cache bounds anyway.
2023-11-16 16:28:06 +01:00
Hans Goudey
f27aee857b Cleanup: Remove unnecessary keywords from newly C++ headers 2023-11-16 12:00:26 +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
451c054d9b Fix #114822: Data transfer modifier doesn't work for face corner normals
In 89e3ba4e25, the preprocess step was removed because the
normals are lazily calculated. But now we need to fetch the source normals
from the correct placed-- they still were looked for in `CD_NORMAL`.
2023-11-16 11:41:33 +01:00
Hans Goudey
d46d1bbe6a Fix #114948: Parenting crash blender since ObjectRuntime refactor
Caused by 4bcdc57fc8
2023-11-16 09:16:48 +01:00
Harley Acheson
8e691ad5be Cleanup: Arrow Operator Required
Just two changes from dot operator to arrow operator, required because
of recent refactor.
2023-11-15 10:23:45 -08:00
Hans Goudey
600a133521 Geometry Nodes: Convert four nodes to use rotation socket
Convert the vector socket from four nodes to a rotation socket, adding
versioning to insert the conversion nodes and change the default values
where necessary.
- Distribute Points on Faces
- Instance on Points
- Rotate Instances
- Transform Geometry

Implicit conversions from vectors and floats, and to vectors have been
added, though using rotation sockets directly can be faster, since converting
to and from Euler rotations is slow. Conversion nodes are not inserted
by versioning if the implicit conversions can be used.

This change is not forward compatible with 3.6, and socket values
are lost when opening 4.1 files in 4.0. The correct socket types are
added back in old versions, though newly added conversion nodes
may have to be removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/111482
2023-11-15 18:56:00 +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
9785f2631e Mesh: Add flag to store presence of overlapping topology
For improving performance in the triangulate node (#112264), it's
helpful to know whether the mesh has edges or faces that overlap
each other. If that is known to be false, the node can skip edge de-
duplication.This might apply to the future "Replace Faces" node too.

This information is stored as a flag on the mesh and set in various
places that create "clean" new meshes. It isn't calculated lazily unlike
other other areas, because the point is to improve performance, and
the calculation probably isn't faster than the duplication check it's
meant to replace.

Pull Request: https://projects.blender.org/blender/blender/pulls/113205
2023-11-15 14:02:48 +01:00
Bastien Montagne
b416c3da3c Minor cleanup/precision to some comments regarding ID management. 2023-11-15 11:34:09 +01:00
Hans Goudey
14eb08c3a5 Fix #114870: Object dimensions does not used evaluated geometry
Refactoring of object bounds to make evaluated to original syncing
more explicit wasn't accounted for yet. This was a mistake in the most
recent refactor 1cbd0f5a85.

To fix this, add separate functions to account for `runtime.bb` which
is the data synced from the evalauted object to the original. In future
refactors, `runtime.bb` will be changed more, including a more helpful
name that reflects this purpose.

Pull Request: https://projects.blender.org/blender/blender/pulls/114897
2023-11-15 11:03:04 +01:00
ariva00
d7b7938706 Fix #92287: focal legth not correctly computed when tracking vertial videos
The motion tracking always operates with horizontal sensor mapping, but
conversion code form tracking camera to Blender camera was not setting
the sensor fitting to Horizontal (Python code was leaving sensor fitting
unchanged, C code was setting it to Auto).

Additionally, the Python code was not handling camera shift, making it
so non-centered optical center was not handled correctly.

The reason why the code is written in two places is because C code is
used when conversion from tracking camera to Blender happens after solving
the motion, and the Python code is used for the "Setup Tracking Scene".
It is possible to unify some code, but it is not that much of an importance
at this time.

Pull Request: https://projects.blender.org/blender/blender/pulls/114253
2023-11-15 10:53:30 +01:00
Hans Goudey
8f5ff2c5dd Cleanup: Use C++ types for modifier type deform callbacks 2023-11-14 10:54:57 +01:00
Hans Goudey
805e6b7525 Cleanup: Use enum class for ModifierTypeType 2023-11-14 10:03:56 +01:00
Hans Goudey
f2aab07760 Cleanup: Remove unused CustomData function 2023-11-14 09:57:26 +01:00
Hans Goudey
0c1bb82fc4 Cleanup: Remove unnecessary struct and typedef keywords from C++ headers 2023-11-14 09:51:41 +01:00
Hans Goudey
7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Charles Wardlaw
7e8557e6c6 Fix: Building with WITH_OPENVDB=OFF and WITH_LZMA=ON
This caused NOMINMAX not to be defined when `LzmaLib.h` includes
`windows.h` which causes a definition of min which upsets `std::min`

By moving BLI_winstuff.hh up, it will take care of this define for
us in case it was not yet defined regardless of openvdb being on or
off

Pull Request: https://projects.blender.org/blender/blender/pulls/114816
2023-11-14 00:46:24 +01:00
Hans Goudey
8f362a175d Cleanup: Combine crazyspace C header with C++ header
The distinction would start to become meaningless when we use C++
features in the older C header. The naming and lack of a proper
namespace should be enough to clarify the separation for now.
2023-11-13 19:35:36 +01:00
Brecht Van Lommel
8e82c82074 Revert "Fix #114582: Replace unknown node types with an 'undefined' node"
This breaks versioning because it runs beforehand, giving no time for
versioning to change to the new node type.

This reverts commit 2bf46b3189.

Ref #114803
2023-11-13 18:55:07 +01:00
Iliya Katueshenock
a1a31659ea Mesh: Make edge_other_vert function branchless
This function shouldn't return invalid index. Instead assertion in used.
While the branchless code path may not be observably faster in current
code, it should work better with instruction level parallelism in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/114682
2023-11-13 18:46:04 +01:00
Lukas Tönne
2bf46b3189 Fix #114582: Replace unknown node types with an 'undefined' node
When loading an unknown node type from a newer Blender version, the node
storage data cannot be properly loaded. Re-saving the file will then
crash if saving with the same node type idname, since new Blender
versions cannot find the expected storage data.

Loading in older versions should replace unknown node types with a dummy
"Undefined" node that will get loaded as `NodeTypeUndefined` in newer
versions as well. Custom node types are exempted from this since they
store all data as generic ID properties and can always be fully
serialized.

Pull Request: https://projects.blender.org/blender/blender/pulls/114803
2023-11-13 16:36:42 +01:00
Hans Goudey
00551a3ed2 Fix: Auto smooth versioning node group doesn't show in data-block picker
The group needs to be explicitly marked as a modifier.
2023-11-13 16:15:58 +01:00
Iliya Katueshenock
4f03d502e6 Cleanup: Remove iostreams include from timeit header
Continuation of #110986

Pull Request: https://projects.blender.org/blender/blender/pulls/111010
2023-11-13 10:42:29 +01:00
Hans Goudey
df960e5fc3 Cleanup: Use C++ math functions in mesh normals code
Pull Request: https://projects.blender.org/blender/blender/pulls/114777
2023-11-13 10:32:01 +01:00
Hans Goudey
0d1831cd2e Cleanup: Small cleanups to mesh normals calculation
- Use consistent data fetch order
- Slightly tweak whitespace
- Use C++ vector type and math function
2023-11-11 22:41:21 +01:00
Hans Goudey
5052e0d407 Mesh: Make vertex normal calculation deterministic
Currently, atomic additions in vertex normal calculation introduce
non-determinism that can influence the result of other operations,
sometimes causing non-reproduceable renders (in cases like #100250
and #101726). This is because the order used during threading when
accumulating face normals changes.

This commit fixes that non-determinism, using a vertex to face topology
map to calculate vertex normals without atomics. When the map is already
available, this can be faster too.

In the longer term future, this method of vertex normal calculation
means it will be easier to do partial recalculations when only part
of a mesh changes. That might be essential for cases like transforming
small selections in a non-BMesh edit mode.

As an experiment I tried a "fast" code path that avoids weighting face
normals by the corresponding corner angle when averaging them to
create vertex normals. This significantly reduces the necessary
computation and memory bandwidth for vertex normal calculation.
The results are shown below too, but it's not part of this PR.

I measured the FPS with two smooth shaded 16 million face grids:
|                                  | Before | After | After (fast) |
| -------------------------------- | ------ | ----- | ------------ |
| Created from scratch every frame | 0.96   | 0.91  | 0.92         |
| Deformed by geometry nodes       | 0.99   | 1.32  | 1.40         |

Though many other things besides normals are being tested here,
it's clear that the performance difference isn't that large either way,
though there is an observable regression with meshes created from
scratch, and there is a noticeable improvement when the topology
stays the same and is persistent.

Pull Request: https://projects.blender.org/blender/blender/pulls/111718
2023-11-10 15:19:01 +01:00
Germano Cavalcante
78943edc5d Transform: Custom modifier to navigate while transforming
Discussed in #114646.

This commit transforms the "alt_navigation" option of the transform
operators into a new modal key item. "PASSTHROUGH_NAVIGATE"

In addition to cleaning up a lot of the code, it allows you to
customize the key chosen to navigate while transforming.
2023-11-09 21:33:34 -03:00
Campbell Barton
3841addab3 Cleanup: spelling in comments 2023-11-10 09:24:19 +11:00