Commit Graph

89185 Commits

Author SHA1 Message Date
Hans Goudey d9d4b9899e Cleanup: Remove includes in node_util.h header
This ends up including the removed headers in many unnecessary places.
Also, remove unnecessary extern from function definitions.
2021-12-12 22:56:51 -06:00
Campbell Barton f5679838bc Docs: document all Global (G) struct members 2021-12-13 14:05:31 +11:00
Campbell Barton bc1e517bb3 Docs: improve on doc-strings for BPY_extern_run.h
Also add ATTR_NONNULL function attributes.
2021-12-13 13:12:09 +11:00
Hans Goudey 03015a9b22 Cleanup/docs: Add comment to spline lookup factor method 2021-12-12 18:03:30 -06:00
Jacques Lucke 92237f11eb Geometry Nodes: improve memory reuse in procedure executor
This reduces the number of separate memory allocations done
by the multi-function procedure executor (which is used by the
field evaluation).

Now a linear memory allocator is used to allocate all intermediate
values. Furthermore, more buffers are reused when possible. This
reduces the total amount of allocated memory and improves
cache efficiency because the values are more likely to be in cache
already.

The performance improvement of this patch are most noticable
when few elements are processed by many functions. The situation
will improve even more with D13548, because then buffers can actually
be reused in practice. I measured up to 20% faster field evaluation
in extreme cases with this change.
2021-12-12 10:34:02 +01:00
Jacques Lucke b444e1be0f Cleanup: use struct instead of class
Using `class` and `struct` for the same type can cause issues on windows.
2021-12-12 08:58:55 +01:00
Charlie Jolly 8c55481e33 UI: Add curve handle buttons to CurveMap interface
This patch exposes the vector handle options as buttons
and aligns the UI between CurveMap and CurveProfile more closely.
- CurveMap point editing is on a single row like CurveProfile
- Tools menu is moved to the right hand side on both widgets
- Emboss curve map buttons

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D10980
2021-12-12 07:17:35 +00:00
Ankit Meel 9df13fba69 macOS: add tilde-based path expander
Replaces `HOME` environment variable usage for user
directories like in D12802.

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D13212
2021-12-11 22:29:53 +05:30
Hans Goudey 23be5fd449 Cleanup: Use const arguments
Also remove unnecessary function to set a node type's
label function that duplicated its definition, and make
another function static.
2021-12-11 09:51:53 -06:00
Jacques Lucke 7b88a4a3ba Geometry Nodes: remove accidental exponential time algorithm
Calling `foreach_field_input` on a highly nested field (we do that
often) has an exponential running time in the number of nodes.
That is because the same node may be visited many times.
This made Blender freeze on some setups that should work just fine.
Now every field keeps track of its inputs all the time. That replaces
the exponential algorithm with constant time access.
2021-12-11 11:26:55 +01:00
Jeroen Bakker 4c705ab8fe Fix compilation error on Windows platform. 2021-12-11 09:48:43 +01:00
Hans Goudey 1a02c0d7dd Cleanup: Return early for null check 2021-12-10 16:42:34 -06:00
Hans Goudey a8b730e04c Cleanup: Use const argument, rename variables
The const argument makes sense because these are the "source"
sockets, even though a const cast is necessary at one point.
The name "interface_socket" is an improvement over "stemp"
because the latter sounds like "temporary", or it confuses
the old socket template system with a node group's interface.
2021-12-10 14:54:32 -06:00
Hans Goudey 7c2fb00e66 Cleanup: Remove unnecessary runtime rectangle from nodes in DNA
I assume this `butr` rectangle was used more in the past,
but currently its value is set and used less than 10 lines apart,
so it's trivial to remove 16 bytes from every node. The other
rectangles are also runtime data and could be removed, but
they are more difficult.
2021-12-10 13:52:02 -06:00
Hans Goudey 5a3d5f751f Revert recent changes to ImBuf transform
This reverts commit 943aed0de3  and f76e04bf4d

The latter caused a test failure: `sequencer_render_transform`
Reverting since the fix is not obvious (to me), and people are
away for the weekend.
2021-12-10 12:55:36 -06:00
Hans Goudey 5ca38fd612 Cleanup/Docs: Add comments to Mesh header, rearrange fields
Most of the fields in Mesh had no comments, or outdated misleading
comments. For example, "BMESH ONLY" referred to the BMesh project,
not the data structure. Given how much these structs are used, it should
save a lot of time to have proper comments.

I also rearranged the fields in mesh to have a more logical order. Now
the most important fields come first. In the process I was able to
remove 19 bytes of unnecessary padding (31->12). I just had to
change a `short` flag to `char`.

Differential Revision: https://developer.blender.org/D13454
2021-12-10 10:42:28 -06:00
Moritz Röhrich f886f29355 Fix T93591: Random Value node first and last value proportion
This patch replaces `round_fl_to_int` with `floor` and adjusts the
maximum value accordingly. The call to `round_fl_to_int` is problematic
here because it messes with the probability distribution at the edges
of the value range, meaning the first and last values were only half
as common as all other values. Since `round_fl_to_int` does
`floor(val + 0.5)`, it will not introduce misbehavior in edge cases.

Differential Revision: https://developer.blender.org/D13474
2021-12-10 09:34:30 -06:00
Jeroen Bakker 943aed0de3 ImBuf: Extracted UV Wrapping from the Interpolation functions.
Improvement of the IMB_transform function by separating the UVWrapping
method from the color interpolation function. This would allow us to
perform uv wrapping operations separate from the interpolation function.

Currently this wrapping is only supported when interpolating colors.
This change would allow us to perform it on non-color image buffers.
2021-12-10 16:14:36 +01:00
Jeroen Bakker 60a9703de8 Added support for large images to openexr. 2021-12-10 15:38:46 +01:00
Jeroen Bakker f76e04bf4d ImBuf: Use templating for IMB_transform.
Reduce the inner loop of IMB_transform by extracting writing to an
output buffer in a template. This reduces a branch in the inner loop and
would allow different number of channels in the future.
2021-12-10 15:19:41 +01:00
Jeroen Bakker 37e799e299 Fix crash using 32k images.
Use IMB_get_rect_len to solve overflow issues.
2021-12-10 12:28:48 +01:00
Campbell Barton bd2b48e98d Cleanup: move public doc-strings into headers for various API's
Some doc-strings were skipped because of blank-lines between
the doc-string and the symbol and needed to be moved manually.

- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.

Ref T92709
2021-12-10 21:42:06 +11:00
Campbell Barton 63f8d18c0f Cleanup: move public doc-strings into headers for 'python/intern'
Ref T92709
2021-12-10 21:40:53 +11:00
Campbell Barton 3060217d39 Cleanup: move public doc-strings into headers for 'nodes'
Ref T92709
2021-12-10 21:40:30 +11:00
Campbell Barton 715f57371b Cleanup: spelling in comments 2021-12-10 21:28:56 +11:00
Campbell Barton b87b33adbf Cleanup: doxygen comments for node_geo_dual_mesh
- Indent text after dot-points.
- Use an unparsed code-block to display the text verbatim in doxygen.
2021-12-10 21:28:56 +11:00
Jeroen Bakker fcf8fc3eaa Fix Crash: Loading Huge Images.
When loading huge images (30k) blender crashed with a buffer overflow.
The reason is that determine the length of a buffer was done in 32bit
precision and afterwards stored in 64 bit precision.

This patch adds a new function to do the correct calculation in 64bit.
It should be added to other sections in blender as well. But that should
be tested on a per case situation.
2021-12-10 10:37:46 +01:00
William Leeson 57f46b9d5f Fix T92036: `Magic Texture` in Volumetric World Shaders render differently with the CPU and GPU
When rendering volume surfaces in unbounded worlds the volume stepping can produce large values. If used with a magic texture node the values can results in a Inf float which when used in a sin or cos produces a NaN.

To fix this the input values are mapped into the periodic range of the sin and cos functions (-2*PI 2*PI) this stops the possibility of a Inf occurring and thus the NaN. It also improves the accuracy and smoothness of the result due to loss of precision when large values are summed with smaller ones effectively removing the parts of the smaller number (i.e. those in the -2PI to 2PI range) that result in variation of the output of sin and cos.

Reviewed By: brecht

Maniphest Tasks: T92036

Differential Revision: https://developer.blender.org/D12821
2021-12-10 09:09:20 +01:00
Campbell Barton 566a458950 Cleanup: move public doc-strings into headers for 'depsgraph'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.

Ref T92709
2021-12-10 12:19:36 +11:00
Hans Goudey dffd032bc9 Geometry Nodes: Remove unnecessary copy when replacing data
In the `replace_mesh`/`replace_curve` etc. methods, the component
was retrieved with write access. Retrieving with write access will
duplicate the data if the component has another user. This means that
the replaced geometry data was often duplicated just to be deleted
a moment later.

I expect this would have a large impact in performance in some specific
situations when dealing with large geometry. In a scene with many small
meshes though, I didn't observe a significant difference.

This also makes replacing a geometry set's data with the same data
that's already in the set safe. It would be valid to assert for that
case instead, but this seems safer.

Differential Revision: https://developer.blender.org/D13530
2021-12-09 17:43:30 -06:00
Germano Cavalcante 18412744c8 Fix T93687: Transform Gpencil vertices not working if scale is zero
Solution similar to rBd5cefc1844cf.

Basically the problem occurs because `td->smtx` was set to zero matrix.
2021-12-09 18:17:23 -03:00
Hans Goudey 74a566d211 Cleanup: Return early in null check
I'm planning to make these functions slightly more complicated,
and it makes sense to return early when checking one of the parameters
for null anyway.
2021-12-09 14:34:15 -06:00
Johnny Matthews bd3bd776c8 Geometry Nodes: Scene Time Node
This node outputs the current scene time in seconds or in frames.
Use of this node eliminates the need to use drivers to control values
in the node tree that are driven by the scene time.
Frame is a float value to provide for subframe rendering for motion
blur.

Differential Revision: https://developer.blender.org/D13455
2021-12-09 11:50:25 -06:00
Brecht Van Lommel e427e4dbb1 Fix T93871: Image.has_data returns True for images that failed to load 2021-12-09 17:36:19 +01:00
Philipp Oeser fc14d02bc5 Fix T93892: Changing bone name leaves non-functional vertex group
The corresponding vertex group was renamed properly, but the armature
influence was broken for that bone.

Caused by {rB3b6ee8cee708}.

Since above commit, vertex group names are stored on object data (mesh/
lattice/gpencil) and if we update these, we have to inform dependency
graph to have immediate effect.

Maniphest Tasks: T93892

Differential Revision: https://developer.blender.org/D13526
2021-12-09 16:47:06 +01:00
Julian Eisel 5ce1c63e1b Fix T93691: Crash when loading custom thumbnail in custom library
This was an issue with the mixed list of external assets and assets from
the current file. When closing the File Browser to select the custom
preview image, the assets from the current file would be cleared for
reread, to make sure we display up-to-date file data. That is because
the workspace of the temporary File Browser was deleted, causing a
change in the file data (main data-base). The reread would happen in a
background thread, meaning it might not finish before the custom preview
operator runs and queries the active asset. So the preview operator
would get the wrong active asset from context.

Two fixes were needed:
* Make sure current file data is reread before the operator runs, by
  doing this partial rereading on the main thread.
* Ensure the asset list (in fact file list) order stays consistent over
  rereads. If multiple assets with the same name were shown, the
  operator might also have gotten the wrong asset, also leading to a
  crash.

Additionally the file operation handler should probably poll before
executing, to fail gracefully at least (not crash).
2021-12-09 15:51:00 +01:00
Jacques Lucke 74fa4ee92b Fix (unreported): missing null check
A crash happened when `instance_id_attribute` further down in the
function was null. This issue was probably introduced when the
id attribute starting using generic attribute handling.
2021-12-09 13:54:47 +01:00
Campbell Barton d812e46f40 Cleanup: move public doc-strings into headers for 'io/usd'
Ref T92709
2021-12-09 22:47:58 +11:00
Campbell Barton 74e57efb2d Cleanup: move public doc-strings into headers for 'io/alembic'
Ref T92709
2021-12-09 22:37:24 +11:00
Julian Eisel 69f55b1b62 Cleanup: Various cleanups to the tree-view API
* Correct URL for documentation (was changed recently).
* Add comments.
* Reevaluate and update which functions are public, protected or
  private.
* Reorder functions and classes to be more logical and readable.
* Add helper class for the public item API so individual functions it
  uses can be made protected/private (the helper class is a friend).
  Also allows splitting API implementation from the C-API.
* Move internal layout builder helper class to the source file, out of
  the header.
* More consistent naming.
* Add alias for item-container, so it's more clear how it can be used.
* Use const.
* Remove unnecessary forward declaration.
2021-12-09 12:35:15 +01:00
Julian Eisel 9183f9f860 Cleanup/Documentation: Add/move comments for asset files
Adds some basic high-level explanations for editor/UI level asset APIs.
Also moves one such comment from the source file to the header file,
so it's in the same file as other API comments.
2021-12-09 12:35:15 +01:00
Campbell Barton 50f378e5c8 Cleanup: move public doc-strings into headers for 'io/collada'
Ref T92709
2021-12-09 22:25:45 +11:00
Campbell Barton 973dac9b5f Cleanup: use doxy section for itasc_plugin
It wasn't obvious all callbacks were part of the plugin-API.
2021-12-09 21:19:46 +11:00
Campbell Barton 7f4878ac7f Cleanup: move public doc-strings into headers for 'functions'
Ref T92709
2021-12-09 21:17:16 +11:00
Azeem Bande-Ali b8bad3549d Fix T93519: handle prefix names in autocompletes
Autocomplete entires keep track of the length of the prefix
in `name_prefix_offset`. However, the name matching logic
was comparing the string including the prefix which resulted
in tab-completion not working (when the user didn't also type
in the prefix, typically two whitespaces).

This is fixed by passing in a char pointer after the end of
the prefix.

Additionally, some searchbox logic is moved. Previously,
`ui_searchbox_apply` would clear the entry which would mean
that `ui_searchbox_find_index` would never succeed. Now the
search box is only cleared if no match was found.

Differential Revision: https://developer.blender.org/D13483
2021-12-09 11:15:19 +01:00
Campbell Barton 65de17ece4 Cleanup: move public doc-strings into headers for 'freestyle'
Ref T92709
2021-12-09 21:09:54 +11:00
Campbell Barton bc01003673 Cleanup: move public doc-strings into headers for 'nodes/geometry'
Ref T92709
2021-12-09 20:58:39 +11:00
Campbell Barton cd4a7be5b2 Cleanup: move public doc-strings into headers for 'io/gpencil'
Ref T92709
2021-12-09 20:34:14 +11:00
Campbell Barton 3647a1e621 Cleanup: move public doc-strings into headers for 'geometry'
Ref T92709
2021-12-09 20:23:10 +11:00
Campbell Barton 8ef8f3a60a Cleanup: spelling in comments 2021-12-09 20:21:26 +11:00