Commit Graph

114109 Commits

Author SHA1 Message Date
Campbell Barton 58d86527ae Cleanup: run autopep8 on release/scripts/startup/ 2022-04-19 15:07:04 +10:00
Hans Goudey 8c25889bb6 Refactor: Move mesh face dot tag out of MVert
Continuing the refactors described in T93602, this commit moves
the face dot tag set by the subdivision surface modifier out of
`MVert` to `MeshRuntime`. This clarifies its status as runtime data
and allows further refactoring of mesh positions in the future.

Before, `BKE_modifiers_uses_subsurf_facedots` was used to check
whether subsurf face dots should be drawn, but now we can just check
if the tags exist on the mesh. Modifiers that create new new geometry
or modify topology will already remove the array by clearing mesh
runtime data.

Differential Revision: https://developer.blender.org/D14680
2022-04-18 23:48:43 -05:00
Campbell Barton 775f0d76d5 Fix missing C/Python methods in API docs
The following methods weren't included in API docs.

- BlendDataLibraries.load
- BlendDataLibraries.write
- Text.region_as_string
- Text.region_from_string
2022-04-19 13:08:48 +10:00
Campbell Barton 7e045094c1 PyDoc: quiet warnings for duplicate members bpy.context 2022-04-19 12:19:08 +10:00
Campbell Barton f401741544 PyDoc: remove multiple `children` properties for Bone type
This doesn't cause any functional change as the RNA property
of Bone wasn't overridden by the _GenericBone's property,
however the `children` property was documented twice, causing a warning.
2022-04-19 12:18:53 +10:00
Campbell Barton 76acc5e999 PyDoc: fix including literal text immediately after function args
Literal text from examples could be included directly after function
arguments, this caused a warning with mis-matching indentation.
2022-04-19 12:17:58 +10:00
Aaron Carlisle adcce654e3 Cleanup: Use correct capitalization of "F-Curve" 2022-04-18 20:17:41 -04:00
Colin Basnett 549f68149d UI: Fix typo in UI description for bpy.types.ActionFCurves.remove function
The UI description for the `bpy.types.ActionFCurves.remove` was incorrect;
seemingly a copy-paste typo from the `rna_Action_groups_remove` function.

Reviewed By: sybren, Blendify

Differential Revision: https://developer.blender.org/D14659
2022-04-18 20:11:45 -04:00
Germano Cavalcante b90e892a17 Fix call of 'BLI_assert' instead 'BLI_assert_msg'
Error in 5da02548e9
2022-04-18 19:15:46 -03:00
Germano Cavalcante 5da02548e9 Cleanup: remove redundant 'DEG_get_original_object' call
The `BMEditMesh` pointer is the same in the original or evaluated mesh.

Also a clang-format was missed.
2022-04-18 19:00:55 -03:00
Germano Cavalcante a0c2d6bf85 Transform: small optimization in snap to edit mesh
In some cases, selected elements do not contribute to snapping.
So ignore these elements when creating the edit meshes bound box.
2022-04-18 18:25:16 -03:00
Germano Cavalcante bec057a453 Fix assert on meshes without mloop in snap code
Meshes without loops are still valid for snapping.
2022-04-18 18:24:50 -03:00
Leon Schittek 03d39a04a3 Fix T97002: Preserve multi socket link order
Preserve multi socket link order when copying nodes or adding a new
group input sockets by linking directly to multi inputs from the group
input node's extension socket.

This is done by also copying the `multi_input_socket_index` when
the new links are created by copying existing or temporary links.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D14535
2022-04-18 22:28:03 +02:00
Hans Goudey 314b27850c Cleanup: Remove incorrect comment 2022-04-18 14:08:29 -05:00
Hans Goudey 95cce6f6b0 Cleanup: Move object_modifier.c to C++
This allows using C++ only APIs/data structures, and potentially
simplifies adding support to apply modifiers for the Curves object.
2022-04-18 12:40:23 -05:00
Hans Goudey 98fc998c70 Cleanup: Clang tidy
- Inconsistent parameter names
- Else after return
- Braces around statements
- Qualified auto
- Also (not clang tidy): Pass StringRef by value, unused parameter
2022-04-18 12:36:37 -05:00
Brecht Van Lommel fc58368263 Build: link with GameController and CoreHaptics frameworks on macOS
In preparation of upcoming SDL upgrade, which uses these.
2022-04-18 19:14:36 +02:00
Brecht Van Lommel 2cb76a6c8d Cleanup: consistently use parallel_for without tbb namespace in Cycles 2022-04-18 19:14:36 +02:00
Brecht Van Lommel 029b0df81a Fix Cycles blackbody shader not taking into account OpenColorIO config
Keep the existing Rec.709 fit and convert to other colorspace if needed, it
seems accurate enough in practice, and keeps the same performance for the
default case.
2022-04-18 19:14:34 +02:00
Brecht Van Lommel 41b3feea85 Fix Cycles build error with latest TBB after recent changes
From changes in 869a46df29, ref D14454
2022-04-18 18:49:35 +02:00
Angus Stanton ccd2e89d37 Fix T94559: Copying geometry node group does not copy animation data
Reimplement copy geometry node groups in C. The version implemented in
Python could also manually copy the animation data, but it's more
standard to do this with `BKE_id_copy_ex` and `LIB_ID_COPY_ACTIONS`.

Differential Revision: https://developer.blender.org/D14615
2022-04-18 10:15:30 -05:00
Hans Goudey ef2b8c1c3a Nodes: Remove unnecessary RNA pointer creation
`rna_NodeSocket_refine` and `rna_Node_refine` take significant time
when building the `NodeTreeRef` acceleration data structure, but they
aren't used at all. This commit removes their eager calculation and
instead creates them on-demand in the `rna()` functions. They also
aren't inlined to avoid including `RNA_prototypes.h` in the header.

Differential Revision: https://developer.blender.org/D14674
2022-04-18 10:12:17 -05:00
Bastien Montagne 933fed2a17 Minor tweaks to labels/tooltips of override operation in the Outliner. 2022-04-18 12:21:33 +02:00
Nicholas Rishel bf80dc2bd4 Add debugging info for Wintab activated by argument `--debug-wintab`.
Bonus: Added docs for `--debug-ghost`.

Differential Revision: https://developer.blender.org/D14610
2022-04-17 15:21:59 -07:00
Aras Pranckevicius 213cd39b6d OBJ: further optimize, cleanup and harden the new C++ importer
Continued improvements to the new C++ based OBJ importer.

Performance: about 2x faster.
- Rungholt.obj (several meshes, 263MB file): Windows 12.7s -> 5.9s, Mac 7.7s -> 3.1s.
- Blender 3.0 splash (24k meshes, 2.4GB file): Windows 97.3s -> 53.6s, Mac 137.3s -> 80.0s.
- "Windows" is VS2022, AMD Ryzen 5950X (32 threads), "Mac" is Xcode/clang 13, M1Max (10 threads).
- Slightly reduced memory usage during import as well.

The performance gains are a combination of several things:
- Replacing `std::stof` / `std::stoi` with C++17 `from_chars`.
- Stop reading input file char-by-char using `std::getline`, and instead read in 64kb chunks, and parse from there (taking care of possibly handling lines split mid-way due to chunk boundaries).
- Removing abstractions for splitting a line by some char,
- Avoid tiny memory allocations: instead of storing a vector of polygon corners in each face, store all the corners in one big array, and per-face only store indices "where do corners start, and how many". Likewise, don't store full string names of material/group names for each face; only store indices into overall material/group names arrays.
- Stop always doing mesh validation, which is slow. Do it just like the Alembic importer does: only do validation if found some invalid faces during import, or if requested by the user via an import setting checkbox (which defaults to off).
- Stop doing "collection sync" for each object being added; instead do the collection sync right after creating all the objects.

Cleanup / Robustness:

This reworking of parser (see "removing abstractions" point above) means that all the functions that were in `parser_string_utils` file are gone, and replaced with different set of functions. However they are not OBJ specific, so as pointed out during review of the previous differential, they are now in `source/blender/io/common` library.

Added gtest coverage for said functions as well; something that was only indirectly covered by obj tests previously.

Rework of some bits of parsing made the parser actually better able to deal with invalid syntax. E.g. previously, if a face corner were a `/123` string, it would have incorrectly treated that as a vertex index (since it would get "hey that's one number" after splitting a string by a slash), instead of properly marking it as invalid syntax.

Added gtest coverage for .mtl parsing; something that was not covered by any tests at all previously.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D14586
2022-04-17 22:07:43 +03:00
Aras Pranckevicius a3eb4027c2 Fix T97095: export of Poly curves, export crash when object contains multiple curve types
- Was not exporting "Poly" curves at all,
- Had a crash when a single object contains multiple curves of different types -- it had a check for "is this nurbs compatible?" only for the first curve, and then proceeded to treat the other curves as nurbs as well, without checking for validity.

Fixed both issues by doing the same logic as in the old python exporter:
- Poly curves are supported,
- Treat object as "nurbs compatible" only if all the curves within it are nurbs compatible.

Added test coverage in the gtest suite. While at it, made "all_curves" test use the "golden obj file template" style test, instead of a manually coded test that checks intermediate objects but does not check the final exported result.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D14611
2022-04-17 21:59:55 +03:00
Aras Pranckevicius b32cb0266c Fix T96824: New 3.1 OBJ exporter writes incorrect polygon/vertex groups in some cases
The new 3.1 OBJ exporter code had incorrect code to determine which vertex group a polygon belongs to -- for each vertex, it was only looking at the first vertex group it has, and not using the group weight either.

This 99% fixes T96824, but not 100% on the user's submitted mesh -- exactly two faces from that mesh get assigned a different group compared to the old exporter. Either choice is "correct" given that on these two faces there are two vertex groups with equal contribution. The old Python exporter was picking the group based on internal python group name map order, whereas the new C++ exporter is picking the group with the lowest index, in case of ties. I'm not sure if it's possible to fix this TBH, will have to wait until the importer is also C++.

While at it, the new vertex group calculation code was doing a lot of redundant work for each and every face (traversing group lists several times, allocating & freeing memory), so I fixed that. Exporting a 6-level subdivided Monkey mesh with 30 vertex groups was taking 810ms, now takes 330ms.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D14500
2022-04-17 21:54:51 +03:00
Hans Goudey e88807e71c Cleanup: Use C++ Array type 2022-04-17 13:30:30 -05:00
Michael Kowalski b9f1b64801 USD/Ctest: Add basic USD-Imaging test.
This adds a basic unit test to check USD has been correctly
build with imaging components to support building both with
the old and new libs, it automatically adds the test when it
detects a library with imaging enabled. (platform devs will
have to pay attention it runs the test to validate the libs
build correctly)

For future use in the code it also defines a USD_HAS_IMAGING
define one could check if we're building against an USD lib
that has it (just because we build/ship with it, doesn't
mean downstream builds will ship with it, so we'll have
to be a little pro-active there)

Reviewed By: sybren

Differential Revision:https://developer.blender.org/D14456
2022-04-16 15:32:48 -06:00
Jesse Yurkovich 98eb111568 Fix T97366: Misdetection of numbers as UDIMs in certain filepaths
In some circumstances singular files with numbers in their name (like
turntable-1080p.png or frame-1042.png) might be detected as a UDIM.

The root cause in this particular instance was because `BKE_image_get_tile_info`
believed this file to be a tiled texture and replaced the filename with
a tokenized version of it. However, later on, the code inside `image_open_single`
did not believe it was tiled because only 1 file was detected and our
tiled textures require at least 2. This discrepancy lead to the broken
filename situation.

This was a regression since rB180b66ae8a1f as that introduced the
tokenization changes.

Differential Revision: https://developer.blender.org/D14667
2022-04-16 14:18:08 -07:00
Joseph Eagar 2b191cd2b4 Mask by color now auto-creates a
color attribute if one does not exist,
and no longer passes through to the
translate tool on tweak grab.
2022-04-15 18:49:38 -07:00
Joseph Eagar 8eb40d2063 This patch changes Sculpt Multi-Plane Scrape tool icon to be red and have a little outline around the color, like the other scraping tools T97271
Also, as a suggestion, this patch changes Mask By Color and Color Filter to be the same shade of green as paint and smear tool icons

{F12998856}

{F12998857}

{F12998858}

Reviewed By: Julian Kaspar & Joseph Eagar
Differential Revision: https://developer.blender.org/D14632
Ref D14632
2022-04-15 18:06:47 -07:00
Hans Goudey dc5ae10692 Fix T96988: Merge by distance node crash with certain input
If the `wpoly` vector was small, the `wpoly_new` pointer could point
to part of its inline buffer on the stack, which becomes invalid out of
that scope. Instead, store `wpoly_new` as a span, and assign it properly
from the moved vector.
2022-04-15 16:55:15 -05:00
Hans Goudey cb3c233ed3 Cleanup: Return early 2022-04-15 16:44:15 -05:00
Hans Goudey 65194f47b0 UI: Improve wording for some USD export descriptions
The HIG mentions that redundant words like "Enables" or "Activates"
shouldn't be used for tooltips of boolean properties. In this case
"When checked" was the redundant language that was implied by
the checkbox itself-- convention is to just state what the property
does when it's on.

Also change a few conjugations to the imperative and simplify
wording slightly, in order to be more consistent with language
elsewhere in Blender, and to be a bit more direct.

Differential Revision: https://developer.blender.org/D14644
2022-04-15 13:50:54 -05:00
Wayde Moss ad324316ce Fix: Missing Null Check
Introduced by my recent commit: {rB3acbe2d1e933}

Lead to crash when insert_keyframe_direct() was called. Keyframing
crashed for NLA special properties (influence, animated_time),
driven properties, etc.
2022-04-15 13:45:00 -04:00
Hans Goudey 089e701191 Fix T97363: Duplicate elements node doesn't tag loose edges 2022-04-15 12:38:34 -05:00
Wayde Moss 4e6c0669e3 Cleanup: fix warning for differing parameter names 2022-04-15 13:21:07 -04:00
Hans Goudey 0f9057390d Cleanup: Clang tidy 2022-04-15 11:59:02 -05:00
Hans Goudey 7484f274dc Curves: Port curve to mesh node to the new data-block
This commit changes the Curve to Mesh node to work with `Curves`
instead of `CurveEval`. The change ends up basically completely
rewriting the node, since the different attribute storage means that
the decisions made previously don't make much sense anymore.

The main loops are now "for each attribute: for each curve combination"
rather than the other way around, with the goal of taking advantage
of the locality of curve attributes. This improvement is quite
noticeable with many small curves; I measured a 4-5x improvement
(around 4-5s to <1s) when converting millions of curves to tens of
millions of faces. I didn't obverse any change in performance compared
to 3.1 with fewer curves though.

The changes also solve an algorithmic flaw where any interpolated
attributes would be evaluated for every curve combination instead
of just once per curve. This can be a large improvement when there
are many profile curves.

The code relies heavily on a function `foreach_curve_combination`
which calculates some basic information about each combination and
calls a templated function. I made assumptions about unnecessary reads
being removed by compiler optimizations. For further performance
improvements in the future that might be an area to investigate.
Another might be using a "for a group of curves: for each attribute:
for each curve" pattern to increase the locality of memory access.

Differential Revision: https://developer.blender.org/D14642
2022-04-15 10:15:48 -05:00
Clément Foucault cc6db8921b GPU: Make viewport not acquireable during rendering
This is a partial fix to the fact that rendering with EEVEE or other GL
render engines is currently blocking the whole UI when asking to redraw
a viewport.

This patch just bypasses the viewport bind (containing the Draw Context
lock) and the following drawing. There is an update tagging to not
loose a viewport update if there was one asked.

Other queries other than view redraw (such as selection depth drawing or
offscreen drawing) will still block the whole UI as they need immediate
data feedback.

Ping @Severin for the change in `WM_draw_region_viewport_bind()`.
I'm assuming this is not an issue because it's highly unlikely to
bring up this operator during rendering. But in this case, it would just
lock as usual.

The bypassing in `DRW_notify_view_update` might be a bit overparanoid.
2022-04-15 17:09:30 +02:00
Hans Goudey 47d961a4b1 Fix: Apply tilt in curves data-block normals calculation
The ported normal calculation from ceed37fc5c neglected to
use the tilt attribute to rotate the normals around the tangents.
This commit adds that behavior back, adding a new math header file
to avoid duplicating the rotation function for normalized axes.

Differential Revision: https://developer.blender.org/D14655
2022-04-15 09:54:45 -05:00
Jeroen Bakker e96a809a68 PBVH Pixel extractor.
This patch contains an initial pixel extractor for PBVH and an initial paint brush implementation.
PBVH is an accelleration structure blender uses internally to speed up 3d painting operations.
At this moment it is extensively used by sculpt, vertex painting and weight painting.

For the 3d texturing brush we will be using the PBVH for texture painting.
Currently PBVH is organized to work on geometry (vertices, polygons and triangles).
For texture painting this should be extended it to use pixels.

{F12995467}

Screen recording has been done on a Mac Mini with a 6 core 3.3 GHZ Intel processor.

# Scope

This patch only contains an extending uv seams to fix uv seams. This is not actually we want, but was easy to add
to make the brush usable.

Pixels are places in the PBVH_Leaf nodes. We want to introduce a special node for pixels, but that will be done
in a separate patch to keep the code review small. This reduces the painting performance when using
low and medium poly assets.

In workbench textures aren't forced to be shown. For now use Material/Rendered view.

# Rasterization process

The rasterization process will generate the pixel information for a leaf node. In the future those
leaf nodes will be split up into multiple leaf nodes to increase the performance when there
isn't enough geometry. For this patch this was left out of scope.

In order to do so every polygon should be uniquely assigned to a leaf node.

For each leaf node
   for each polygon
     If polygon not assigned
       assign polygon to node.

Polygons are to complicated to be used directly we have to split the polygons into triangles.

For each leaf node
  for each polygon
    extract triangles from polygon.

The list of triangles can be stored inside the leaf node. The list of polygons aren't needed anymore.
Each triangle has:

    poly_index.
    vert_indices
    delta barycentric coordinate between x steps.

Each triangle is rasterized in rows. Sequential pixels (in uv space) are stored in a single structure.

    image position
    barycentric coordinate of the first pixel
    number of pixels
    triangle index inside the leaf node.

During the performed experiments we used a fairly simple rasterization process by
finding the UV bounds of an triangle and calculate the barycentric coordinates per
pixel inside the bounds. Even for complex models and huge images this process is
normally finished within 0.5 second. It could be that we want to change this algorithm
to reduce hickups when nodes are initialized during a stroke.

Reviewed By: brecht

Maniphest Tasks: T96710

Differential Revision: https://developer.blender.org/D14504
2022-04-15 16:40:01 +02:00
Clément Foucault 25196f8a36 EEVEE: Support disabling all lightprobe object contribution in viewport
This is supported throught the visibility toggle. The light cache will
then only be used for world lighting. This is the behavior as light
objects.
2022-04-15 14:05:18 +02:00
Jacques Lucke 2839fe9a4d Curves: initial geometry nodes support for curves objects
* Curves objects now support the geometry nodes modifier.
* It's possible to use the curves object with the Object Info node.
* The spreadsheet shows the curve data.

The main thing holding this back currently is that the drawing code
for the curves object is very incomplete. E.g. it resamples the curves
always in the end, which is not expected for curves in general.

Differential Revision: https://developer.blender.org/D14277
2022-04-15 09:08:50 +02:00
Wayde Moss db6287873c Object: Set Parent (Keep Transform Without Inverse)
**Relevant to Artists:** This patch adds an option to the Parenting
menu, `Object (Keep Transform Without Inverse)`, and Apply menu, `Parent
Inverse`. The operators preserve the child's world transform without
using the parent inverse matrix. Effectively, we set the child's origin
to the parent. When the child has an identity local transform, then the
child is world-space aligned with its parent (scale excluded).

**Technical:** In both cases, the hidden parent inverse matrix is
generally set to identity (cleared or "not used") as long as the parent
has no shear. If the parent has shear, then this matrix will not be
entirely cleared. It will contain shear to counter the parent's shear.
This is required, otherwise the object's local matrix cannot be properly
decomposed into location, rotation and scale, and thus cannot preserve
the world transform.

If the child's world transform has shear, then its world transform is
not preserved. This is currently not supported for consistency in the
handling of shear during the other parenting ops: Parent (Keep
Transform), Clear [Parent] and Keep Transform. If it should work, then
another patch should add the support for all of them.

Reviewed By: sybren, RiggingDojo
Differential Revision: https://developer.blender.org/D14581
2022-04-14 20:25:06 -04:00
Antonio Vazquez 48ff456a4b Fix T96875: Envelope modifier strokes cannot be eselected with Tweak
The new created strokes were not setting the right `orig` pointers, so the select operator could not select the strokes and points.

Now, the original pointers are set in the new strokes. To set the values is necessary assign the original pointer from the reference stroke because in modifiers the stroke is evaluated, so we need back two levels: Eval->Eval->Orig
2022-04-14 21:51:38 +02:00
Germano Cavalcante 48d2f536e1 Fix crash when loading Blender due to recent change
Issue introduced in {rB80859a6cb272}

Only seen on Windows.

The `keyword_parse` lambda function code did not consider `\r` as a
whitespace char, resulting in a wrong parse.

(More investigation needs to be done).
2022-04-14 15:54:09 -03:00
Hans Goudey 05715eaea1 Fix: Use after free when removing attribute on instances
Assume that only one layer matches the id and return instead
of continuing to iterate over attributes after the layers have
been potentially reallocated.
2022-04-14 13:04:23 -05:00
Clément Foucault 80859a6cb2 GPU: Make nodetree GLSL Codegen render engine agnostic
This commit removes all EEVEE specific code from the `gpu_shader_material*.glsl`
files. It defines a clear interface to evaluate the closure nodes leaving
more flexibility to the render engine.

Some of the long standing workaround are fixed:
- bump mapping support is no longer duplicating a lot of node and is instead
  compiled into a function call.
- bump rewiring to Normal socket is no longer needed as we now use a global
  `g_data.N` for that.


Closure sampling with upstread weight eval is now supported if the engine needs
it.

This also makes all the material GLSL sources use `GPUSource` for better
debugging experience. The `GPUFunction` parsing now happens in `GPUSource`
creation.

The whole `GPUCodegen` now uses the `ShaderCreateInfo` and is object type
agnostic. Is has also been rewritten in C++.

This patch changes a view behavior for EEVEE:
- Mix shader node factor imput is now clamped.
- Tangent Vector displacement behavior is now matching cycles.
- The chosen BSDF used for SSR might change.
- Hair shading may have very small changes on very large hairs when using hair
  polygon stripes.
- ShaderToRGB node will remove any SSR and SSS form a shader.
- SSS radius input now is no longer a scaling factor but defines an average
  radius. The SSS kernel "shape" (radii) are still defined by the socket default
  values.

Appart from the listed changes no other regressions are expected.
2022-04-14 18:47:58 +02:00