Commit Graph

3370 Commits

Author SHA1 Message Date
Campbell Barton
3241db35cd Docs: correct code comment for LaplacianSystem::tris
Also use doxygen doc-strings as they more easily allow comments to be
expanded on.
2023-12-14 12:51:21 +11:00
Campbell Barton
944e0483a6 Cleanup: clarify naming for MLoopTri
The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
2023-12-14 12:32:11 +11:00
Hans Goudey
e657aa2360 Cleanup: Move two mesh functions to C++ header 2023-12-13 09:50:47 -05:00
Hans Goudey
b52a071e7a Cleanup: Remove unnecessary Mesh C-API functions
Like mentioned in the docstrings, use the C++ API or access methods
in C++ code.
2023-12-13 08:40:21 -05:00
Hans Goudey
c53e220aef Cleanup: Use C++ attribute API instead of CustomData API
This gives better asserts in debug builds through use of Span, more
safety when name convention attributes happen to have different types
or domains, and simpler code in some cases. But the main reasoning is to
avoid relying on the specifics of CustomData more to allow us to replace
it in the future.
2023-12-12 18:23:59 -05:00
Hans Goudey
1d0179adbb Cleanup: Move mesh update tags to DNA struct
This is similar to other update tags and update tags for other geometry types.
2023-12-12 18:23:59 -05:00
Douglas Paul
75f160ee96 Geometry Nodes: Add Active Camera input node
This adds a new "Active Camera" input geometry node, per #105761.

The node outputs the the scene's current active camera. It is available
from Input > Scene > Active Camera in the geometry nodes Add menu.

Typical usage would be to connect this node to an Object Info node to
obtain its transform. This works as expected when the camera's
transform is animated, and also when there are markers on the timeline
that change the active camera.

In order to support the aforementioned changes in the active camera,
this implementation adds depsgraph relations for all cameras referenced
by timeline markers. This eliminates the complexity of updating the
depsgraph whenever the scene switches to a different active camera,
but of course it comes at the cost of including more objects than
strictly necessary in the depsgraph for scenes that switch cameras.
Dynamically updating the depsgraph upon camera changes could be a
future improvement if there proves to be sufficient need for it.

Pull Request: https://projects.blender.org/blender/blender/pulls/113431
2023-12-12 19:11:06 +01:00
Hans Goudey
d8497e48e1 Cleanup: Use is_empty() instead of size() == 0 2023-12-11 15:47:11 -05:00
Campbell Barton
ded36920d7 Cleanup: spelling in comments 2023-12-10 16:33:54 +11:00
Hans Goudey
854cdd1180 Cleanup: Use consistent "mesh" variable name (replace "me")
"mesh" reads much better than "me" since "me" is a different word.
There's no reason to avoid using two more characters here. Replacing
all of these at once is better than encountering it repeatedly and
doing the same change bit by bit.
2023-12-08 16:40:06 -05:00
Jeroen Bakker
65e58fe574 CMake: Fix Compiling Shader Builder on macOS
Due to changes in the build environment shader_builder wasn't able to
compile on macOs. This patch reverts several recent changes to CMake files.

* dbb2844ed9
* 94817f64b9
* 1b6cd937ff

The idea is that in the near future shader_builder will run on the buildbot as
part of any regular build to ensure that changes to the CMake doesn't break
shader_builder and we only detect it after a few days.

Pull Request: https://projects.blender.org/blender/blender/pulls/115929
2023-12-08 15:47:14 +01:00
Hans Goudey
7a96c4672c Cleanup: Move BMesh headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/115817
2023-12-05 23:01:12 +01:00
Hans Goudey
fe3b8b6e9b Cleanup: Remove remnants of old color layer preview system
For context, see 6d09fa3577. Overall, these values were still
written in some cases, but never used. Nowadays the viewer node and
attribute overlays give even better answers to these needs.
2023-12-05 09:36:13 -05:00
Hans Goudey
5cd6a05f5e Cleanup: Store SubdivCCG in unique_ptr
Automatic memory management and clearer ownership! Requires
removing `MEM_CXX_CLASS_ALLOC_FUNCS` from `MeshRuntime`,
but that's used very inconsistently anyway, and `MeshRuntime` isn't
that large.
2023-12-04 07:55:47 -05:00
Bastien Montagne
3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +01:00
Jacques Lucke
5de86fc4f8 Cleanup: make name more specific for simulations
This is necessary for the bake node (#115466).
2023-12-01 17:13:31 +01:00
Philipp Oeser
6023a6a423 Fix #115526: missing normals on first chunk of array modifier
Exposed by 383a145a19.

Think the issue actually started in cfa53e0fbe, since then the new
destination normals were only filled from the first array copy onwards
(probably hidden by some recalculation of normals somewhere?).

In any case, starting the destination normals array with what we have
from the input mesh normals and then resizing the array (instead of
reinitializing it from scratch) fixes this.

Pull Request: https://projects.blender.org/blender/blender/pulls/115612
2023-11-30 15:49:52 +01:00
Hans Goudey
1a36feb7e5 Cleanup: Use references instead of pointers in subdiv_ccg.cc 2023-11-29 11:40:10 -05:00
Jacques Lucke
7a7b7196f9 Geometry Nodes: extract global data passed to a geometry nodes invocation to separate struct
This avoids some duplication between the modifier and operator evaluation
contexts and also makes it easier to make independent from a specific
evaluation context (so e.g. the simulation nodes code shouldn't care whether
it's used from a modifier or operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/115512
2023-11-29 13:22:20 +01:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Hans Goudey
f2467f75b3 Cleanup: Remove mesh "vert coords" functions
Inlining the functions is simpler nowadays, since there are utility
functions to copy spans and tag the mesh caches dirty. Also use an
array instead of a raw pointer for multires.
Resolves #103789
2023-11-28 12:26:51 -05:00
Ray molenkamp
dbb2844ed9 Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions 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/115427
2023-11-28 01:14:15 +01:00
Ray Molenkamp
6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph 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/115422
2023-11-25 22:51:59 +01:00
Ray Molenkamp
ae25298774 Cleanup: CMake: Modernize bf_blenfont dependencies
Pretty straightforward

- Remove any bf_blenfont 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/115365
2023-11-24 18:29:09 +01:00
laurynas
0ff1a8825e Fix: bevel weights in Simple mode of Solidify
In Simple Solidify's mode  edge weights created by "Bevel Convex"
disappear, if edge weight is added to original mesh. From technical
side problem is identical to the one in #114860.

If original mesh doesn't have layer "bevel_weight_edge" option "Bevel
Convex" works fine. All bevels disappear after one edge gets bevel
weight. Except ones corresponding newly added weight. In patched
version weights created by "Convex Bevel" stay. Also manually added
weight can be observed on the edge of inner cube.

Second problem is when am original plane has one vertex with bevel
weight 1.0, but no bevel in result. If to change Solidify's mode from
"Simple" to "Complex" bevel appears. Patch adds this behavior to the
"Simple" mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/115258
2023-11-22 13:42:01 +01:00
Jacques Lucke
96b3afe065 Cleanup: rename node group to group node context
`GroupNodeComputeContext` is the more correct name because it's
specifically about a group node that invokes another node tree.
The old name makes it sound like it should be used because a node group
is invoked but does not tell anything about what invoked it.
For example, the current context in a node group can also be a
`ModifierComputeContext` if that's what invoked it.
2023-11-21 14:12:23 +01:00
laurynas
6ccb30246d Fix #114860: Edge bevel weights in complex solidify
"Solidify" modifier in "Complex" mode was creating redundant layer
"bevel_weight_edge.001", if mesh has bevel weights for vertex set.
All modifier's  custom edge bevel weight calculations went there and got lost.

Pull Request: https://projects.blender.org/blender/blender/pulls/115178
2023-11-20 14:44:15 +01:00
Hans Goudey
62b4555d01 Cleanup: Return Bounds type directly in mesh to volume code 2023-11-19 16:57:13 -05: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
Jacques Lucke
e62179ce04 Fix: assert when running deform modifier tests in debug build
The issue was that `dco` had a different size than was expected
because it was intentionally larger than strictly necessary.
2023-11-17 13:10:51 +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
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
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
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
7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +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
Aras Pranckevicius
b1c7b573c0 mesh: use faster acos() variant in normals calculation
Function                         Module   Inclusive Time  Exclusive Time
--------------------------------------------------------------------------
  mesh_render_data_update_normals  blender  297.51          0.00

  315 -> 297

acos() usage in all places related to normal calculations shows up in the
profiler. Given that "angle between faces" is only additional heuristic
weight in there (the effect of it at all is very subtle), approximate but
faster version of acos() might be just fine. Especially since some other
parts of Blender (e.g. mikktspace) use approximate acos in a conceptually
the same part.

- Adds safe_acos_approx() to BLI_math_base.hh. Implementation the same
  as already exists in Cycles; max error 0.00258 degrees. Between 2x and 4x
  faster in my tests.
- Changes all normals related calculations to use the function above instead
  of saacos.

Computing normals on a Stanford Lucy (14m verts) mesh:
- Mac (arm64, M1 Max): 247ms -> 229ms
- Win (x64, Ryzen 5950X): 276ms -> 250ms

All places that are about "normal calculation" were changed, including e.g.
Corrective Smooth modifier. Applying that one to the same 14m vertices mesh,
Mac M1 Max: 9.96s -> 9.76s

Tiny changes in several test output expectations w.r.t. normals are
observed, these were reviewed and updated expectations checked in svn.

Pull Request: https://projects.blender.org/blender/blender/pulls/114501
2023-11-07 18:22:17 +01:00
Damien Picard
f48f901b3b I18n: translate socket properties in the Modifier Properties editor
Each node group asset exposes various properties through sockets.
Although they can generally be considered user-created data, for
built-in assets they are also part of the UI and should be
translated--especially since more modifiers should be migrated to
Geometry Nodes in the future.

This commit enables the translation of those properties in the
Modifier Properties editor.

Pull Request: https://projects.blender.org/blender/blender/pulls/114256
2023-11-07 18:08:35 +01:00
Jeroen Bakker
b56382b38a Cleanup: Make format 2023-11-07 08:04:17 +01:00
Campbell Barton
611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Aras Pranckevicius
6e4adbe694 Cleanup: use_holes arg to isect_point_poly_v2 has been ignored since 2013
07851dd8df made the use_holes argument be no longer used.
2023-11-06 20:51:21 +02:00
Sergey Sharybin
783eb3f390 Merge branch 'blender-v4.0-release' 2023-11-03 09:28:36 +01:00
Sergey Sharybin
e24c7f1954 Fix #114129: Crashes on boolean operation macOS Intel
The issue crash was caused by non-safe cast from a bare C array
float[4][4] to float4x4*. Such cast is not safe because it might
break alignment.

Modified the code so that the transform matrices are passed by
value.

Technically it could mean higher memory usage, but odds that the
actual geometry which is a part of boolean operation consumes much
more memory. Additionally, avoiding indirection could potentially
lead to better performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/114421
2023-11-03 09:27:59 +01:00
Sergey Sharybin
317ee3b6ea Merge branch 'blender-v4.0-release' 2023-10-31 17:29:41 +01:00
Hans Goudey
2893dc8ab7 Fix: Broken node tool group data-block references
Currently the node tool node group and data-blocks referenced by it
may not be part of the active dependency graph. This means we
cannot retrieve their evaluated geometry when executing the operator.
Since operators almost always use the evaluated geometry of other
objects, and since geometry nodes is mostly set up to deal with
evaluated data-blocks currently, this must be fixed.

Instead, set up a temporary dependency graph and add the selected
objects and the data-blocks used by the node group. That graph is
evaluated to give simple access to evaluated data-blocks.

Unfortunately this will cause more work than necessary in a few ways:
1. Selected objects are reevaluated an extra time before execution.
2. All data-blocks referenced by the group are completely evaluated again.
3. The node group itself is reevaluated, which recreates the function graph.

These may or may not become bottlenecks in the future, but it's best to
keep it simple late in the release process. And between a completely
broken feature and a potentially slow feature, the choice is clear!

Pull Request: https://projects.blender.org/blender/blender/pulls/114293
2023-10-31 17:16:48 +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
7cdd73b247 Merge branch 'blender-v4.0-release' 2023-10-25 15:43:10 +11:00
Hans Goudey
74af0528f4 Fix #113752: Explode modifier edge cut option broken
`EdgeHash` was replaced by `VectorSet`, but the changes in the data
structure hid some other changes, causing incorrect indices to be used.
Instead use `Map` and explicitly build the indices similar to how they
were counted in a separate loop before.

Caused by: 425b871607
2023-10-24 18:44:24 +02:00
Dalai Felinto
6b7d0fe425 GPv3: Layer Selection modifier input
Known limitations to be addressed separately:

* We are not warning/keeping track of the named layers.
* There is no lookup for layers (groups) yet.

Ref !113908.
2023-10-23 15:49:34 +02:00