Commit Graph

6263 Commits

Author SHA1 Message Date
Jacques Lucke ec18e11c37 Cleanup: remove unnecessary "for_write" in method name
This suffix is only preferred when the non-const version does more
work than the const version of a method (e.g. because it may duplicate
data because of implicit sharing).
2023-06-21 09:26:41 +02:00
Campbell Barton 472c461816 Cleanup: spelling in comments 2023-06-21 11:28:58 +10:00
Iliya Katueshenock 7b93431c2d BLI: add assert for negative indices in MutableSpan
Pull Request: https://projects.blender.org/blender/blender/pulls/109143
2023-06-20 09:54:32 +02:00
Campbell Barton 2e087374d9 BLI_rect: support a zero limit for BLI_rctf_compare
Use <= comparison for BLI_rctf_compare so two rectangles which
are exactly the same return true with a limit of zero.

Matches compare_ff, compare_v3v3 etc.

In practice, this shouldn't result in user visible functional changes.
2023-06-20 14:14:16 +10:00
Campbell Barton 69d92bd3de Cleanup: remove strcpy usage
Remove strcpy use in:

- bone_autoside_name
- BLI_string_flip_side_name
- datatoc_icon utility.
- RNA define error messages.
- RNA UI registration.
- extern/xdnd.
2023-06-20 13:26:38 +10:00
Campbell Barton 2100ebca7a Cleanup: use the term "value" for RNA get/set functions
This is already used in most functions.
2023-06-20 13:23:30 +10:00
Campbell Barton 8bcad285de Cleanup: remove strcpy usage 2023-06-19 20:40:49 +10:00
Campbell Barton e1f7757a39 Merge branch 'blender-v3.6-release' 2023-06-19 09:43:12 +10:00
Campbell Barton 25aa510adb Fix potential buffer overflow in BLI_path_sequence_decode
Clamp the by the buffer destination size.
2023-06-19 09:39:27 +10:00
Hans Goudey 05190a5a23 Fix: Add missing header used by recent backport fix
This was added in main by 2cfcb8b0b8, and used by
6a05e5161b which was cherry-picked from main
to the release branch.
2023-06-16 09:18:44 -04:00
Hans Goudey 6301775f48 Cleanup: Access geometry bounds more directly
More consistently return geometry bounds with the `Bounds` type that
holds the min and max in one variable. This simplifies some code and
reduces the need to initialize separate min and max variables first.
Meshes now use the same `bounds_min_max()` function as curves and
point clouds, though the wrapper mesh isn't affected yet.

The motivation is to make some of the changes for #96968 simpler.
2023-06-16 08:14:25 -04:00
Campbell Barton 4a93de9cc9 License headers: move copyright statements into SPDX-FileCopyrightText 2023-06-15 16:47:51 +10:00
Campbell Barton 65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Jacques Lucke 7b61dcf6bc Geometry Nodes: deduplicate anonymous attribute analysis algorithm
Previously, there were two independent algorithms for analysing how anonymous
attributes are used in a node tree: One that just computed the `aal::RelationsInNode`
for an entire node tree and one that performed a more in depth analysis to
determine how far anonymous attributes should be propagated.

As it turns out, both operations can also be done at the same time and the result
can be cached on the node tree. This reduces the amount of code and allows for
better code reuse.

This simplification is likely only an intermediate step as things will probably have
to be refactored further to support e.g. serial loops (#108896).
2023-06-14 14:04:22 +02:00
Hans Goudey c9d70ae44b Merge branch 'blender-v3.6-release' 2023-06-13 08:22:50 -04:00
Hans Goudey 8a11f0f3a2 Fix #108517: Mesh split edges can give invalid indices
The split edges code had a complex method of merging duplicate edges,
going backwards to avoid shifting elements in a vector. Sometimes it
could result in incorrect corner edge indices though, if it moved an
index that matched one of the local variables (I think! I've bee
 trying to understand this all day and still struggling). Instead,
 replace it with a `VectorSet` that handles the deduplication by
 itself, and avoid creating the new edges until the end.

I think this code could still be simpler if we tried to reduce the
amount of things happening at the same time, making more code
deal with the input or final state rather than an in-between one.
But to avoid making the change too complicated I stopped here.

Pull Request: https://projects.blender.org/blender/blender/pulls/108826
2023-06-13 14:10:13 +02:00
Hoshinova 144ad4d20b Nodes: add Fractal Voronoi Noise
Fractal noise is the idea of evaluating the same noise function multiple times with
different input parameters on each layer and then mixing the results. The individual
layers are usually called octaves.
The number of layers is controlled with a "Detail" slider.
The "Lacunarity" input controls a factor by which each successive layer gets scaled.

The existing Noise node already supports fractal noise. Now the Voronoi Noise node
supports it as well. The node also has a new "Normalize" property that ensures that
the output values stay in a [0.0, 1.0] range. That is except for the F2 feature where
in rare cases the output may be outside that range even with "Normalize" turned on.

How the individual octaves are mixed depends on the feature and output socket:
- F1/Smooth F1/F2:
  - Distance/Color output:
    The individual Distance/Color octaves are first multiplied by a factor of
    `Roughness ^ (#layers - 1.0)` then added together to create the final output.
  - Position output:
    Each Position octave gets linearly interpolated with the combined output of the
    previous octaves. The Roughness input serves as an interpolation factor with
    0.0 resutling in only using the combined output of the previous octaves and
    1.0 resulting in only using the current highest octave.
- Distance to Edge:
  - Distance output:
    The Distance octaves are mixed exactly like the Position octaves for F1/Smooth F1/F2.

It should be noted that Voronoi Noise is a relatively slow noise function, especially
at higher dimensions. Increasing the "Detail" makes it even slower. Therefore, when
optimizing a scene one should consider trying to use simpler noise functions instead
of Voronoi if the final result is close enough.

Pull Request: https://projects.blender.org/blender/blender/pulls/106827
2023-06-13 09:18:12 +02:00
Campbell Barton 57dc36fb98 BLI_path: add BLI_path_slash_skip utility function
Avoids having to add inline loops that step over slashes.
2023-06-13 14:36:32 +10:00
Hans Goudey 1e4b80fed9 Attributes: Add quaternion rotation type
Add a quaternion attribute type that will be used in combination with
rotation sockets for geometry nodes to give a more intuitive experience
and better performance when using rotations.

The most interesting part is probably the interpolation, the rest is
the same as the last attribute type addition, 988f23cec3.
We need to interpolate multiple values with different weights.
Based on Sybren's suggestion, this uses the `expmap` methods from
4805a54525 for that.

This also refactors `SimpleMixerWithAccumulationType` to use a
function rather than a cast to convert to the accumulation type.

See #92967

Pull Request: https://projects.blender.org/blender/blender/pulls/108678
2023-06-12 15:49:50 +02:00
Hans Goudey 107c5e39aa Fix: OffsetIndices assert with invalid span
In some cases (when there are no faces for example, the offsets span
can have a size of 1 but no data). That's technically invalid and might
need to be addressed more later on, but for now, just fix the assert.
2023-06-12 08:48:21 -04:00
Campbell Barton a2865b701d Cleanup: rename max-length to maxncpy as this includes the null byte 2023-06-10 17:21:24 +10:00
Sergey Sharybin 884b1e8cc3 BLI: Add math::exp() function
Covers both arithmetic and vectorized types.

Pull Request: https://projects.blender.org/blender/blender/pulls/108793
2023-06-09 10:33:29 +02:00
Campbell Barton 2f1899a7fa Cleanup: spelling in comments 2023-06-09 11:40:50 +10:00
Hans Goudey 65d8cfd82d BLI: Add hash function to quaternion type
Just reuse the 4D vector hash.
This allows creating a CPPType for math::Quaternion.
2023-06-08 17:42:36 -04:00
Hans Goudey 04422064fb Cleanup: Fix mistaken dependency between rotation headers
The quaternion header depended on the old C header where it doesn't
need to with a better alternative in the newer C++ types. Also remove an
unused function in another header.
2023-06-08 17:33:47 -04:00
Chris Blackbourn 55f9abfd3c Merge branch 'blender-v3.6-release' 2023-06-08 14:26:21 +12:00
Chris Blackbourn 9d25c4aaa6 Fix #104513: UV packing produces different results on x86 vs apple silicon
During uv unwrapping and uv packing, certain floating point algorithms
have extreme sensitivity to round-off errors. These can produce very
different layouts even when given inputs which are only slightly different.

The root cause is that the two main types of CPUs used to run Blender,
namely x86 and Apple Silicon, produce slightly different results on some
math functions, including `sinf()`, `cosf()` and `atan2f()`.

* sinf(0.8960554599761962890625) = 0.780868828296661376953125 (Intel i7)
* sinf(0.8960554599761962890625) = 0.78086888790130615234375 (Apple M1)

This fix, and others that came before it [0], improve accuracy by using
double-precision to hide the differences between the CPUs.

[0] e.g. 0eba9e41bf
[1] See also #107829
2023-06-08 14:23:44 +12:00
Campbell Barton 9c28eebc9a Cleanup: minor clarifications & corrections, use doxygen comments
Also replace full URL's in with #ID.
2023-06-08 10:43:55 +10:00
Sergey Sharybin 97197bd53e BLI: Add more per-element functions for vectors
This includes square root and reciprocal, and their safe versions.

For the reciprocal use name rcp, which matches Cycles and allows
to implement the same function for per-element operation on matrices.

Pull Request: https://projects.blender.org/blender/blender/pulls/108705
2023-06-07 15:15:37 +02:00
Sergey Sharybin db3a96492f BLI: Use math:: functions for per-element vector operations
Use math functions from blender::math for those operations, which
allows to device vectors of non-standard types.
2023-06-07 15:15:35 +02:00
Campbell Barton 7d56c8fe1d BLI_string: add BLI_strchr_or_end
Returning the pointer to the null byte when the character isn't found
is useful when handling null terminated strings that contain newlines.

This means the return value is never null and the line span always ends
at the resulting value.
2023-06-05 12:17:13 +10:00
Campbell Barton 85e5d3325c Cleanup: replace 'sz' abbreviation with 'size' 2023-06-04 19:56:19 +10:00
Campbell Barton 493a1dd7c8 Cleanup: remove NULL literals in C++ (including comments & strings) 2023-06-04 18:35:12 +10:00
Campbell Barton 74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
Campbell Barton b347346ca7 Cleanup: header wrapping, spelling, use doxy sections 2023-06-03 08:21:48 +10:00
Campbell Barton 9b97123bf9 Cleanup: spelling in comments, odd comment block spacing 2023-06-02 10:16:16 +10:00
Harley Acheson a58e5ccdec UI: File Save Incremental Operator
Operator for the TopBar File Menu that saves the currently open file
with a numerically incremented name.

Pull Request: https://projects.blender.org/blender/blender/pulls/104678
2023-06-01 17:34:57 +02:00
Hans Goudey 9e9e0bf6d0 Geometry Nodes: Copy no loose vert/edge status in delete geometry node
When the loose edge and vertex status are cached in the source mesh and
the combination of selection domain and mode don't add loose elements,
copy the cache status to avoid recomputation. In a test with a 1 million
face grid:
- All: 23 -> 30 FPS
- Only faces: 22 -> 23.5 FPS
- Only edges and faces: 24 -> 27 FPS

Also remove unnecessary includes and fix a build error introduced in
the last commit to this area from an inconsistent forward declaration.
2023-06-01 10:02:37 -04:00
Hans Goudey 50bfe1dfe3 Geometry Nodes: Rewrite mesh delete geometry node
Replace the implementation of the separate and delete geometry nodes
for meshes. The new code makes more use of the `IndexMask` class, which
was recently optimized. The main goal is to make more of the work scale
with the size of the result mesh rather than the input. For example,
instead of keeping a map from input to output elements, the maps used
to copy attributes go from output to input elements.

The new implementation is generally 2-4x faster, depending on the mode
and the number of elements selected. The new code is also able to skip
more work when nothing is removed.

This also allows using more existing attribute interpolation code,
allowing the overall removal of over 300 lines. Some of the attribute
utilities from a similar change for curves (f63cfd8e28) are
reused directly.

The indices of the result changes, so the test file needs to be updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/108435
2023-06-01 14:55:21 +02:00
guishe f957fd227e Fix: Avoid windows.h min/max macro definition in BLI_winstuff.h
When moving io_allembic to c++, the compiler would throw the error
`type "unknown-type" unexpected`.

Pull Request: https://projects.blender.org/blender/blender/pulls/108471
2023-06-01 12:26:34 +02:00
Julian Eisel 06be652055 Cleanup: Clang-format 2023-05-31 17:18:20 +02:00
Hans Goudey 49b48209e7 BLI: Improve IndexMask::complement() performance
IndexMask::complement() is often used in geometry processing
algorithms when a selection needs to be inverted, mostly just in
curves code so far.

Instead of reusing `from_predicate` and lookup in the source mask,
scan the mask once, inserting segments between the original indices.

Theoretically this improves the performance from O(N*log(N)) to O(N).
But with the small constant offset of the former, the improvement is
generally just 3-4 times faster. However in some cases like empty
and full masks, the new code takes constant time.

![image](/attachments/d2f6b0be-f195-4206-9bf4-c0ab20041d1b)

Pull Request: https://projects.blender.org/blender/blender/pulls/108331
2023-05-31 17:11:04 +02:00
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton d6b9df2737 Merge branch 'blender-v3.6-release' 2023-05-29 21:54:50 +10:00
Campbell Barton 21ef4276ee Fix potential buffer overflow in BLI_windows_get_executable_dir
GetModuleFileName size was 256 bytes greater then the argument given.
2023-05-29 20:33:43 +10:00
Campbell Barton 3a5ba15c79 PyAPI: add bpy.app.help_text() for accessing output from `--help`
Simplify help text extraction which may be used by the manual &
man-page generation.
2023-05-27 16:36:52 +10:00
Campbell Barton d9ffa2dfc4 Test: add string.StrCat test 2023-05-27 15:46:34 +10:00
Campbell Barton 26e1d63b67 Cleanup: rename fname to filepath or failname depending on use 2023-05-27 15:38:15 +10:00
Campbell Barton 12d91d4e60 Cleanup: spelling in comments 2023-05-27 15:24:52 +10:00
Campbell Barton 823685db76 Cleanup: consistent doxygen comment blocks
Also remove doxygen block for comments in a functions body.
2023-05-27 15:10:58 +10:00