1
1

Compare commits

...

1703 Commits

Author SHA1 Message Date
0bdf574ea2 Merge branch 'master' into draw-viewport-data 2022-01-26 22:05:55 +01:00
bb1e2a80e4 Cleanup: Workbench: Remove extern shader strings
This is not needed anymore with the new dependency system.
2022-01-26 22:04:49 +01:00
710e46cb2d Cleanup: Move specific node tree execution functions into respective module
`node_exec` had some code that was specific to texture/shader nodes.
These functions  arent used outside there module so limit there declarations.

Also make a function static that is only used in `node_exec.c`

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13899
2022-01-26 15:29:31 -05:00
cab1f1d9a2 Geometry Nodes: Add or improve various socket descriptions 2022-01-26 14:22:23 -06:00
af87b6d8cb Merge branch 'master' into draw-viewport-data
# Conflicts:
#	source/blender/draw/DRW_engine_types.h
#	source/blender/draw/intern/draw_manager.c
#	source/blender/draw/intern/draw_manager.h
#	source/blender/draw/intern/draw_manager_profiling.c
#	source/blender/draw/intern/draw_manager_text.h
#	source/blender/draw/intern/draw_texture_pool.cc
#	source/blender/draw/intern/draw_texture_pool.h
#	source/blender/draw/intern/draw_view_data.cc
#	source/blender/draw/intern/draw_view_data.h
#	source/blender/editors/space_view3d/view3d_draw.c
#	source/blender/gpu/GPU_texture.h
#	source/blender/gpu/GPU_viewport.h
#	source/blender/gpu/intern/gpu_shader_create_info_private.hh
#	source/blender/gpu/intern/gpu_viewport.c
2022-01-26 20:27:16 +01:00
7b615ca186 Cleanup: Remove RNA data from TreeElement, get via type specific class
The `TreeElement.rnaptr` was only needed for RNA tree-elements. Now it
can be gotten through the new type specific classes, e.g.
`TreeElementRNAProperty.getPointerRNA()`.
2022-01-26 19:15:57 +01:00
9dc0379dc0 Cleanup: Improve function name, introduced in own recent commit
I prefer it this way around now, especially since I'm adding a
`getPointerRNA()` too. Good to keep it match the actual struct names.
2022-01-26 19:15:57 +01:00
f6296e502a Cleanup: Small improvements to Outliner RNA path build function
Smaller cleanups to improve readability of a complex function.
2022-01-26 19:15:57 +01:00
fdd84d36ce Fix incorrect index-key in RNA path built from Outliner
Bug introduced in 7cbcfb7f49.
2022-01-26 19:15:57 +01:00
b57db4b79e Cleanup: Reduce void * reliance of new RNA C++ Outliner elements
Continuation of the previous commit, this time addressing the same for
RNA tree-elements.
2022-01-26 19:15:57 +01:00
fc0dd5583c Cleanup: Reduce void * reliance of new sequencer C++ Outliner elements
Plan is to remove things like `TreeElement.directdata` and to instead
expose specific queries in the new type specific tree-element classes.
e.g. like here: `TreeElementSequence.getSequence()`

For now uses `tree_element_cast<>()` to get the new type specific
tree-element, later these should replace `TreeElement` all together.
2022-01-26 19:15:57 +01:00
08e2885796 Outliner: Function to "cast" C-style TreeElement to typed C++ pendant
Add function to safely request the type-specific C++ element from a
C-style `TreeElement`. Looks like this:
```
TreeElementFoo *te_foo = tree_element_cast<TreeElementFoo>(te);
```
The "cast" will return null if the tree-element doesn't match the
requested type.

This is useful for the transition from the C-style type to the new ones.
2022-01-26 19:15:57 +01:00
da1b6c4c02 Outliner: Port sequencer elements to new tree-element design
Continuation of work started in 2e221de4ce and 249e4df110.

Adds new tree-element classes for sequences, strips and strip
duplicates.
2022-01-26 19:15:57 +01:00
d74c2b5c1f Outliner: Add missing sanity checks for RNA tree-elements
Forgot to add these in 9bce134e56. Also tweaked assert to print a
message that was previously communicated via a comment only.
2022-01-26 19:15:57 +01:00
57dfec79f4 DRW: Fix builtin uniform name mismatch
This lead to severe unreported regression, like volume rendering broken
in workbench.
2022-01-26 19:09:05 +01:00
13f2df3c28 Fix/workaround failing Cycles tests on macOS after ray offset changes
Temporarily blacklist a few tests with overlapping objects as they seem to
give different results on this platform.
2022-01-26 18:52:56 +01:00
489b484b7b Cleanup: GPUShaderShared: Complete vector support
Move some declaration from `GPU_shader_shared.h` to the main
common file and add missing vector declarations.
2022-01-26 18:10:59 +01:00
b42adab3a2 GPUShader: Add GLSL source modification pass to support enums
This uses a light parser / string modification pass to convert
C++ enum declaration syntax to GLSL compatible one.

GLSL having no support for enums, we are forced to convert the
enum values to a series of constant uints.

The parser (not really one by the way), being stupidly simple,
will not change anything to the values and thus make some C++
syntax (like omitting the values) not work.

The string replacement happens on all GLSL files on startup.
I did not measure significant changes in blender startup speed.
There is plans to do all of this at compile time.

We limit the scope of the search to `.h` and `.hh` files to prevent
confusing syntax in `.glsl` files.

There is basic error reporting with file, line and char logging
for easy debuggabiliy.

The requirements to use this enum sharing system are already listed in
`gpu_shader_shared_utils.h` and repeated on top of the preprocessor
function.
2022-01-26 18:10:59 +01:00
e729abb0e2 BLI_string_ref: Add back missing rfind()
Must have been removed in a bad merge or something.
2022-01-26 18:10:59 +01:00
William Leeson
74afc86d4b Cycles: remove ray offsetting
Remove small ray offsets that were used to avoid self intersection, and leave
that to the newly added primitive object/prim comparison. These changes together
significantly reduce artifacts on small, large or far away objects.

The balance here is that overlapping primitives are not handled well and should
be avoided (though this was already an issue). The upside is that this is
something a user has control over, whereas the other artifacts had no good
manual solution in many cases.

There is a known issue where the Blender particle system generates overlapping
objects and in turn leads to render differences between CPU and GPU. This will
be addressed separately.

Differential Revision: https://developer.blender.org/D12954
2022-01-26 17:51:05 +01:00
William Leeson
ae44070341 Cycles: explicitly skip self-intersection
Remember the last intersected primitive and skip any intersections with the
same primitive.

Ref D12954
2022-01-26 17:51:05 +01:00
William Leeson
a9bb460766 Cycles: compute triangle location from barycentric instead of re-intersecting
This is a bit more efficient than what we did before.

Ref D12954
2022-01-26 17:51:05 +01:00
974981a637 Fix T95222: Crash selecting vertices with modifier applied on cage
Caused by 0f89bcdbeb where it was needed for cage and evaluated mesh
to have same behavior in respect of having edit_mesh pointer assigned.
This change makes it so that edit_data is not implied to exist when the
edit_mesh pointer is not null. This was already the case in some other
code.
2022-01-26 17:48:45 +01:00
79927e730e LibOverride: Resync: Do not process overrides that should already have been resynced.
Those cases are almost always synptoms of either bug in code, or broken
files. Re-doin resync on them only costs time and causes extra trash
data as a result, without really helping in any way.
2022-01-26 16:20:08 +01:00
990ed109f2 Fix (unreported) missing 'override-exclusion' flag on new RNA mesh data accessors.
Both new normals (from rBb7fe27314b25) and vpaint (from rBf7bbc7cdbb6c)
RNA arrays were missing the `PROPOVERRIDE_IGNORE`. Those huge blobs of
geometry data should never be processed by liboverride code.
2022-01-26 16:20:08 +01:00
37848d1c8e Assets: enable node group assets
This enables support for node group assets. Previously, node group
assets only worked when the "extended asset browser" experimental
features is enabled.

Differential Revision: https://developer.blender.org/D13748
2022-01-26 15:22:15 +01:00
12b26d21b0 Assets: allow creating preview image by rendering active object
For node groups there is no good default preview generation.
Nevertheless, t would be useful to generate a preview image for a
node group by rendering an object in some cases.

This commit adds a new operator that allows updating the preview
image for the active asset by rendering the active object.
Note, the operator can also be used for other asset types, not just
node groups.

The operator can be found in a menu right below the refresh-preview
button. Currently it is the only operator in that menu. In the future,
more operators to create previews may be added.

Differential Revision: https://developer.blender.org/D13747
2022-01-26 15:10:49 +01:00
6738ecb64e Fix T94900: Fix drawing artifacts sequencer+node editor.
The VSE and node editor only uses an overlay buffer to draw to the screen. The
GPUViewport assumes that platforms clears all textures during creation, but
they do not on selected platforms. What would lead to drawing from
uncleared memory.

This patch fixes this by clearing all viewport textures during creation.
2022-01-26 14:48:28 +01:00
5b299e5999 D13910: Workbench: Port shaders to use GPUShaderCreateInfo
Also adds a few things to GPUShader for easily create shaders.
Heavy usage of macros to compose the createInfo and avoid
duplications and copy paste bugs.
This makes the link between the shader request functions
(in workbench_shader.cc) and the actual createInfo a bit
obscure since the names are composed and not searchable.

Reviewed By: jbakker
Differential Revision: https://developer.blender.org/D13910
2022-01-26 12:46:37 +01:00
9bce134e56 Outliner: Port RNA elements to new tree-element design
Continuation of work started in 2e221de4ce and 249e4df110.

Adds new tree-element classes for RNA structs, properties and array
elements. This isn't exactly a copy and paste, even though logic should
effectively be the same. Further cleanups are included to share code in
a nice way, improve code with simple C++ features, etc.
2022-01-26 11:44:58 +01:00
1bf6a880ab ID: Fix failing test cases.
This fixes failing test cases when using `make test`.
See {D13615} for more information.

The fix will perform the id remapping one item at a time. Although not
really nice, this isn't a bottleneck.

The failing test cases is because space_node stores pointers multiple
times and didn't update all pointers. It was not clear why it didn't do
it, but changing the behavior more to the previous behavior fixes the
issue at hand.

I prefer to remove the double storage of the node tree pointers (in
snode and path) to reduce pointer management complexity.
2022-01-26 11:12:52 +01:00
Jeroen Bakker
a21bca0e20 Performance: Remap multiple items in UI
During sprite fright loading of complex scenes would spend a long time in remapping ID's
The remapping process is done on a per ID instance that resulted in a very time consuming
process that goes over every possible ID reference to find out if it needs to be updated.

If there are N of references to ID blocks and there are M ID blocks that needed to be remapped
it would take N*M checks. These checks are scattered around the place and memory.
Each reference would only be updated at most once, but most of the time no update is needed at all.

Idea: By grouping the changes together will reduce the number of checks resulting in improved performance.
This would only require N checks. Additional benefits is improved data locality as data is only loaded once
in the L2 cache.

It has be implemented for the resyncing process and UI editors.
On an Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz 16Gig the resyncing process went
from 170 seconds to 145 seconds (during hotspot recording).

After this patch has been applied we could add similar approach
to references (references between data blocks) and functionality (tagged deletion).
In my understanding this could reduce the resyncing process to less than a second.
Opening the village production file between 10 and 20 seconds.

Flame graphs showing that UI remapping isn't visible anymore (`WM_main_remap_editor_id_reference`)
* Master {F12769210 size=full}
* This patch {F12769211 size=full}

Reviewed By: mont29

Maniphest Tasks: T94185

Differential Revision: https://developer.blender.org/D13615
2022-01-26 11:12:35 +01:00
b3bf46b78d Revert "CMake: include BROTLI_LIBRARIES in FREETYPE_LIBRARIES on UNIX"
This reverts commit 086f191169.

There was apparently a problem using APPEND which wasn't referenced
in the commit log.

Added comment noting the reason for the discrepancy.
2022-01-26 20:51:04 +11:00
0cb5eae9d0 Gizmo: optimize intersection tests, fix selection bias
Use more efficient logic for detecting when gizmos are under the cursor.
Even though this isn't a bottleneck, it runs on cursor motion in the
3D viewport, so avoiding any lag here is beneficial.

The common case for cursor motion without any gizmos was always
drawing two passes (one small, then again if nothing was found).

Now a single draw call at the larger size is used.

In isolation this gives around 1.2x-1.4x speedup.

When there are multiple gizmos a depth-buffer picking is used
(similar to object / bone selection) which is more involved but
still only performs 2x draw calls since the result is cached for reuse.

See note in gizmo_find_intersected_3d for a more detailed explanation.

Also restore the depth values in the selection result as they're
needed for gizmos to use selection bias.
Broken since support for GL_SELECT was removed.
2022-01-26 17:24:21 +11:00
1758dcd423 Fix T94794: Gizmo selection doesn't pick the front-most gizmo
Early on in 2.8x development gizmo-depth used GL_SELECT,
which has been removed. Bind the depth buffer so occlusion queries
use the front-most gizmo.

While this report only mentions face-maps, gizmo depth was ignored in
all cases. This wasn't noticeable in most cases though since the
transform gizmo for example was placed so gizmos didn't overlap.
2022-01-26 17:21:10 +11:00
9338126ecc Fix error using GPU selection cache for selection picking
When calling GPU_select_cache_begin, checking the selection mode used
the last used selection mode, not the one about to be used.

Using border select, then picking would not use the selection cache.

This wasn't noticeable by users as failing to use cache just completes
the selection without it (drawing the depth buffer unnecessarily).
2022-01-26 17:21:10 +11:00
46ae083113 Fix: OSL not recognizing UVTILE images
The OSL image compilation step needed to be taught about the new UVTILE
format for UDIM textures.

A small missing feature from OIIO[1] means this is a bit uglier than it
needs to be. Once we update to a version of OIIO with the fix we can
remove the string replace part.

[1] 35cb6a83e2

Differential Revision: https://developer.blender.org/D13912
2022-01-25 22:00:23 -08:00
b06fff4737 Cleanup: spelling in comments 2022-01-26 16:06:22 +11:00
94d2a611ec Cleanup: unused variable warning, formatting 2022-01-26 16:01:34 +11:00
37e555d2fe CMake: mark all BROTLI libraries as advanced 2022-01-26 16:01:00 +11:00
086f191169 CMake: include BROTLI_LIBRARIES in FREETYPE_LIBRARIES on UNIX
This was already done for APPLE & WIN32, which would
reference these libraries twice.

Now append BROTLI_LIBRARIES to FREETYPE_LIBRARIES when they're
required for linking.

No functional changes as all references to FREETYPE_LIBRARIES also
used BROTLI_LIBRARIES.
2022-01-26 16:00:55 +11:00
4c951bfa82 CMake: add WITH_SYSTEM_FREETYPE to link against the systems freetype 2022-01-26 15:31:30 +11:00
4530449317 CMake: resolve issues using pre-compiled & system libraries for Unix
When LIBDIR existed, searching for system libraries would always
first search 'LIBDIR'.

This meant "WITH_SYSTEM_*" would still prefer LIBDIR versions of
libraries if they exist.

The presence of LIBDIR also ignored the setting for WITH_STATIC_LIBS
which is now restored to the cached value once pre-compiled libraries
have been handled.
2022-01-26 15:20:32 +11:00
c4bedeb018 GLShader: Fix crash caused by redundant uniform declaration
This slipped through during a rebase.
2022-01-26 00:03:27 +01:00
83094d9a0d Fix T94149: Incorrect sound strip length
Fix formula in function `SEQ_sound_update_length`.

Formula for sound strip length was changed in commit ded68fb102, when
strip is added to timeline, but it was not changed in function
mentioned above.
2022-01-25 23:59:50 +01:00
c1b5cea63a Cleanup: Remove useless comments 2022-01-25 16:54:36 -06:00
b45e71e22c VSE: Build proxies only for slow movies
This change applies only for automatic proxy building, when strip
is added to timeline. Manual building process is not affected.

Don't build proxy file if movie is already fast enough to seek.
To determine seek performance, check if whole GOP can be decoded
in 100 milliseconds.

To consider some variation in GOP size, large number of packets are
read, assuming that each packet will produce 1 frame. While this is not
technically correct, it does give quite accurate estimate of maximum GOP
size.

This test will ensure consistent performance on wide array of machines.
Check should be done in order of few milliseconds.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11671
2022-01-25 22:06:46 +01:00
597eaeaa11 Deps builder: add VS2019, remove 2013/2015 support
This will allow building most deps with VS2019
SDL has some linker issues that are resolved in
a newer version, but that would be better handled
in a separate change.

VS2013 and VS2015 support which was broken has
been removed.
2022-01-25 13:55:18 -07:00
52b2769b9c Fix T95169: Assert in weld modifier code
Return early before accessing the array when all edges are merged.
2022-01-25 13:56:00 -06:00
c847122096 Cleanup: Remove leftover hair fade code in Cycles
Missed in rB1687903fb813f6656453fbc7c49237b06437370c
2022-01-25 14:14:39 -05:00
1687903fb8 Cleanup: Remove leftover hair fade code in Cycles. 2022-01-25 19:46:10 +01:00
c89d6b0953 Workbench: Use GPU_ARB_gpu_shader5 instead of GL variant
This is to be able to turn off the extension usage on demand.
2022-01-25 18:51:31 +01:00
2637f94358 GLShader: Fix buffer overflow caused by workaround uniform
In order to use a workaround builtin uniform, we need to count it
just like other uniforms and give it some space in the name buffer.

This also fixes extensions being added after the uniform declaration.
All `#extension` directives are now part of the gl backend.
2022-01-25 18:48:58 +01:00
3e2591c83e Cleanup: Remove unused variable
Mistake in a18bd403bf
2022-01-25 11:08:34 -06:00
0ec94d5359 Geometry Nodes: Port weld modifier to the merge by distance node
This commit moves the weld modifier code to the geometry module
so that it can be used in the "Merge by Distance" geometry node
from ec1b0c2014. The "All" mode is exposed in the node
for now, though we could expose the "Connected" mode in the future.

The modifier itself is responsible for creating the selections from
the vertex group. The "All" mode takes an `IndexMask` for the
selection, and the "Connected" mode takes a boolean array,
since it actually iterates over all edges.

Some disabled code for a BVH mode has not been copied over,
it's still accessible through the patches and git history anyway,
and it made the port slightly simpler.

Differential Revision: https://developer.blender.org/D13907
2022-01-25 11:07:31 -06:00
932d8dba52 Point Cloud: expose in Python API for release, now that Cycles uses it
Previously it was only part of experimental features in beta, however now
renderers can render point clouds generated by geometry nodes. Adding or
converting a point cloud object directly is still hidden by default, since
there is no good way to edit it.
2022-01-25 18:03:52 +01:00
ec1b0c2014 Geometry Nodes: Initial merge by distance node
This implements a merge by distance operation for point clouds.
Besides the geometry input, there are two others-- a selection
input to limit the operation to certain points, and the merge
distance. While it would be a reasonable feature, the distance
does not support a field currently, since that would make
the algorithm significantly more complex.

All attributes are merged to the merged points, with the values
mixed together. This same generic method is used for all attributes,
including `position`. The `id` attribute uses the value from the
first merged index for each point.

For the implementation, most of the effort goes into creating a
merge map to speed up attribute mixing. Some parts are inherently
single-threaded, like finding the final indices accounting for the
merged points. By far most of the time is spend balancing the
KD tree.

Mesh support will be added in the next commit.

Differential Revision: https://developer.blender.org/D13649
2022-01-25 10:51:52 -06:00
97a023a0d5 Cycles: Reorganize Acceleration Structure UI panel.
Only show options that are valid for the used device (CPU, GPU, Multi).

Note: The panel isn't shown for OPTIX anymore, unless Multi device is used.

Reference: https://developer.blender.org/D13592
2022-01-25 17:33:41 +01:00
e2a36a6e45 Cycles: Make Embree compact BVH optional
Make the Embree RTC_SCENE_FLAG_COMPACT flag optional and enabled per default.
Disabling it makes CPU rendering a bit faster in some scenes at the cost of a higher memory usage.

Barbershop renders about 3% faster, victor about 4% on CPU with compact BVH disabled.

Differential Revision: https://developer.blender.org/D13592
2022-01-25 17:22:08 +01:00
f26c36c96b make.bat: unify python detection
Several sub commands tried on their own
to locate python, given I wanted to look
in several locations for a broader libdir
compatibility this is best done in a
central location.

Python 3.9 is still preferred, but if
3.10-3.12 are available that be accepted
as well.

note: this is about the python version
make.bat uses to run various python helper
scripts, this change has no influence on
the python version blender itself uses.
2022-01-25 09:19:03 -07:00
c813a1b358 Cycles: add Point Info node
With (center) position, radius and random value outputs.

Eevee does not yet support rendering point clouds, but an untested
implementation of this node was added for when it does.

Ref T92573
2022-01-25 17:14:20 +01:00
eab066cbf2 VSE: Use timecodes by default
Movies with variable frame rate can cause mismatch of displayed frame
when proxies are used. Since proxies are not used for rendering, this
means, that output may be different than expected. This problem can be
avoided when timecodes are used.

Set used timecode to Record Run. Timecodes are built with proxies at
the same time, therefore if proxies are built and used this will
resolve possible mismatch of output.

Record run is chosen, because it will show frames based on time they
were encoded by encoder and should match behavior as if movie was
played back at normal speed. This change is done only for new strips
in order to not overwrite user defined settings.

Other minor changes:
- When proxies are enabled, size 25% is no longer set by default. It was mostly annoying anyway.
- Silence warning when timecode file is not present. This was introduced in 4adbe31e2f.
  Previously use of timecodes was hard-coded in sequencer and this error would spam console if timecodes would be
  enabled by default and proxies would be never built.

ref: T95093

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13905
2022-01-25 17:07:11 +01:00
Michael
2ed73fc97e Fix T94237: Glitch when copying unaligned ffmpeg buffer
Using a negative linesize to flip an image vertically is supported in
ffmpeg but not for every function.

This method treats frames that need and those that do not need alignment
the same. An RGBA frame buffer with alignment that ffmpeg decides is
optimal for the CPU and build options is allocated by ffmpeg.
The `sws_scale` does the colorspace transformation into this RGBA frame
buffer without flipping. Now the image is upside down and aligned.
The combined unaligning and vertical flipping is then done by
`av_image_copy_to_buffer` which seems to handle negative linesize
correctly.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D13908
2022-01-25 17:07:11 +01:00
a18bd403bf Nodes: Improve link-drag search support for boolean math node
List the operations in the search instead of the "Boolean" socket names.
2022-01-25 09:51:20 -06:00
96667e3391 Fix T93058: Crash on opening old pre-2.80 .blend files.
Layer resync code would not yet fully properly deal with all possible
invalid status of ViewLayer comming from those older files.

Now put 2.80-doversion specific fixes into their own dedicated
function, so that they do not affect actual regular layer resync code
anymore. Also added some sanity-checks in main
`BKE_layer_collection_sync` code.
2022-01-25 16:44:55 +01:00
6c25aabddf GLShader: Fix fallback to gl_BaseInstance
All `#entension` directives needs to be first before any other
token. Add missing `;` after uniform declaration.
2022-01-25 16:23:54 +01:00
0477ca75f0 CMake/Linux: only link to brotli when using static precompiled libraries
The Brotli library only needs to be explicitly linked when using the
statically linked libraries. When using system libs they're shared, and
the .so loading mechanism takes care of dependencies.
2022-01-25 16:18:59 +01:00
Hallam Roberts
14f6afb090 Geometry Nodes: Expand the Boolean Math node
Currently the Boolean Math node only has 3 basic logic gates:
AND, OR, and NOT. This commit adds 6 additional logic gates
for convenience and ease of use.

- **Not And (NAND)** returns true when at least one input is false.
- **Nor (NOR)** returns true when both inputs are false.
- **Equal (XNOR)** returns true when both inputs are equal.
- **Not Equal (XOR)** returns true when both inputs are different.
- **Imply (IMPLY)** returns true unless the first input is true and
  the second is false.
- **Subtract (NIMPLY)** returns true when the first input is true and
  the second is false.

Differential Revision: https://developer.blender.org/D13774
2022-01-25 09:09:39 -06:00
368bfa80f9 Fix: Build issue with MSVC + Python 3.10
ssize_t is a posix type pyconfig.h previously
supplied for MSVC, it appears to have stopped
doing this in the python 3.10 headers.

Py_ssize_t is the type of the field this macro
actually returns, so best to to use that in our
code as well.
2022-01-25 07:54:28 -07:00
460e0a1347 Revert "Performance: Remap multiple items in UI"
This reverts commit 948211679f.
This commit introduced some regressions in the test suite.
As this change is a core part of blender Bastien and I decided to revert
it as the solution isn't clear and needs more investigation.

The following tests FAILED:
	 62 - blendfile_liblink (SEGFAULT)
	 63 - blendfile_library_overrides (SEGFAULT)

It fails in (id_us_ensure_real)
2022-01-25 15:31:46 +01:00
33ba298b5d GPUShader: Add optionnal single shader stage interface for in and out
This makes optionnal the use of a different interface for the geometry
shader stage output. When the vertex and geometry interface instance name
matches, a `_in` and `_out` suffix is added to the end of the instance name.

This makes it easier to have optional geometry shader stages.

# Conflicts:
#	source/blender/gpu/intern/gpu_shader_create_info.hh
2022-01-25 15:08:11 +01:00
Jeroen Bakker
948211679f Performance: Remap multiple items in UI
During sprite fright loading of complex scenes would spend a long time in remapping ID's
The remapping process is done on a per ID instance that resulted in a very time consuming
process that goes over every possible ID reference to find out if it needs to be updated.

If there are N of references to ID blocks and there are M ID blocks that needed to be remapped
it would take N*M checks. These checks are scattered around the place and memory.
Each reference would only be updated at most once, but most of the time no update is needed at all.

Idea: By grouping the changes together will reduce the number of checks resulting in improved performance.
This would only require N checks. Additional benefits is improved data locality as data is only loaded once
in the L2 cache.

It has be implemented for the resyncing process and UI editors.
On an Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz 16Gig the resyncing process went
from 170 seconds to 145 seconds (during hotspot recording).

After this patch has been applied we could add similar approach
to references (references between data blocks) and functionality (tagged deletion).
In my understanding this could reduce the resyncing process to less than a second.
Opening the village production file between 10 and 20 seconds.

Flame graphs showing that UI remapping isn't visible anymore (`WM_main_remap_editor_id_reference`)
* Master {F12769210 size=full}
* This patch {F12769211 size=full}

Reviewed By: mont29

Maniphest Tasks: T94185

Differential Revision: https://developer.blender.org/D13615
2022-01-25 14:51:44 +01:00
Jeroen Bakker
3f42417cd4 Draw: Migrate hair refine compute shader to use create info.
This patch migrates the draw manager hair refine compute shader to use
GPUShaderCreateInfo.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D13915
2022-01-25 14:46:45 +01:00
196da819ba Python: Expose crazyspace correction functionality via RNA
Allows to perform correction of coordinate delta/displacement in a
similar way of how sculpt mode handles sculpting on a deformed mesh.
An example of usecase of this is allowing riggers and sciprters to
improve corrective shapekey workflow.

The usage consists of pre-processing and access. For example:

  object.crazyspace_eval(depsgraph, scene)

  # When we have a difference between two vertices and want to convert
  # it to a space to be stored, say, in shapekey:
  delta_in_orig_space = rigged_ob.crazyspace_displacement_to_original(
      vertex_index=i, displacement=delta)

  # The reverse of above.
  delta_in_deformed_space = rigged_ob.crazyspace_displacement_to_deformed(
      vertex_index=i, displacement=delta)

  object.crazyspace_eval_clear()

Fuller explanation with actual usecases and studio examples are written in
the comment:

  https://developer.blender.org/D13892#368898

Differential Revision: https://developer.blender.org/D13892
2022-01-25 14:43:44 +01:00
31296f6f9d CMake/Linux: Fix Brotli library finding on standard distros.
Brotli seems to add a custom postfix to its static libraries by default,
but in Debian at least libraries are just named the same for both shared
and static versions, as usual.

So add standard name after static-specific ones.

Follow-up to rB4c617c06e9cb and rBa000de7c2a4d.
2022-01-25 14:34:33 +01:00
0f89bcdbeb Fix depsgraphs sharing IDs via evaluated edit mesh
The evaluated mesh is a result of evaluated modifiers, and referencing
other evaluated IDs such as materials.
It can not be stored in the EditMesh structure which is intended to be
re-used by many areas. Such sharing was causing ownership errors causing
bugs like

  T93855: Cycles crash with edit mode and simultaneous viewport and final render

The proposed solution is to store the evaluated edit mesh and its cage in
the object's runtime field. The motivation goes as following:

- It allows to avoid ownership problems like the ones in the linked report.
- Object level is chosen over mesh level is because the evaluated mesh
  is affected by modifiers, which are on the object level.

This patch allows to have modifier stack of an object which shares mesh with
an object which is in edit mode to be properly taken into account (before
the change the modifier stack from the active object will be used for all
objects which share the mesh).

There is a change in the way how copy-on-write is handled in the edit mode to
allow proper state update when changing active scene (or having two windows
with different scenes). Previously, the copt-on-write would have been ignored
by skipping tagging CoW component. Now it is ignored from within the CoW
operation callback. This allows to update edit pointers for objects which are
not from the current depsgraph and where the edit_mesh was never assigned in
the case when the depsgraph was evaluated prior the active depsgraph.

There is no user level changes changes expected with the CoW handling changes:
should not affect on neither performance, nor memory consumption.

Tested scenarios:

- Various modifiers configurations of objects sharing mesh and be part of the
  same scene.

- Steps from the reports: T93855, T82952, T77359

This also fixes T76609, T72733 and perhaps other reports.

Differential Revision: https://developer.blender.org/D13824
2022-01-25 14:32:23 +01:00
c5980ada4f GPU: Add GPU_shader_create_from_info_name
This function will be used as the way to build shaders from
create_infos. The previous used method was using a private function.
2022-01-25 14:22:44 +01:00
Kevin C. Burke
17b0c06946 Animation: Equalize Handle Operator
The Equalize Handles operator allows users to make selected handle
lengths uniform: either respecting their original angle from the key
control point or by flattening their angle (removing the overshoot
sometimes produced by certain handle types).

Design: T94172

Reviewed by: sybren

Differential Revision: https://developer.blender.org/D13702
2022-01-25 11:41:40 +01:00
a000de7c2a CMake/Linux: find Brotli library the proper way
Use a `FindBrotli.cmake` module instead of manually appending library
paths.

This is just for Linux; Windows and macOS will be reviewed separately.
2022-01-25 11:34:13 +01:00
a54142f3f1 Cleanup: Replace reinterp cast with static cast.
Conversion of void* should not use the unsafe reinterp cast.
2022-01-25 10:18:32 +01:00
1b1693d43f Fix (unreported) RNA setter for TextEditor's text ID pointer not ensuring real user. 2022-01-25 09:12:13 +01:00
2e9b8689e4 Fix T95037: Allow making local IDs that are not used by anything.
Some IDs (like text ones) can be linked and only kept around thanks to
editors, allow making such IDs local in `BKE_lib_id_make_local_generic`.

Also refactor logic checking whether ID should be made directly local or
copied into its own util function, so that we can remain sure all
special-cases 'make local' code still uses the same logic here.
2022-01-25 09:12:13 +01:00
a2301b1d91 Geometry Nodes: Add description to curve handle input node
The "Relative" input isn't immediately obvious unless one is familar
with that naming pattern, so an explicit description may be helpful.
2022-01-25 00:04:33 -06:00
114b06b3cb Cleanup: Remove unused pixel buffer in read_render_tile
A left over remnant from rB1a134c4c30a643ada1b9a7a037040b5f5c173a28

Differential Revision: https://developer.blender.org/D13901
2022-01-24 20:53:19 -08:00
2bf519d211 Cleanup: Correct location of node function declarations
Currently there are many function declarations in `BKE_node.h` that
don't actually have implementations in blenkernel. This commit moves
the declarations to `NOD_composite.h`, `NOD_texture.h`, and
`NOD_shader.h` instead. This helps to clarify the purpose of the
different modules.

Differential Revision: https://developer.blender.org/D13869
2022-01-24 16:18:30 -06:00
4d799db72f LShaderInterface: Fix interface binding with UBO containing arrays
To avoid the issue we search using the name in the `name_buffer_` which
already have the array suffix stripped out.
2022-01-24 21:25:53 +01:00
5a0c5912a4 Tests: Enable new tests for geometry nodes extrude node
rB95981c9876483256b28
2022-01-24 13:55:32 -06:00
083de503ce GLShaderInterface: Fix interface from createInfo not setting bindings
This is because the `glUniform1i` calls were not preceeded by `glUseProgram`
which made parameters not stick.
2022-01-24 20:26:33 +01:00
04c3b08518 Fix T94355: Cycles wrong GPU bake with adaptive sampling 2022-01-24 19:18:11 +01:00
263f862ba5 Add workaround for broken interface query functions on Intel HD Graphics 4400 and 4600
Fixes T93680

For current drivers of Intel HD Graphics 4400 and 4600, various Program Introspection functions appear broken and return incorrect values, causing crashes in the current handling of SSBOs. Disable use of this feature on those devices. Add checks to features that use SSBOs (Hair and Subdivision Modifier).

Reviewed By: fclem, jbakker

Maniphest Tasks: T93680

Differential Revision: https://developer.blender.org/D13806
2022-01-24 18:48:16 +01:00
e2337b5342 GPU subdiv: reduce memory usage for point IBO
The point IBO should only have data for coarse vertices (or in general,
the vertices in the original mesh). As it used for displaying the
vertices for selection in edit mode, and as it indexes into the VBOs for
the positions and edit data, it is itself only indexed by coarse/
original vertex index.

For the subdivision case, this would allocate space for the final
subdivision vertex and reallocate to make room for loose geometry,
although only the first coarse vertex count amount of data would be.

Now just allocate for the required memory. Also reuse index buffer APIs
instead of doing manual work.
2022-01-24 18:42:37 +01:00
90d61600fc GPU subdiv: fix unitialized data 2022-01-24 18:27:05 +01:00
Jens Ehrhardt
e673cfc2d7 Fix T95099: Have launcher wait for Blender exit
unity launches blender in background mode to do some
file conversions, ever since the launcher got introduced
this process broke.

The root cause here is: Unity looks up the default program
to launch .blend files with, which is now the launcher, then
launches it in background mode with a script to export the data.

The launcher however was designed to exit as quickly as
possible so there would not be an extra background process
lingering. It does not wait for blender to exit and does not
pass back any error codes.

This broke unity's workflow since it assumed if the process
exits and succeeds the data *must* be ready for reading which
no longer holds true.

This change keeps the launcher design as was previously,
*except* when launching in background mode, then it
waits and passes back any error codes, thus restoring
unity's workflow.

Differential Revision: https://developer.blender.org/D13894
Reviewed by: LazyDodo, Brecht
2022-01-24 08:43:38 -07:00
25fa5792e6 Cleanup: Move the "toggle smooth brush" functionality to functions
This is so it will be easier to keep the logic to toggle on/off in sync
because they are declared close to eachother.
2022-01-24 16:00:01 +01:00
a215d7e230 Hook up invert and smooth mode to weight and vertex paint
Previously weight paint wasn't hooked up to the "Smooth" and "Invert" modes.
With this patch it is not possible to use the "Smooth" and "Invert"
modifiers for the draw keybindings.

Reviewed By: Campbell Barton

Differential Revision: http://developer.blender.org/D13857
2022-01-24 16:00:01 +01:00
0928fe8710 Fix T94651: Cycles error with pointcloud vector attribute 2022-01-24 15:58:32 +01:00
4c617c06e9 Linux/CMake: link libbbrotli*.a along with new FreeType
Add `libbrotlidec-static.a` and `libbrotlicommon-static.a` to the CMake
`$FREETYPE_LIBRARIES` variable; they'll be required when the Linux libs
for the FreeType upgrade lands (D13448).

The order of libraries is different compared to the similar lines in the
Windows and Apple CMake files, to prevent linker errors on Linux.
2022-01-24 15:44:03 +01:00
796ef560b4 Fix Image.gl_touch not loading image.
Same fix as for {rBc09f61a9157ddee0e186db52fb7ac0f4cdae09da}
2022-01-24 15:32:04 +01:00
578baf95e0 Cleanup: Remove unused enum
The `SCULPT_TRANSFORM_DISPLACEMENT_INCREMENTAL` value is not actually
being used.

Keeping it in the code only complicates its readability.
2022-01-24 10:18:34 -03:00
e774f2c901 GPUShaderCreateInfo: Add manual validation of bindpoints
Some drivers/glsl compilers will not warn about multiple resources using
the same binding, creating silent errors.

This patch checks for this case and outputs a descriptive error message if
a particular createInfo merge error is founds.

Other validation can be added later.
2022-01-24 13:28:33 +01:00
7708a848c9 Cleanup: sort cmake file lists 2022-01-24 21:23:30 +11:00
4b1f243e4d Cleanup: sort struct forward declarations 2022-01-24 21:16:06 +11:00
f9b6a257bd Cleanup: clang-format 2022-01-24 21:15:25 +11:00
95981c9876 Geometry Nodes: Extrude Mesh Node
This patch introduces an extrude node with three modes. The vertex mode
is quite simple, and just attaches new edges to the selected vertices.
The edge mode attaches new faces to the selected edges. The faces mode
extrudes patches of selected faces, or each selected face individually,
depending on the "Individual" boolean input.

The default value of the "Offset" input is the mesh's normals, which
can be scaled with the "Offset Scale" input.

**Attribute Propagation**
Attributes are transferred to the new elements with specific rules.
Attributes will never change domains for interpolations. Generally
boolean attributes are propagated with "or", meaning any connected
"true" value that is mixed in for other types will cause the new value
to be "true" as well. The `"id"` attribute does not have any special
handling currently.

Vertex Mode
 - Vertex: Copied values of selected vertices.
 - Edge: Averaged values of selected edges. For booleans, edges are
   selected if any connected edges are selected.
Edge Mode
 - Vertex: Copied values of extruded vertices.
 - Connecting edges (vertical): Average values of connected extruded
   edges. For booleans, the edges are selected if any connected
   extruded edges are selected.
 - Duplicate edges: Copied values of selected edges.
 - Face: Averaged values of all faces connected to the selected edge.
   For booleans, faces are selected if any connected original faces
   are selected.
 - Corner: Averaged values of corresponding corners in all faces
   connected to selected edges. For booleans, corners are selected
   if one of those corners are selected.
Face Mode
 - Vertex: Copied values of extruded vertices.
 - Connecting edges (vertical): Average values of connected selected
   edges, not including the edges "on top" of extruded regions.
   For booleans, edges are selected when any connected extruded edges
   were selected.
 - Duplicate edges: Copied values of extruded edges.
 - Face: Copied values of the corresponding selected faces.
 - Corner: Copied values of corresponding corners in selected faces.
Individual Face Mode
 - Vertex: Copied values of extruded vertices.
 - Connecting edges (vertical): Average values of the two neighboring
   edges on each extruded face. For booleans, edges are selected
   when at least one neighbor on the extruded face was selected.
 - Duplicate edges: Copied values of extruded edges.
 - Face: Copied values of the corresponding selected faces.
 - Corner: Copied values of corresponding corners in selected faces.

**Differences from edit mode**
In face mode (non-individual), the behavior can be different than the
extrude tools in edit mode-- this node doesn't handle keeping the back-
faces around in the cases that the edit mode tools do. The planned
"Solidify" node will handle that use case instead. Keeping this node
simpler and faster is preferable at this point, especially because that
sort of "smart" behavior is not that predictable and makes less sense
in a procedural context.

In the future, an "Even Offset" option could be added to this node
hopefully fairly simply. For now it is left out in order to keep
the patch simpler.

**Implementation**
For the implementation, the `Mesh` data structure is used directly
rather than converting to `BMesh` and back like D12224. This optimizes
for large extrusion operations rather than many sequential extrusions.
While this is potentially more verbose, it has some important benefits:
First, there is no conversion to and from `BMesh`. The code only has
to fill arrays and it can do that all at once, making each component of
the algorithm much easier to optimize. It also makes the attribute
interpolation more explicit, and likely faster. Only limited topology
maps must be created in most cases.

While there are some necessary loops and allocations with the size of
the entire mesh, I tried to keep everything I could on the order of the
size of the selection rather than the size of the mesh. In that respect,
the individual faces mode is the best, since there is no topology
information necessary, and the amount of work just depends on the size
of the selection.

Modifying an existing mesh instead of generating a new one was a bit
of a toss-up, but has a few potential benefits:
 - Avoids manually copying over attribute data for original elements.
 - Avoids some overhead of creating a new mesh.
 - Can potentially take advantage of future ammortized mesh growth.
This could be changed easily if it turns out to be the wrong choice.

Differential Revision: https://developer.blender.org/D13709
2022-01-23 22:42:49 -06:00
46475b8e11 Cleanup: Grammar: its self vs. itself 2022-01-23 22:34:56 -06:00
43e3a33082 Cleanup: spelling in comments 2022-01-24 14:35:23 +11:00
c69a581c0b Cleanup: avoid positional struct initialization
When moving to C++ field for initialization was removed.
Favor assignments to field names as it reads better and avoids bugs if
files are ever re-arranged as well as mistakes (see T94784).

Note that the generated optimized output is identical with GCC11.
2022-01-24 14:27:16 +11:00
abf30007ab Geometry Nodes: Triangulate Node - Add Selection Input
This adds a selection field input to the node, faces that are selected and
meet the minimum vertex count threshold will be triangulated.

Differential Revision: https://developer.blender.org/D13804
2022-01-23 13:27:53 -06:00
38c7378949 Geometry Nodes: Relative Handle Position Mode
Add a boolean option to have the Curve Handle Position input node return the
position of the handle relative to each point position.

Differential Revision: https://developer.blender.org/D12947
2022-01-23 12:29:37 -06:00
807c58aae4 Cleanup: separate function for Alembic edge crease reading 2022-01-23 16:35:11 +01:00
889712927f Fix Cycles crash collecting render stats 2022-01-23 16:30:57 +01:00
5c4a5fd40d Cleanup: Improvements to mesh to bmesh conversion
- Use `Array` and `Span` instead of raw pointers.
- Declare variables in smaller scope.
- Use references instead of pointers.
2022-01-22 18:09:30 -06:00
6cd977b903 Fix T94760: Crash building BMesh when opening file
A large polygon in the file from the report caused `alloca`
to exceed the maximum stack size, causing a crash.  Instead
of using `alloca`, use `blender::Array` with an inline buffer.

Based on a patch by Germano Cavalcante (@mano-wii).

Differential Revision: https://developer.blender.org/D13898
2022-01-22 13:06:15 -06:00
dde997086c LineArt: Option to keep contour when using face mark filtering.
When enabled, it will keep contour around the object instead of hide them by rule of face mark,
so the object can always have full contour while filtering out some of the feature lines inside certain regions.

Reviewed By: Antonio Vazquez (antoniov), Aleš Jelovčan (frogstomp)

Differential Revision: https://developer.blender.org/D13847
2022-01-22 16:57:25 +08:00
579e8ebe79 LineArt: Back face culling
Option to discard back faced triangles, this speeds up calculation especially for when you only want to show visible feature lines.

Reviewed By: Antonio Vazquez (antoniov), Aleš Jelovčan (frogstomp)

Differential Revision: https://developer.blender.org/D13848
2022-01-22 16:41:08 +08:00
5ae76fae90 LineArt: Noise tolerant chaining.
Instead of splitting it at each occlusion change, it tolerates short segments of "zig-zag" occlusion incoherence and doesn't split the chain at these points, thus creating a much smoother result.

Reviewed By: Antonio Vazquez (antoniov), Aleš Jelovčan (frogstomp)

Differential Revision: https://developer.blender.org/D13851
2022-01-22 16:13:44 +08:00
e88d966737 BMesh: merge normal and tessellation calculation on undo
This gives a modest speedup as calculating tessellation and face
normals at the same time can be more efficiently multi-threaded.

Also avoids calculating face normals twice,
oversight in d590e223da.
2022-01-22 18:02:12 +11:00
25c99e72cd Fix linking in debug mode
b7878a4d45 seems to have caused linking
issues building debug mode on Linux.

Using extern "C" resolves.
2022-01-22 17:59:09 +11:00
b7878a4d45 Cleanup: Move bmesh_mesh_convert.c to C++
Useful for a simpler bug fix, code clarity,
and easier possible optimizations in the future.
2022-01-21 23:53:15 -06:00
Aras Pranckevicius
9350005d8b Fix T13879 new OBJ exporter not saving files with Unicode characters.
Need to use BLI_fopen instead of fopen.
2022-01-21 20:14:01 -05:00
1f026a3db9 Cleanup: Use references, const variables 2022-01-21 18:20:07 -06:00
Laurynas Duburas
45d038181a Curves: Improve accuracy and clarity of NURBS knots calculation
This commit improves NURBS knot generation by adding proper support
for the combination of the Bezier and cyclic options. In other cases
the resulting knot doesn't change. This cyclic Bezier knot is used to
create accurate accurate "Nurbs Circle", "Nurbs Cylinder" primitives.
"Nurbs Sphere" and "Nurbs Torus" primitives are also improved by
tweaking the spin operator.

The knot vector in 3rd order NURBS curve with Bezier option turned on
(without cyclic) is changed in comparison to previous calculations,
although it doesn't change the curve shape itself.

The accuracy of the of NURBS circle is fixed, which can be checked by
comparing with mesh circle. Tessellation spacing differences in
circular NURBS is also fixed, which is observable with the NURBS
cylinder and sphere primitives. These were causing seam-like effects.

This commit contains comments from Piotr Makal (@pmakal).

Differential Revision: https://developer.blender.org/D11664
2022-01-21 16:40:49 -06:00
d590e223da Fix T94974: Invalid normals in edit mode
Normal layers currently aren't stored in the undo step
mesh storage, since they are not stored in files at all.
However, the edit mesh expects normals to be fully
calculated, and does not keep track of a dirty state.
This patch updates the normals in the BMesh created
by loading an undo step.

Another option would be calculating the normals on
the undo mesh first, which might be better if Mesh
normal calculation is faster than BMesh calculation,
but the preferred method to access vertex normals fails
in this case, because the mesh runtime mutexes are not
initialized for undo-state meshes.

Differential Revision: https://developer.blender.org/D13859
2022-01-21 16:14:00 -06:00
68aa35ae74 Fix T94967: Sculpt mode crashes with missing normals
From an error in rBcfa53e0fbeed, the vertex normals in `SculptSession`
seem to be used, but in the case when no "pbvh" is used, the value of
the pointer is never assigned.

Normals were not generally dirty before this "ensure" function with
regular sculpting operations, so this addition shouldn't have any cost.

Differential Revision: https://developer.blender.org/D13854
2022-01-21 16:12:12 -06:00
294ab84909 Fix T95097: Attribute Capture node UI inconsistency
All other nodes with data type and domain choices have the domain
below the data type. Generally that order makes sense, because it's
consistent with nodes that have no domain drop-down.
2022-01-21 16:08:21 -06:00
1c23a06706 Fix: Applying object transform can create normal layers
Because this operator is used on original objects, it's best to tag
the normals dirty instead of explicitly calculating them, to avoid
unnecessarily storing normal layers on an original object (since
they might have to be recalculated during evaluation anyway).
There may be other places this change is helpful, but being
conservative is likely better for now.

Related to T95125
2022-01-21 16:04:16 -06:00
e07b217669 Build: update macOS for FreeType library with woff2 support
Ref D13448, T93161
2022-01-21 21:36:00 +01:00
32ceb0b807 Fix std::optional value() build error on older macOS SDK
No longer happens on the buildbot, but for users building with an older
Xcode we still need to avoid using value().
2022-01-21 21:36:00 +01:00
4f9be46526 Distribute Points on Faces: Fix missing minimum value for density socket
Negative number density is not a part of this reality.
2022-01-21 15:31:51 -05:00
54d69a2fd1 Fix new OBJ exporter to handle instancing.
The new OBJ exporter did not handle object instances.
The fix is to use a dependency graph iterator, asking for instances.
Unfortunately that iterator makes a temporary copy of instance objects
that does not persist past the iteration, but we need to save all the
objects and meshes to write later, so the Object has to be copied now.

This changed some unit tests. Even though the tests don't have instancing,
the iterator also picks up some Text objects as Mesh ones (which is a good
thing), resulting in two more objects in the all_objects.obj file output.
2022-01-21 14:37:33 -05:00
9d274a609c cmake/win: Platform update for freetype 2.11.0
freetype now depends on brotli
2022-01-21 11:40:53 -07:00
58f8eb54a3 deps/win: fix typo in brotli.cmake
it was harvesting to the zstd folder which
is not where these libs ought to be.
2022-01-21 11:36:56 -07:00
RUben
5b90c046d5 Fix: Object selection delay with many objects
With object collection properties open there was a huge delay when
switching active objects in a large scene, (~10k objects, ~5m vertices).
This is due to a non-optimal function to query all the collections the object is in.

To solve this the code can be simplified by using `bpy.types.Object.users_collection`
This returns all the collections the object is in removing the need to compute this in python.
2022-01-21 13:13:04 -05:00
c20f209b1c Cmake/Deps: Freetype 2.11.0 / brotli 1.0.9
The UI team requested adding woff2 support to freetype.
this required a new dependency brotli.

This changes adds brotili to the builder and bumps
freetype to version 2.11.0

As freetype now depends on other libraries, for consistency
all use of ${FREETYPE_LIBRARY} in cmake has been updated to
use ${FREETYPE_LIBRARIES} adjustments have been made in the
windows platform file, all other platforms use cmake's
FindFreeType.cmake which already sets this variable.

reviewed by: brecht

Differential Revision: https://developer.blender.org/D13448
2022-01-21 10:26:05 -07:00
59fc95bf97 UI: Clarify Active Movie Clip tooltip
See T92299
2022-01-21 12:02:34 -05:00
d034b85f33 Geometry Nodes: new Scale Elements nodes
This node can scale individual edges and faces. When multiple selected
faces/edges share the same vertices, they are scaled together.
The center and scaling factor is averaged in this case.

For some examples see D13757.

Differential Revision: https://developer.blender.org/D13757
2022-01-21 17:34:47 +01:00
Alan Babu
c39d514a4e Geometry Nodes: Flip Faces Node
Currently there is no way to flip normals in geometry nodes. This node
makes that possible by flipping the winding order of selected faces.
The node is purposely not called "Flip Normals", because normals are
derived data, changing them is only a side effect. The real change is
that the vertex and edge indices in the face corners of every selected
polygon are reversed, and face corner attribute data is reversed.

While there are existing utilities to flip a polygon and its custom
data, this node aims to process an attribute's data together instead
of processing all attributes separately for each index.

Differential Revision: https://developer.blender.org/D13809
2022-01-21 09:26:40 -06:00
4251455dcd Geometry Nodes: Mesh Island Node - Rename Index Socket
Rename 'Index' Socket to 'Island Index' to make it more consistent with
'Island Count'

Differential Revision: https://developer.blender.org/D13893
2022-01-21 09:01:18 -06:00
87c5423c5e Geometry Nodes: New Output for Number of Mesh Islands
Adds a second output to the Mesh Islands node that shows the total
number of islands as a field.

Differential Revision: https://developer.blender.org/D13700
2022-01-21 08:30:02 -06:00
Brecht Van Lommel
d68ce0e475 Cycles: add pointcloud implementation for Metal RT
This is not currently working, with an internal compiler error. However
we are currently using BVH2 instead of Metal RT. So this has no effect for
users, it's being committed to avoid the code getting outdated.

Ref T92573, T92212

Differential Revision: https://developer.blender.org/D13632
2022-01-21 14:42:27 +01:00
5e51a5e8a4 Fix error in previous commit. 2022-01-21 14:35:27 +01:00
93065a67c6 GPU: Disable create info for 2d image overlay merge.
This shader needs to use the same interface as the OCIO shader. On Linux
and Windows this seems to be the case. On MacOS however there is a
mismatch that makes the overlay texture to be completely black when
switching to workbench in the Shader workspace.

This is just a temporarily work-around as this should be solved. Due to
the poor GPU debugging facilities on Mac we haven't been able to
pin-point the root cause.
2022-01-21 14:24:30 +01:00
f6888b530a Attributes: add operator to convert generic attributes to other types
Editing of generic attributes on the original objects in edit modes is
still very limited. However, when applying a geometry nodes modifier
that generates new attributes. These attributes will show up in the
Attributes panel.

Currently, our exporters are not capable of exporting generic attributes.
Therefore, for the time being, a work around is to apply geometry nodes
and then convert a generic attribute to a task specific attribute like a
uv map, vertex group or vertex color layer. Once more parts of Blender
support generic attributes, this will become less important.

Currently, only meshes are supported by the operator. However, it would
be relatively easy to extend it to other geometry types.

Differential Revision: https://developer.blender.org/D13838
2022-01-21 12:47:35 +01:00
36c40760a5 .obj: simplify templates in FileHandler, add comments
- Remove redundant template from `FormattingSyntax`.
- Replace one enable_if with static assert for readability
- Add comments

No functional change expected.

Reviewed by: jacqueslucke
Differential Revision: https://developer.blender.org/D13882
2022-01-21 15:28:04 +05:30
23fa5bb723 GPU: Remove unused resources in shader create info.
When adding the shader create infos some additional resources where defined
that doesn't exist in the shader itself. This commit will remove them.
2022-01-21 09:58:58 +01:00
64196a6b29 Cleanup: struct/class mismatch. 2022-01-21 07:52:10 +01:00
872dc1038c UI: exclude "Undo History" from menu search
Undo history was showing in menu search since converting undo history to
a menu from a popup, see: 0e1bb232e6.
2022-01-21 16:30:11 +11:00
53923f502d Fix T95078: Setting digits as modifier in keymap doesn't work
Allow any non-modifier keyboard events to be used.

Note that the existing check for >= EVT_AKEY allowed NDOF and other
non-keyboard events (including modifiers, which didn't work).
2022-01-21 15:20:02 +11:00
20655128c9 Cleanup: event type values & defines
- Use defines instead of magic numbers for F-Key & NDOF range checks.
- Use explicit values for NDOF event types.
- Minor clarification to doc-strings.
- Use doxy-sections.
2022-01-21 15:19:00 +11:00
5fca280c80 Fix: Node link drag search doesn't list shader sockets
Shader sockets were only available when dragging from inputs.
2022-01-20 16:26:43 -06:00
1ac2d2dcb6 Fix T93711: Cycles diffuse/glossy baking does not write alpha
With the change to use render passes internally the alpha channel got lost.
Add support for these render passes to output an alpha channel for baking.
2022-01-20 22:32:35 +01:00
14d261d23a Cleanup: Resolve unused variable warning, make function static 2022-01-20 15:10:56 -06:00
9ca1052226 Fix Python API docs build error
There is probably a better solution that's possible, but the few other
things I tried didn't work, and the build error should be resolved for
the buildbots. This is similar to the "breaks" in the namespace for
functions declared in `ED_node.h`.
2022-01-20 15:10:28 -06:00
4369c5817a Fix T94457: random result using sky texture in light object
Still not well defined, but should not longer use uninitialized values that
gave different results between CPU/GPU and subsequent renders.
2022-01-20 21:28:41 +01:00
22a8e934e4 Fix T94698: artifacts in light passes with mixed volumes and surfaces 2022-01-20 20:55:43 +01:00
e1ae95f6b2 Fix T93520: wrong subframe motion blur with rigid body physics
The code here was using velocity based interpolation copied from particles.
However there is no velocity cached in the rigid body point cache so the
results were non-sensical.
2022-01-20 20:40:55 +01:00
24e00c115c Fix T94712: Cycles missing colorspace transform on grayscale images 2022-01-20 20:40:55 +01:00
2559d79d2f Fix T94582: Cycles mapping shader node incorrectly skipped in Normal mode
Even if no rotation or scale is specified, we must still always normalize
the output.
2022-01-20 20:40:55 +01:00
Charlie Jolly
cc1a48e395 Geometry Nodes: Curve Primitive Arc
This adds a new curve primitive to generate arcs.

Radius mode (default): Generates a fixed radius arc on XY plane
with controls for Angle, Sweep and Invert.

Points mode: Generates a three point curve arc from Start to End
via Middle with an Angle Offset and option to invert the arc.
There are also outputs for arc center, radius and normal direction
relative to the Z-axis.

This patch is based on previous patches
D11713 and D13100 from @guitargeek. Thank you.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13640
2022-01-20 19:04:09 +00:00
6baccc36a0 Fix continuous stream of thumbnail notifiers after redo
This fixes a similar issue as the previous commit, but this time the
continuous notifiers would be sent after redoing. E.g. after moving an
object, and then modifying the transform in the "Adjust Last Operation"
panel.
2022-01-20 18:51:49 +01:00
d552b3c0c0 Fix file/asset thumbnails causing constant stream of notifiers
The thumbnail caching continuously sends `ND_SPACE_FILE_PREVIEW`
notifiers via a timer. But this timer was never ended properly after
thumbnails are fully loaded into the cache.
Wouldn't actually cause a refresh or redraw, send and process the
notifiers.

I already tried to avoid this for the asset view template, but
apparently that wasn't working correctly. For the File/Asset Browser I
never applied that fix to avoid possible regressions before the release.
2022-01-20 18:51:49 +01:00
902a103f80 Cleanup: Move node editor files to proper namespace
This commit moves code in all node editor files to the
`blender::ed::space_node` namespace, except for C API
functions defined in `ED_node.h`, which can only be moved
once all areas calling them are moved to C++.

The change is fairly straightforward, I just moved a couple
of "ED_" code blocks around to make the namespace more
contiguous, and there's the method for adding a pointer to
a struct in a C++ namespace in DNA.

Differential Revision: https://developer.blender.org/D13871
2022-01-20 10:36:56 -06:00
19622ffc5b Cleanup: Remove OpenCL workaround in volume_sample_channel(). 2022-01-20 17:02:20 +01:00
f6c8a78ac6 Cycles: Fix bvh2 gen on Apple Silicon and use it to speed up renders
This patch fixes a correctness issue discovered in the `int4 select(...)` function on Apple Silicon machines, which causes bad bvh2 builds. Although the generated bvh2s give correct renders, the resulting runtime performance is terrible. This fix allows us to switch over to bvh2 on Apple Silicon giving a significant performance uplift for many of the standard benchmarking assets. It also fixes some unit test failures stemming from the use of MetalRT, and trivially enables the new pointcloud primitive.

Ref T92212

Reviewed By: brecht

Maniphest Tasks: T92212

Differential Revision: https://developer.blender.org/D13877
2022-01-20 15:37:49 +00:00
9315215b20 Fix T94726: crash with GPU subdivision on a custom bone shape
Custom bones are drawn by instancing the GPUBatch of the base object. To
access the mesh and its GPUBatch, `BKE_object_get_evaluated_mesh` was
used. However, since GPU subdivision support, this will return a
subdivision wrapper which will never be drawn, and thus will have an
invalid batch, which caused the crash.

`BKE_object_get_evaluated_mesh_no_subsurf` should be used instead, to
return the mesh that will be drawn, and have the subdivision evaluated
on the GPU. Note that the rest of the draw code is already using this
function.
2022-01-20 15:28:08 +01:00
264fe10ddd Cleanup: Remove unused python helper function.
Branched Path has been removed with the Cycles X merge.
2022-01-20 14:34:20 +01:00
969a571e0f Revert "Sculpt: Multires Heal Brush"
This reverts commit ae349eb2d5.
2022-01-20 03:55:41 -08:00
4425e0cd64 Subdivision: add support for vertex creasing
This adds vertex creasing support for OpenSubDiv for modeling, rendering,
Alembic and USD I/O.

For modeling, vertex creasing follows the edge creasing implementation with an
operator accessible through the Vertex menu in Edit Mode, and some parameter in
the properties panel. The option in the Subsurf and Multires to use edge
creasing also affects vertex creasing.

The vertex crease data is stored as a CustomData layer, unlike edge creases
which for now are stored in `MEdge`, but will in the future also be moved to
a `CustomData` layer. See comments for details on the difference in behavior
for the `CD_CREASE` layer between egdes and vertices.

For Cycles this adds sockets on the Mesh node to hold data about which vertices
are creased (one socket for the indices, one for the weigths).

Viewport rendering of vertex creasing reuses the same color scheme as for edges
and creased vertices are drawn bigger than uncreased vertices.

For Alembic and USD, vertex crease support follows the edge crease
implementation, they are always read, but only exported if a `Subsurf` modifier
is present on the Mesh.

Reviewed By: brecht, fclem, sergey, sybren, campbellbarton

Differential Revision: https://developer.blender.org/D10145
2022-01-20 12:21:34 +01:00
9b4c017031 Cleanup: Remove incorrect comment 2022-01-19 23:56:27 -06:00
ae349eb2d5 Sculpt: Multires Heal Brush
This brush fixes the random spikes that
occasionally happen in multires models.
These spikes can be nearly impossible to
fix manually and can make working with
multires a nightmare.
2022-01-19 17:28:22 -08:00
eb3ff1d6f9 Cleanup: spelling in comments 2022-01-20 11:59:20 +11:00
1d536c21dd Cleanup: clang-format 2022-01-20 11:59:20 +11:00
e3f9d9b206 Cleanup: quiet ASAN warnings for divide by zero & NULL memcpy args
No functional changes as the inf value was never used &
memcpy args were only NULL when the size to copy was zero.
2022-01-20 11:59:20 +11:00
b7fe27314b Mesh RNA API: Expose contiguous normal arrays
Since vertex and face normals are now stored on the mesh when necessary,
we can expose them as contiguous arrays of vectors in the Python API.
This can give render engines and other addons easy access to they data
for fast access through a regular collection property.

While "Mesh Vertex" still has a "normal" property in RNA, that is only
maintained in order to avoid breaking the existing API, and accessing
it is less efficient than accessing the normals directly.

I made the normal arrays read-only, because modifying them could
put them in an invalid state. This is inline with how we treat the data
internally, and helps keep relationships between data clear.

Differential Revision: https://developer.blender.org/D13839
2022-01-19 18:43:05 -06:00
b47a1867e8 Cleanup doc comments for sculpt_intern.h 2022-01-19 16:21:14 -08:00
e7db1247b1 Fix: File Browser using asset indexer after Asset Browser was visible
When toggling to a File Browser from an Asset Browesr, the asset indexer
would be used to load files. I couldn't spot issues with that on a
quick look, but this should still be corrected.
2022-01-19 20:43:31 +01:00
293aab2253 Asset Browser: Add debug option to disable asset indexing
Adds an "Asset Indexing" option (enabled by default) to Preferences >
Experimental > Debugging. This is useful when working on the asset
library loading.
2022-01-19 20:12:53 +01:00
9a2d1cd5b7 PyAPI Docs: Prepare for Sphinx 4.5 2022-01-19 14:08:38 -05:00
cd0acba330 CMake: Support external callback in configuration
An external CMake script can be used to debug CMake code, modify/read
target properties, inter-target dependencies, non-cache variables etc.

Reviewed by: LazyDodo, brecht
Differential Revision: https://developer.blender.org/D13830
2022-01-20 00:15:09 +05:30
17cab47ed1 Cycles: Fix T94736: Crash when modifying strength of world environment texture
This patch fixes crash T94736 on Metal in which the launch_params were not being updated to reflect destruction of MetalMem objects.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13875
2022-01-19 18:17:37 +00:00
596ce11556 CMake Cleanup: use set for filepath instead of option
See https://developer.blender.org/D13830#368219
2022-01-19 23:34:25 +05:30
f179637222 Fix T95042: Rendering high-res image in Cycles crashes
Integer overflow when the final frame is handled by the Blender's
output driver.

Thanks Jesse and Thomas for investigation!
2022-01-19 16:03:28 +01:00
ecf2f5ed01 Fix error in previous commit
While doing last minute cleanup in
e49bf4019b,  missed to rename function
in one place.
2022-01-19 14:32:11 +01:00
eddad4e9a1 VSE: Support copy-pasting strips with animation
When copying strips between 2 scenes, it wasn't possible to copy
animation curves along with strips.

In this patch curves are copied into clipboard `ListBase`. When pasted,
original curves are moved into temporary `ListBase` and curves in
clipboard are moved into scene action. This is because when strips from
clipboard have to be renamed, function `SEQ_ensure_unique_name()` does
fix RNA paths of curves, but this is done globally for all curves within
action. After strips are renamed, restore original curves from backup.

Note: This patch handles only fcurves. Drivers and actions are currently
not handled anywhere in VSE.

Fixes T77530

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13845
2022-01-19 14:15:49 +01:00
e49bf4019b Cleanup: VSE animation handling
- Move functions that handle animation to own file - `animation.c`
- Refactor `SEQ_offset_animdata` and `SEQ_free_animdata` functions
- Add function `SEQ_fcurves_by_strip_get` to provide more granular
  and explicit way for operators to handle animation
- Remove function `SEQ_dupe_animdata`, do curve duplication explicitly
  in operator code, which makes more sense to do. Further this function
  was also used for renaming strips which makes no sense.
- Refactor usage of function `SEQ_free_animdata` and remove XXX comment.
  Now this functiuon is no longer called when `Sequence` data is freed
  implicitly, it is done explicitly in high level function
  `SEQ_edit_remove_flagged_sequences`

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13852
2022-01-19 14:12:23 +01:00
1788298804 Cleanup: Strict compiler warning in Cycles
The ustring is not a trivially copyable object from the C++ standard
point of view, so using memcpy on it is strictly wrong. In practice,
however, this is OK since it is just a thin wrapper around char*.

For now use explicit cast to void* same as it was done in other places
of ccl::array implementation. But also localize the place where memory
copy happens to make it easier to support proper non-trivial C++
objects in the future.
2022-01-19 12:01:49 +01:00
8a23d91a50 GPUShaderCreateInfo: Rework geometry shader layout support
This merge the description into one struct only that can be more easily
copied during `finalize()`.

The in and out layout parameters are better named and extended with the
invocation count (with fallback support)
2022-01-19 11:59:57 +01:00
952a4fa456 Fix T94987: Dragged node links are invisible.
Route cause was data alignment mismatch between GPU and CPU. This
mismatch would not allow us to bind the UBO where data wasn't available
on the GPU.

Fixed by using float4 in stead of float2. This could eventually be
packed, but that would lead to less readable code.
2022-01-19 11:32:34 +01:00
71386c08f1 Fix T95039,T94998: Shaders compilation errors on Mac.
Cause was incorrect logic when generating the resource layout. It the
explicit_location_support setting was ignored and the binding were
generated for image, uniform buffers and storage buffers.
2022-01-19 10:28:19 +01:00
eb63646605 BMesh: add mesh debug information printing
- Add BM_mesh_debug_print & BM_mesh_debug_info.
- Report flags in Mesh.cd_flag in BKE_mesh_debug_print
- Move custom data printing into customdata.cc (noted as a TODO).

Note that the term "runtime" has been removed from
`BKE_mesh_runtime_debug_print` since these are useful for debugging any
kind of mesh data.
2022-01-19 17:16:00 +11:00
71879d665d BMesh: improve handling of custom-data flag (Mesh.cd_flag)
Code that handled merging & initializing custom-data from other
meshes sometimes missed checks for this flag, causing bevel weights to
lost when the mesh was converted to a BMesh.

The following changes are a more general fix for T94197.

- Add BM_mesh_copy_init_customdata_from_mesh_array which initializes
  custom-data from multiple meshes at once.
  As well as initializing custom-data layers from Mesh.cd_flag.

  This isn't essential for boolean, however it avoids the overhead of
  resizing custom-data layers.

- Loading mesh data into a BMesh now respects Mesh.cd_flag
  instead of only checking if the BMesh custom-data-layer exists.
  Without this, the order of meshes passed to BM_mesh_bm_from_me could
  give different (incorrect) results.

- Copying mesh data now copies `cd_flag` too. This is a precaution
  as in my tests evaluating modifiers these values always matched.
  Nevertheless it's correct to copy this value as custom-data it's
  self is being copied.
2022-01-19 14:30:10 +11:00
ee6507f2b1 Docs: notes on thumbnail sizes
The rationale for storing thumbnails at different sizes wasn't obvious.
2022-01-19 14:05:56 +11:00
7e3b1e2c8f Fix flipped order of items in the "Undo History" menu
Error in 0e1bb232e6.
2022-01-19 13:25:10 +11:00
2e5aecf557 Fix T94202: GPUFrameBuffer: wrong refcount in the buffer passed for read_color and read_depth
The buffer passed as an argument to `GPUFrameBuffer.read_color` is used
in the return of the function and therefore, if not used, its refcount is
decremented.

So be sure to increment the refcount of the already existing objects that
will be used in the return of a function.
2022-01-18 19:23:16 -03:00
221ff895d9 Cleanup: Use references, LISTBASE_FOREACH macro 2022-01-18 13:32:36 -06:00
a5610da1d5 Fix T93413: Nodes 'Make Links' fails for multi input socket
This was the case for multi input sockets that have a link already.

Since we have multi input sockets, the way we use `socket_is_available`
is not really giving the expected result on these.

When used for input sockets the intention is to find a free socket
(either for noodle **replacement**, then it is always available, or just
the next free available socket).
Now I would think without the intention to replace an existing link, a
multi input socket should still be available.
From the inside of the function, the `replace` argument turns [namewise]
to `allow_used`, which sounds a little different (so one might argue
that if `allow_used` is `False` this should also trigger for already
connected multi input sockets).
In the end, this is an issue with the variable naming though, cant think
of a usecase where the patch change would really go against intentions.

Maniphest Tasks: T93413

Differential Revision: https://developer.blender.org/D13866
2022-01-18 20:23:39 +01:00
9506dcf675 Fix T95029: Arrow gizmo always uses normal direction
Bug possibly introduced in {rBc57e4418bb85aec8bd3615fd775b990badb43d30}.

Interestingly, the orientation set before (NORMAL), even different from
the orientation that was actually used, was allowing the use of
"orient_matrix" ("orient_matrix_type" should have been NORMAL in that
case too).

In any case, make sure the "orient_matrix_type" and "orient_type" are the
same so that the "orient_matrix" is used.
2022-01-18 16:21:48 -03:00
977baeaa26 Cleanup: Make node editor functions private
These operations (sorting and selecting all nodes) should generally
be handled by the node editor and not outside code. They were not
called outside of the node editor, so they can be moved to the editor's
`intern` header.
2022-01-18 13:07:41 -06:00
09ecb089a5 Cleanup: Remove unused node editor toolbar file
This file was added nine years ago, and was unused then.
Now with active tools we use a different approach to create
toolbars, so the file is not relevant.
2022-01-18 12:31:14 -06:00
15657b7ccd Fix warning from rB9925606539. 2022-01-18 18:38:14 +03:00
b88a37a490 Geometry Nodes: new Field at Index node
This node allows accessing data of other elements in the context geometry.
It is similar to the Transfer Attribute node in Index mode. The main difference
is that this node does not require a geometry input, because the context
is used.

The node can e.g. be used to generalize what the Edge Vertices node is doing.
Instead of only being able to get the position of the vertices of an edge,
any field/attribute can be accessed on the vertices.

Differential Revision: https://developer.blender.org/D13825
2022-01-18 16:25:47 +01:00
4d5c08b938 Geometry Nodes: Add Signed Output to Edge Angle Node
Adds a second output to the edge angle node that shows the signed angle
between the two faces, where Convex angles are positive and Concave angles
are negative. This calculation is slower than the unsigned angle, so it
was best to leave both for times where the unsigned angle will suffice.

Differential Revision: https://developer.blender.org/D13796
2022-01-18 09:20:31 -06:00
796e9d442c Geometry Nodes: improve domain interpolation code
It's now easier than before to do the interpolation of attributes
only for the elements that are actually used in some cases.
This can result in a speedup because unnecessary computations
can be avoided. See the patch for a simple performance test.

Differential Revision: https://developer.blender.org/D13828
2022-01-18 16:14:00 +01:00
dfe22a53bb Fix T95003: Shader issue using voronoi noise.
Cause of the issue isn't that clear, but the NVIDIA GLSL compiler
complained that it couldn't find an overloaded function when the second
parameter is an interger. This change fixes it by using a float.
2022-01-18 14:32:26 +01:00
0d7b3ed39c RNA: display exact integer values without fraction if step is integer.
Display exact integer values of a floating point fields without
a fraction if the step is also an exact integer. This is intended
for cases when the value can technically be fractional, but most
commonly is supposed to be integer.

This handling is not applied if the field has any unit except frames,
because integer values aren't special for quantities like length.

The fraction is discarded in the normal display mode and when copying
the value to clipboard, but not when editing to remind the user that
the field allows fractions.

Differential Revision: https://developer.blender.org/D13753
2022-01-18 16:24:54 +03:00
6952228386 UI: fix a precision issue with float field step size.
Fix a precision issue when stepping down from 1 to 0 via the left
decrement button and step 100 results in a small nonzero value.

The reason is that 0.01 can't be precisely represented in binary
and converting to double before multiplication reveals this.

Ref D13753
2022-01-18 16:24:54 +03:00
6a8ad00bcc Cleanup: Avoid possible NULL pointer error
In normal conditions, `gpf` always has a value, but better move inside the NULL checking.
2022-01-18 13:44:41 +01:00
08d008a508 GPU: Create Info for GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR.
This patch converts GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR shader to use
the GPUShaderCreateInfo pattern. It can be used as a reference when
converting other shaders.

In this special case the flat uniform vector cannot be used anymore as it
doesn't fit as push constants. To solve this a uniform buffer is used.
2022-01-18 13:17:04 +01:00
2486346f6f Fix T94977: muted link is not ignored in eevee
Add a preprocessing step that removes all muted links from
the localized node tree.

Differential Revision: https://developer.blender.org/D13864
2022-01-18 13:06:49 +01:00
9f8ae130af Fix T95006: missing modifier update after frame change
The previous optimization did not work in general yet, unfortunately.
This change makes the code more correct, but also brings back
some unnecessary updates (e.g. when creating a node group).
2022-01-18 12:58:29 +01:00
5d7ac749c5 Fix T94197: Applying boolean with fast solver clears bevel weights
For boolean operations only one of the meshes was checked to determine
if bevel weights should be created.

Now initialize custom data from both meshes flag.
Note that this is a localized fix to be back-ported, further changes
will be made so edit-mode conversion accounts for this
without the caller needing explicit checks for custom-data flags.
2022-01-18 21:35:10 +11:00
fce0b824a7 Assets: Enabling Asset Indexing.
Asset indexing was disabled as ID property indexing wasn't supported.
Now that ID property support is added we can enable asset indexing.

Check {T91406} for more information about asset indexing.
2022-01-18 11:20:50 +01:00
Jeroen Bakker
36068487d0 AssetsBrowser: Add ID Properties to Asset Indexer
Object/collection asset workflow would need the bounding box for snapping.
The bounding box is stored using ID properties in the scene. Currently ID properties
aren't stored in the asset index, what would break object snapping. For this reason
Asset Indexing is turned off in mater. This patch will introduce the indexing of ID
properties what will allow the indexing to be turned on again.

## Data Mapping ##

For data mapping we store the internal structure of IDProperty to the indexer (including meta-data) to be able to deserialize it back.
```
[
  {
    "name":  ..,
    "value": ..,
    "type": ..,
    /* `subtype` and `length` are only available for IDP_ARRAYs. */
    "subtype": ..,
  },
]
```

| **DNA** | **Serialize type** | **Note** |
| IDProperty.name | StringValue| |
| IDProperty.type | StringValue| "IDP_STRING", "IDP_INT", "IDP_FLOAT", "IDP_ARRAY", "IDP_GROUP", "IDP_DOUBLE"|
| IDProperty.subtype | StringValue| "IDP_INT", "IDP_FLOAT", "IDP_GROUP", "IDP_DOUBLE" |
| IDProperty.value | StringValue | When type is IDP_STRING |
| IDProperty.value | IntValue | When type is IDP_INT |
| IDProperty.value | DoubleValue | When type is IDP_FLOAT/IDP_DOUBLE |
| IDProperty.value | ArrayValue | When type is IDP_GROUP. Recursively uses the same structure as described in this section. |
| IDProperty.value | ArrayValue | When type is IDP_ARRAY. Each element holds a single element as described in this section. |

NOTE: IDP_ID and IDP_IDARRAY aren't supported. The entry will not be added.

Example
```
[
  {
    "name": "MyIntValue,
    "type": "IDP_INT",
    "value": 6,
  },
  {
    "name": "myComplexArray",
    "type": "IDP_ARRAY",
    "subtype": "IDP_GROUP",
    "value": [
        [
          {
            "name": ..
            ....
          }
        ]
    ]
  }
]
```

## Considered alternatives ##

- Add conversion functions inside `asset_indexer`; makes generic code part of a specific solution.
- Add conversion functions inside `BLI_serialize`; would add data transformation responsibilities inside a unit that is currently only responsible for formatting.
- Use direct mapping between IDP properties and Values; leads to missing information and edge cases (empty primitive arrays) that could not be de-serialized.

Reviewed By: Severin, mont29, HooglyBoogly

Maniphest Tasks: T92306

Differential Revision: https://developer.blender.org/D12990
2022-01-18 11:18:11 +01:00
d7822981b1 Python API Docs: add non-invert Bone.convert_local_to_pose example.
This updates the example function to support assigning a subset of
bone matrices. The code was tested to work in real use by @gaiaclary.
2022-01-18 11:45:27 +03:00
542d15b1cd Allow overriding motion path settings.
Motion paths themselves aren't getting saved (not sure if they are
without overrides), but being able to override options makes them
usable even if it's necessary to regenerate every edit session.

Differential Revision: https://developer.blender.org/D13842
2022-01-18 11:45:27 +03:00
1b94631975 CMake: Fix using numpy variable for the zstandard path
Copy paste error in a5917175d8.
2022-01-18 17:23:19 +11:00
6dd89afa96 Fix obj exporter tests by deduping normals and printing with less precision.
Some new obj exporter tests were disabled because the normals were different
in the last decimal place on different platforms.
The old python exporter deduped normals with their coordinates rounded to
four decimal places. This change does the same in the new exporter.
On one test, this produced a file 25% smaller and even ran 10% faster.
2022-01-17 23:22:40 -05:00
db496a0b7d Cleanup: spelling in comments 2022-01-18 14:27:29 +11:00
20df402adc Cleanup: move docs to definition 2022-01-18 14:13:58 +11:00
7220897280 WM: batch rename support for volume & light object data
Also order items to match the "Add" menu.
2022-01-18 12:23:15 +11:00
75d84b1b64 WM: batch rename outliner support for various ID types
The outliner selection can now be used for renaming objects,
object-data & materials.
2022-01-18 12:12:05 +11:00
0fc9526178 Fix for batch rename operating on library collections & materials 2022-01-18 11:50:02 +11:00
84f6d86445 Fix batch renaming selected meta-strips 2022-01-18 11:13:05 +11:00
c11c2a4b91 WM: batch rename collections outside the outliner
Use selected objects collection instances to rename in the 3D view.
2022-01-18 10:47:12 +11:00
Red Mser
54fb1a75ee WM: batch rename collections
User must activate the operator from the outliner,
so that the selected collections can be determined.

Reviewed By: campbellbarton

Ref D13821
2022-01-18 10:26:20 +11:00
0fa36c81d9 Cleanup: quite old-style-declaration warning, strip trailing space 2022-01-18 10:26:18 +11:00
3bbb39ecc1 Cleanup: remove HWND from GHOST_Wintab constructor.
No change in behavior.
2022-01-17 14:07:08 -08:00
44ca984dc7 BLI: Add index_range method to VectorSet
This can simplify iterating through all of the indices in the vector,
which is fairly common, since one of the benefits of the data structure
is that all values are contiguous.
2022-01-17 15:10:52 -06:00
8c1ddee10c Geometry Nodes: Set Handle Type Node: Left and right by default
This node's UI uses a multi-select enum to allow adjusting the
type of both handle sides with the same node. Since usually the
user wants to affect both handles, and it's the multi-select behavior
isn't obvious, selecting both by default is an improvement.
2022-01-17 15:02:15 -06:00
b776c46d2f Fix T94715: multiple volumes using the same .vdb causes freeze
Needs more TBB task isolation, as even freeing an OpenVDB grid uses
multithreading.
2022-01-17 20:36:59 +01:00
Martijn Versteegh
449db0ab1e Baking: new method to generate margin, based on adjacent faces
This significantly reduces discontinuities on UV seams, by giving a better
match of the texture filtered colors on both sides of the seam. It works by
using pixels from adjacent faces across the UV seam.

This new option is called "Adjacent Faces" and is the default. The old option
is called "Extend", and extends border pixels outwards.

Differential Revision: https://developer.blender.org/D13303
2022-01-17 19:36:13 +01:00
8af22719d0 Cleanup: Remove now redundant performance workaround for asset previews
Not needed anymore after aa0ecd179. The removed function was identical
to `icon_draw_rect()` now.

Reverts ab7214ca2e.
2022-01-17 18:26:32 +01:00
fa1fef5081 Cleanup: Correct comments for immediate mode buffer draw functions 2022-01-17 18:26:10 +01:00
194979e929 Cleanup: Improve naming of immediate mode buffer draw functions
Followup to the previous commit. Jeroen and I agreed the old naming was
confusing.
2022-01-17 18:26:10 +01:00
aa0ecd1791 UI: Speed up icon scaling
Use GPU-side scaling to speed up the scaling itself, and to avoid having
to copy the image buffer using the CPU. Mipmapping is used to get decent
filtering when downscaling without ugly artifacts.
In my comparisons, there was barely any difference between the methods
for DPIs >= 1. Below that, the result looks a bit different due to the
different filtering method.

See D13144 for screen-recordings showing the difference.

Part of T92922.

Differential Revision: https://developer.blender.org/D13144

Reviewed by: Jeroen Bakker
2022-01-17 18:26:10 +01:00
4d10a46e63 Cleanup: refactor BVH2 in preparation of self intersection skip
Move some logic out of triangle intersection functions and into BVH
traversal, so we can share logic between primitives.

Ref D12954
2022-01-17 17:35:23 +01:00
a25cfc5db2 Texture/Vertex Paint: Add secondary color to the tool header
Before we would only display the secondary color in the N-panel.
Now we also display it in the tool header.
2022-01-17 16:50:20 +01:00
be8f10a4e2 T94828: Appending collection with instancing links nested collections
See T94828 for details.

Differential Revision: https://developer.blender.org/D13803

Reviewed by: Bastien Montagne
2022-01-17 16:32:50 +01:00
e3fd0b1d17 Fix compiler warning on Windows
The variable was `uint64_t` and needs `1ull`
2022-01-17 16:08:48 +01:00
7abdd82dfd Fix T94338: bpy.data.libraries.load does not return the right thing.
Typo in rB605cdc4346e5f82, both `eBlendfileLinkAppendForeachItemFlag`
flags had the same value, effectively preventing to filter out direct
vs. indirect appended items.
2022-01-17 15:22:22 +01:00
59fcbdd815 Cleanup: deduplicate condition in transform curve code
Checking `t->around` and `nu->pntsv` does not need to be done in 2 places.
2022-01-17 11:14:44 -03:00
0a08ac2528 Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.

This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.

It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.

Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.

After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.

See differential page for tests files and demos.

Reviewed by: brecht, sybren

Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:51:04 +01:00
9d3f35a0bf Revert "Revert "GPUShaderCreateInfo for interface abstraction""
This reverts commit edee5a947b.

Fixes compilation error (Missing file BLI_float2.hh)
2022-01-17 14:46:32 +01:00
edee5a947b Revert "GPUShaderCreateInfo for interface abstraction"
This reverts commit 8fb2ff458b.
Missing some files.
2022-01-17 14:34:28 +01:00
Jeroen Bakker
8fb2ff458b GPUShaderCreateInfo for interface abstraction
This is a first part of the Shader Create Info system could be.

A shader create info provides a way to define shader structure, resources
and interfaces. This makes for a quick way to provide backend agnostic
binding informations while also making shader variations easy to declare.

- Clear source input (only one file). Cleans up the GPU api since we can create a
  shader from one descriptor
- Resources and interfaces are generated by the backend (much simpler than parsing).
- Bindings are explicit from position in the array.
- GPUShaderInterface becomes a trivial translation of enums and string copy.
- No external dependency to third party lib.
- Cleaner code, less fragmentation of resources in several libs.
- Easy to modify / extend at runtime.
- no parser involve, very easy to code.
- Does not hold any data, can be static and kept on disc.
- Could hold precompiled bytecode for static shaders.

This also includes a new global dependency system.
GLSL shaders can include other sources by using #pragma BLENDER_REQUIRE(...).

This patch already migrated several builtin shaders. Other shaders should be migrated
one at a time, and could be done inside master.

There is a new compile directive `WITH_GPU_SHADER_BUILDER` this is an optional
directive for linting shaders to increase turn around time.

What is remaining:
- pyGPU API {T94975}
- Migration of other shaders. This could be a community effort.

Reviewed By: jbakker

Maniphest Tasks: T94975

Differential Revision: https://developer.blender.org/D13360
2022-01-17 14:32:28 +01:00
08822801ac Fix T94805: Library weak reference generates "path not found" reports.
No reason to handle those paths here, those are fully internal temp
data, user should not be exposed to it currently.
2022-01-17 14:22:59 +01:00
04feaa8bd0 Core: Library Remap test cases.
For an upcoming refactoring of library remapping we want to be able to test if the logic won't change.
It also increased my experience inside the remapping codebase and find out what exactly needed to
be refactored.

This patch adds test cases for the core functionality of `foreach_libblock_remap_callback`. The test cases
don't cover of all the branches. Also pre-, post-processing, referencing and proxies are not tested.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D13815
2022-01-17 12:45:37 +01:00
e15449623d InstallDeps: Increase 'MEX' version of llvm to 14.
llvm 13 is now default on debian testing, tried it quickly and it seems
to work fine, so raising exclusive maximum value for it to 14.
2022-01-17 10:34:34 +01:00
40c8e23d48 LineArt: Invert collection option.
Allows conveniently selecting an inverse of a collection.

Reviewed By: Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D13846
2022-01-17 17:22:09 +08:00
e1e3043a51 CMake: resolve issue finding mold
The default installation path uses `libexec`, missed this as the
package for Arch replaces this with `lib`,
now both are checked.
2022-01-17 18:12:15 +11:00
Piotr Makal
a84621347d Geometry Nodes: Improve conversion from NURBS to Bezier
This patch improves conversion method from NURBS to Bezier curves,
resulting in exact shape between those two types when provided with
a 3rd degree NURBS curve. Part of T86086.

See the differential revision for more comparisons.

The node still cannot account properly for a NURBS "order" other
than 4 and it does not take into account control point weights.

Differential Revision: https://developer.blender.org/D13546
2022-01-16 22:52:18 -06:00
Alaska
34d424fd64 Fix T94526: Incorrect workspace ordering tooltip
Fix the description for WORKSPACE_OT_reorder_to_back to say "last" in
list rather than "first"

See D13696 for more details.

Differential Revision: https://developer.blender.org/D13696

Reviewed by Aaron Carlisle
2022-01-16 15:26:08 -08:00
d914cfcb7a Cleanup: simplify parameters
Use a common `userdata` for the different snap callbacks.
2022-01-16 11:25:51 -03:00
608d51c9c8 Fix T94951: Crash when snapping
Missed in {rBd9c6ceb3b88b6db87490b08e0089f9a18e6c52d6}
2022-01-16 11:25:51 -03:00
bc66cd9868 Fix T94865: GPU subdiv crash switching to texpaint area
The crash is due to the fact that GPU subdivision extraction routines
for edit data (including UVs) only worked for BMesh. However, a Mesh
based version is still needed for texture painting. This adds the
missing components. This also ensures all data are properly initialized
(at least the ones revealed by the bug).
2022-01-16 08:40:38 +01:00
3574f2730d Cleanup: deduplicate GPU subdiv data extraction loops
This puts the loop over the final subdivision quads outside of the mesh
iteration callback. This can also allow for easier parallel execution in
the future if need be.
2022-01-16 07:31:26 +01:00
b87d87b1d3 macOS: fix llvm-ranlib invalid option error 2022-01-16 11:47:55 +05:30
e69020ad0f CMake: only ever enable one alternative linker for UNIX/GCC
Since the option to enable linkers are booleans,
it's possible to enable them all at once.

Now only the first enabled + available linker is used
(with priority given to link is with better performance).
2022-01-15 16:40:24 +11:00
18c5d4ccb3 CMake: use LINKER flags instead of CFLAGS for setting the linker
Set the linker using CMAKE_*_LINKER_FLAGS instead of {C/CXX}FLAGS.

There is no advantage in using the CFLAGS to set the linker, it has the
downside of triggering a full rebuild when changing the linker.

Tested building Blender and the bpy.so Python module.

Ref D13833

Reviewed by: sergey, brecht
2022-01-15 16:12:13 +11:00
9664cc91f3 Fix T94918: GPU subdivision uses viewport levels for final render
The resolution for the subdivision grid traversal was always based on
the viewport setting.
2022-01-15 01:36:18 +01:00
6a16a9e661 Geometry Nodes: Rename transfer attribute geometry input
Conceptually, this is the geometry that data is taken from,
not the target of an operation, so rename it from "Target"
to "Source". This was common user feedback and agreed
on in a recent sub-module meeting.
2022-01-14 16:42:04 -06:00
6e926e9b56 Fix T94852: Geometry Proximity crash when unsuccessful
Before rB644e6c7a3e99ae1d43ed, `fill` was used in the error
cases, but now `fill_indices` is used, which doesn't work when
the span is empty (when only one output is used). The fix is just
to check for that case.
2022-01-14 16:10:38 -06:00
2a095d8bfe Audaspace: port bugfixes from upstream.
Windows audio backend (WASAPI) now automatically switches to
the selected audio device in windows.
2022-01-14 22:51:35 +01:00
9fe704800e Nodes: Support link-drag search with compare node outputs
The search list only displayed the "Result" output socket in this
case, which is unexpected since dragging from an input gives the
operations in the list as well. Also use integer mode when
connecting to boolean sockets.
2022-01-14 14:38:49 -06:00
b7a27efd78 Cleanup: Remove unused subdiv functions
I noticed these when doing final cleanup on rBcfa53e0fbeed.
One use was removed in that commit, the others were unused
going further back a few years.

Differential Revision: https://developer.blender.org/D13834
2022-01-14 14:04:24 -06:00
bba95d1901 Fix possible build error with unity build
`NodeOperationBuilder::Link` could conflict with the list base macros.
To resolve this dont use `using Link`.
2022-01-14 13:46:31 -05:00
67517c7d5c Cleanup: Outliner function names, simplify struct initialization 2022-01-14 19:26:04 +01:00
41495707d2 Fix incorrect destruction of Outliner tree-elements
`TreeElement` isn't a trivial type anymore, so `MEM_delete()` should be
called, which calls the destructor.
AFAICS this would cause a memory leak, since the contained `unique_ptr`
is allocated but not destructed correctly - but it's not using the
guarded allocator so woudn't be reported.
2022-01-14 19:26:04 +01:00
82d5905e4b Cleanup: Use destructor to delete Outliner runtime data
Simplifies and makes things safer due to proper RAII usage.
2022-01-14 19:26:04 +01:00
ca9a749b21 Cleanup: Use smart pointers for Outliner tree display and element types
Smart pointers should be the default choice for C++ owning pointers,
since they let you manage memory using RAII.

Also moved type factory methods into static class functions.
2022-01-14 19:26:04 +01:00
e9a43a3b60 Cleanup: Remove Outliner C-API headers/wrappers
Basically this removes any C <-> C++ glue code. C++ types are accessed
directly via the public C++ APIs.
Contains some related changes like, moving functions that were
previously declared in a now removed header to a different file, whose
header is the more appropriate place (and the source file as well).
But generally I tried to avoid other changes.
2022-01-14 19:26:04 +01:00
9109ea0b96 Disable some failing new obj exporter tests.
The switch to how normals are kept has led to tiny differences in
the normal output values on different platforms. Disabling the failing
tests while working on a solution to this problem.
2022-01-14 12:34:07 -05:00
5703efab88 Fix T94784: Crop node gizmo doesn't work
Fix refactoring mistake in rBcbca71a7cff3
Not the min and max values are initialized properly.
2022-01-14 17:44:18 +01:00
d723fa3d31 blenlib Any tests: Fix unknown pragma warning on Windows.
Part of a5cb7c1e62 is reverted since it 
created unknown pragma warning on windows.
Use a trick to do self-assigning.
Reviewed by Jacques Lucke in chat.
2022-01-14 22:10:28 +05:30
780633ec4b Cleanup: Unused function 2022-01-14 17:37:14 +01:00
301bb5afa5 Cleanup: Remove unused functions 2022-01-14 17:06:16 +01:00
eb33ee566e Fix T: Crash in do-version of older pre-2.80 blender files.
`BKE_layer_collection_sync` was missing a specific handling for one of
those pre-master collection cases,

NOTE: It is a bit unfortunate to have to do 'do-version' code in BKE...
At some point might look into moving this into actual `do_version` file,
but this is not fully trivial not critical improvement for now.
2022-01-14 17:02:05 +01:00
85df7036f7 Fix T94827: Group Input/Output cannot connect to custom sockets
Caused by rBa5c59fb90ef9.

Since Group Input and Output sockets happen to be of type `SOCK_CUSTOM`
[and since rBa5c59fb90ef9 custom py defined sockets are too :)] a check
introduced in rB513066e8ad6f that prevents connections for `SOCK_CUSTOM`
triggered.

Now refine the check, so it specifically looks for NODE_GROUP_INPUT /
NODE_GROUP_OUTPUT, too (this keeps the intention intact to not connect
group inputs to group outputs and vice versa, but allows custom py
defined sockets to connect again) and put it in new utility function.

Maniphest Tasks: T94827

Differential Revision: https://developer.blender.org/D13817
2022-01-14 16:30:59 +01:00
e57365a70b Cleanup split foreach_libblock_remap_callback into smaller functions. 2022-01-14 15:50:42 +01:00
348631cffe Fix: Compilation error caused by missing target relation
bf_nodes/bf_nodes_composite depend on DNA headers
2022-01-14 07:46:00 -07:00
8ae6995e98 Tests: show more precise numbers in benchmark charts 2022-01-14 15:17:22 +01:00
c0d0e2788b Cleanup: compiler warnings with clang 2022-01-14 15:17:22 +01:00
ba48c1ee58 macOS: silence bundle identifier mismatch Xcode warning
Blender.xcodeproj User-supplied CFBundleIdentifier value
'org.blenderfoundation.blender' in the Info.plist must be the same as
the PRODUCT_BUNDLE_IDENTIFIER build setting value ''.

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D13826
2022-01-14 19:33:23 +05:30
6f51cb0ad7 Info.plist: Bump LSMinimumSystemVersion to silence warning
Didn't remove the key-value pair since old Xcode behavior is not
known.

warning: LSMinimumSystemVersion of '10.9.0' is less than the value of
MACOSX_DEPLOYMENT_TARGET '10.13' - setting to '10.13'. (in target
'blender' from project 'Blender')

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D13831
2022-01-14 19:33:06 +05:30
a5cb7c1e62 blenlib/ Any tests: fix self-assignment warning and typo
Fix assignment warning

source/blender/blenlib/tests/BLI_any_test.cc:56:5: warning: explicitly
assigning value of variable of type 'blender::Any<void, 8, 8>'
to itself [-Wself-assign-overloaded]
  c = c;

Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D13835
2022-01-14 19:32:29 +05:30
0cf746c1fa Fix T94878: LineArt crease threshold logic error.
A coding mistake allows default crease to override object crease, now fixed.
2022-01-14 21:43:52 +08:00
c0432d5edb Fix T94089: GPencil Drawing don't Update after paste in Dopesheet
When paste new frames, the datablock need to be tagged to update the drawings.
2022-01-14 13:51:30 +01:00
86b7746e3c Fix T94903: GPencil: Copying keys doesn't preserve Keyframe Type
When a new frame is created, ensure the keytype of source key is used.
2022-01-14 13:05:57 +01:00
0a3de0305c Cleanup: move attribute operators to c++ 2022-01-14 12:53:19 +01:00
c9a8975de5 Fix T94867: viewport render not updating when editing color ramp
The changed node wasn't tagged correctly.
2022-01-14 12:50:53 +01:00
261517e475 Cleanup: Fix warning when compiling without Audaspace 2022-01-14 11:56:02 +01:00
c8e536bac3 Fix T94837: curve tilt on a 2-point-curve is wrong
2-point-curves are treated separately from 3plus-point-curves (assume a
lot of the twisting reduction can be skipped, so there is a dedicated
function for single segment curves).

And while using the 3plus-point-curves function [`make_bevel_list_3D`]
would actually work in this case, the dedicated function
`make_bevel_list_segment_3D` would only consider the tilt of the second
point and would just copy over the quat to the first point as well. Dont
see a reason for this, now consider the first point's tilt as well.

Maniphest Tasks: T94837

Differential Revision: https://developer.blender.org/D13813
2022-01-14 11:26:21 +01:00
e0ac75cb44 Cleanup: Reduce indentation in foreach_libblock_remap_callback. 2022-01-14 09:55:35 +01:00
7c568e7d36 Python API: add "children_recursive" property to Object & Collection
This is a convenience property, already available for bones.

Simplifies D13821 which in-lined this function.
2022-01-14 12:21:56 +11:00
cea588b9ef Cleanup: spelling in comments, C++ style comments for disabled code
Also ensure space at end of comment.
2022-01-14 11:23:46 +11:00
7a0cf2c72f Fix crash caused by exception in Python gizmo target get handler 2022-01-14 10:18:52 +11:00
1bd0a87384 Cleanup: Clang tidy
- modernize-deprecated-headers
- modernize-use-using
- modernize-use-nullptr
- modernize-use-bool-literals
2022-01-13 17:11:38 -06:00
8b3d798374 CMake: add WITH_LINKER_MOLD option for GCC/Clang Unix platforms
Can give considerably faster linking, especially on system with many
cores.

The mold linker recently reached 1.0, see:
https://github.com/rui314/mold

The current stable release of GCC can't use this linker via
-fuse-ld=mold, so this patch uses the "-B" argument to add a binary
directory containing an alternate "ld" command that points to
"mold" (which is part of the default mold installation).

Some timing tests for linking full builds for AMD TR 3970X:

- BFD: 20.78 seconds.
- LLD: 12.16 seconds.
- GOLD: 7.21 seconds.
- MOLD: 2.53 seconds.

Ref D13807

Reviewed by: sergey, brecht
2022-01-14 09:44:58 +11:00
0c5ccae79d Fix: Incorrect logic in mesh validation for removing layers
The mask is only used if it's not zero. Adding the normal mask made
it not zero, but it didn't include anything else, so all custom data
layers except normals were removed. The fix is to only add normals
to the mask when it should be used.
2022-01-13 16:36:50 -06:00
cfa53e0fbe Refactor: Move normals out of MVert, lazy calculation
As described in T91186, this commit moves mesh vertex normals into a
contiguous array of float vectors in a custom data layer, how face
normals are currently stored.

The main interface is documented in `BKE_mesh.h`. Vertex and face
normals are now calculated on-demand and cached, retrieved with an
"ensure" function. Since the logical state of a mesh is now "has
normals when necessary", they can be retrieved from a `const` mesh.

The goal is to use on-demand calculation for all derived data, but
leave room for eager calculation for performance purposes (modifier
evaluation is threaded, but viewport data generation is not).

**Benefits**
This moves us closer to a SoA approach rather than the current AoS
paradigm. Accessing a contiguous `float3` is much more efficient than
retrieving data from a larger struct. The memory requirements for
accessing only normals or vertex locations are smaller, and at the
cost of more memory usage for just normals, they now don't have to
be converted between float and short, which also simplifies code

In the future, the remaining items can be removed from `MVert`,
leaving only `float3`, which has similar benefits (see T93602).

Removing the combination of derived and original data makes it
conceptually simpler to only calculate normals when necessary.
This is especially important now that we have more opportunities
for temporary meshes in geometry nodes.

**Performance**
In addition to the theoretical future performance improvements by
making `MVert == float3`, I've done some basic performance testing
on this patch directly. The data is fairly rough, but it gives an idea
about where things stand generally.
 - Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms),
   showing that accessing just `MVert` is now more efficient.
 - Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight
   change that at least shows there is no regression.
 - Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small
   but observable speedup.
 - Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms),
   shows that using normals in geometry nodes is faster.
 - Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms),
   shows that calculating normals is slightly faster now.
 - File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB),
   Normals are not saved in files, which can help with large meshes.

As for memory usage, it may be slightly more in some cases, but
I didn't observe any difference in the production files I tested.

**Tests**
Some modifiers and cycles test results need to be updated with this
commit, for two reasons:
 - The subdivision surface modifier is not responsible for calculating
   normals anymore. In master, the modifier creates different normals
   than the result of the `Mesh` normal calculation, so this is a bug
   fix.
 - There are small differences in the results of some modifiers that
   use normals because they are not converted to and from `short`
   anymore.

**Future improvements**
 - Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier
   already retrieves normals if they are needed anyway.
 - Copy normals as part of a better CoW system for attributes.
 - Make more areas use lazy instead of eager normal calculation.
 - Remove `BKE_mesh_normals_tag_dirty` in more places since that is
   now the default state of a new mesh.
 - Possibly apply a similar change to derived face corner normals.

Differential Revision: https://developer.blender.org/D12770
2022-01-13 14:38:25 -06:00
800fc17367 Fix/workaround MSVC compile error with messag-bus
Some of the message-bus macros are not safe to use in C++. This has come
up before, but no good solution was found. Now @LazyDodo, @HooglyBoogly
and I concluded this is the best duct tape "solution" for the moment.
The message-bus API should address this.
2022-01-13 20:40:52 +01:00
1c4a1c13e0 Cleanup: Run make format 2022-01-13 19:56:11 +01:00
5ecaa9a838 Fix compilation error caused by missing target relation
compositor depends on DNA now so that it can access offsets.
2022-01-13 11:34:41 -07:00
3537abe84b Geometry Nodes: Rename String to Curves socket
Today many users seem to think the output from
this node is a single curve with multiple splines.
This patch renames the geometry output socket
from "Curves" to "Curve Instances" to avoid confusion.

Differential Revision: https://developer.blender.org/D13693
2022-01-13 19:17:03 +01:00
743b9c5e1d CMake: fix build issue with gcc+clang-tidy
Precompiled headers are in a compiler specific format,
when using clang-tidy it tries to read the GCC PCH file
and fails at that.

Disable PCH's for now when WITH_CLANG_TIDY is enabled since
a clean work-around doesn't seem readily available.

relevant LLVM/CMake bugs:

https://bugs.llvm.org/show_bug.cgi?id=41579
https://gitlab.kitware.com/cmake/cmake/-/issues/22081

Differential Revision: https://developer.blender.org/D13814

Reviewed by: sergey, Blendify
2022-01-13 09:47:14 -07:00
b8157f5bf1 Fix compilation error caused by missing target relation
Space clip depends on DNA now so that it can access offsets.
2022-01-13 17:25:57 +01:00
22dc865a86 Cleanup: Use nullptr in new Outliner C++ files 2022-01-13 17:01:47 +01:00
039cc32917 Outliner: Compile all Outliner files in C++
We want to refactor quite some of the Outliner code using C++, this is a
logical step to help the transition to a new architecture.

Includes plenty of fixes to make this compile without warnings, trying
not to change logic. The usual stuff (casts from `void *`, designated
initializers, compound literals, etc.).
2022-01-13 17:01:47 +01:00
1a4f8ab389 Cleanup: Make message-bus utility macros callable from C++
C++ doesn't support compound literals like used here (GCC does via an
extension).
2022-01-13 17:01:47 +01:00
f173973ae4 Fix T94874: Drivers using bone custom properties don't work on modifiers 2022-01-13 15:17:32 +01:00
79e985ea54 Cleanup: fix building all geometry nodes in one translation unit
There were a couple of function name collisions which were caused
by sharing code with the mask modifier. I just removed the dependence
on the mask modifier now. The code that I duplicated for that purpose
is only in a legacy node, so it can be expected to be removed soonish.
2022-01-13 12:39:48 +01:00
19a6220308 Fix link errors after recent FFMPEG / link_directories changes 2022-01-13 11:12:56 +01:00
d53738396f Tests: skip some compositor tests when WITH_LIBMV=OFF 2022-01-13 10:41:34 +01:00
7bb572f208 Fix T94737: Cycles wrong normal map normal with OSL
Ensure valid reflection was moved elsewhere, should not be done in the node
anymore.
2022-01-13 10:40:41 +01:00
0cf2fafd81 Fix T94050, T94570, T94527: Cycles Bevel and AO nodes not working with Metal
Workaround what may be a compiler bug, solution found by Michael Jones.
2022-01-13 10:40:41 +01:00
a3deef6fff Fix Cycles CPU + GPU render not using CPU after recent changes
In some places the task scheduler was not initialized in time.
2022-01-13 10:40:41 +01:00
eaa4cdaa42 Fix T94758: wrong denoising albedo with BSSRDF retro reflection 2022-01-13 10:40:40 +01:00
Brecht Van Lommel
29450a2af3 Build: remove usage of link_directories
We are now always using absolute paths for libraries, as recommended by the
CMake docs.

Followup to D9177.
2022-01-13 10:40:38 +01:00
Brecht Van Lommel
75a1a578bd CMake: use FFmpeg find module on Linux
And change install_deps.sh to build shared (instead of static) FFMPEG
libraries, for consistency with other library dependencies and to simplify
the logic. This may require users of install_deps.sh to rebuild FFMPEG.

This is the last step that lets us get rid of LIBPATH variables and
link_directories() entirely, as recommended by the CMake docs.

Some fixes were needed in the find FFMPEG module to make it actually work,
this code was unused up to now.

Followup to D8855.

Differential Revision: https://developer.blender.org/D9177
2022-01-13 10:27:11 +01:00
f1a488d0f2 Fix T92953: Tool Settings: Drag on Tweak fails with LMB select 2022-01-13 14:30:12 +11:00
a7c9fb59ca Cleanup: follow code-style for float suffix 2022-01-13 12:34:28 +11:00
227f0f3582 Cleanup: quiet missing braces warning 2022-01-13 12:33:34 +11:00
97c2c39916 Fix T94624: Object as font instances don't work
The fundamental limitation is that we can only have one instance
("dupli") generator at a time. Because the mesh output of a curve
object is output as an instances, the geometry set instances existed,
replacing the object as font instances. The "fix" is to reverse the
order. The behavior won't be perfect still, but at least the old
behavior will be preserved, which is really what matters for a
feature like this.

One way to take this change further would be completely disabling
regular geometry evaluation while this option is active. However,
it doesn't seem like that would actually improve the state of the code.

Differential Revision: https://developer.blender.org/D13768
2022-01-12 13:46:13 -06:00
a311fa96aa Fix T85706: wm_window_make_drawable update DPI
When drawing windows on monitors that differ in DPI, we can sometimes
have UI elements draw at an incorrect scale. This patch just ensures
that `wm_window_make_drawable` always updates DPI.

See D10483 for more details.

Differential Revision: https://developer.blender.org/D10483

Reviewed by Brecht Van Lommel
2022-01-12 10:37:52 -08:00
e594f23a27 Revert "CMake: use FFmpeg find module on Linux"
This reverts commit 62a0de1673. Linux buildbot
is giving link errors.
2022-01-12 19:07:40 +01:00
fa8c2c7885 Fix T94071: Area Split Improvements
Allow area Split to be initiated in any area and give better feedback
when not allowed.

See D13599 for more details and usage examples.

Differential Revision: https://developer.blender.org/D13599

Reviewed by Campbell Barton
2022-01-12 09:45:19 -08:00
a0dcd0bf2c Fix warnings after bab47b60cb
It's not really clear how this part of the defaults code should be used,
I think this is fine now and solves the warnings.
2022-01-12 18:37:53 +01:00
a72a9e099c Cleanup: Correct indentation 2022-01-12 18:37:53 +01:00
Brecht Van Lommel
62a0de1673 CMake: use FFmpeg find module on Linux
And change install_deps.sh to build shared (instead of static) FFMPEG
libraries, for consistency with other library dependencies and to simplify
the logic. This may require users of install_deps.sh to rebuild FFMPEG.

This is the last step that lets us get rid of LIBPATH variables and
link_directories() entirely, as recommended by the CMake docs.

Some fixes were needed in the find FFMPEG module to make it actually work,
this code was unused up to now.

Followup to D8855.

Differential Revision: https://developer.blender.org/D9177
2022-01-12 18:25:24 +01:00
Simon Lenz
bab47b60cb DNA: Add space clip editor defaults
This is my attempt of adding defaults for the space clip editor struct
(in line with https://developer.blender.org/T80164).

It adds the default allocation for `SpaceClip` and
`node_composite_movieclip.cc`. This also solves the error below (for
C++ files using the DNA_default_alloc), which was put forward by
Sergey Sharybin.

Differential Revision: https://developer.blender.org/D13367

Reviewed by: Julian Eisel
2022-01-12 18:04:48 +01:00
Bastien Montagne
a909ab984c Outliner: Add way to display warning icon for items.
While theorically fairly generic, current code is only enabled for
bledfile and liboverride views, and only used to display messages from
library IDs.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D13766
2022-01-12 18:01:50 +01:00
5f7ad4baaa BLI_math: Fix building when WITH_GMP is off 2022-01-12 17:24:57 +01:00
Nikhil Shringarpurey
e5858a3ad0 Icons: Remove absolute pathnames and deprecated gradients from SVG files
SVG files contained specific detailed pathnames on developers'
computers. These included full local user profile and path and should
not be in the release.

This patches corrects those lines. It also removes unused gradients from
the private icons SVG.

Differential Revision: https://developer.blender.org/D13344

Reviewed by: Yevgeny Makarov, Julian Eisel
2022-01-12 15:03:05 +01:00
ec5560db73 DRW: Add DRW_gpu_wrapper.hh
This adds wrapper classes that make it easier to use GPU objects in C++.

####Motivations:####

 - Easier handling of GPU objects.
 - EEVEE rewrite already makes use of similar wrappers.
 - There is the ongoing effort to use more C++ in the codebase
 and lans to port more engines to it.
 - The shader code refactor will make use of many UBOs with shared
 struct declaration. This helps managing them.
 - Safer handling of `TextureFromPool` which can't be bound as normal
 texture (only texture ref) and can be better tracked in the future.

####Considerations:####

 - I chose the `blender::draw` namespace because `blender::gpu` already has private classes (i.e: `gpu::Texture`).
 - Theses are wrappers that manage a GPU object internally. They might be confused with actual `Texture`. However, the name `TextureWrapper` is a bit too much verbose in my opinion. I'm open to suggestion about better name.

Reviewed By: jbakker

Differential Revision: http://developer.blender.org/D13805
2022-01-12 13:05:18 +01:00
0882069095 Cleanup: codestyle obj_exporter_tests.cc. 2022-01-12 13:02:28 +01:00
1552b86b55 Cleanup: Not needed if statement around delete. 2022-01-12 13:02:28 +01:00
d43b5791e0 BLI: Refactor vector types & functions to use templates
This patch implements the vector types (i.e:`float2`) by making heavy
usage of templating. All vector functions are now outside of the vector
classes (inside the `blender::math` namespace) and are not vector size
dependent for the most part.

In the ongoing effort to make shaders less GL centric, we are aiming
to share more code between GLSL and C++ to avoid code duplication.

####Motivations:
- We are aiming to share UBO and SSBO structures between GLSL and C++.
This means we will use many of the existing vector types and others
we currently don't have (uintX, intX). All these variations were
asking for many more code duplication.
- Deduplicate existing code which is duplicated for each vector size.
- We also want to share small functions. Which means that vector
functions should be static and not in the class namespace.
- Reduce friction to use these types in new projects due to their
incompleteness.
- The current state of the `BLI_(float|double|mpq)(2|3|4).hh` is a
bit of a let down. Most clases are incomplete, out of sync with each
others with different codestyles, and some functions that should be
static are not (i.e: `float3::reflect()`).

####Upsides:
- Still support `.x, .y, .z, .w` for readability.
- Compact, readable and easilly extendable.
- All of the vector functions are available for all the vectors types
and can be restricted to certain types. Also template specialization
let us define exception for special class (like mpq).
- With optimization ON, the compiler unroll the loops and performance
is the same.

####Downsides:
- Might impact debugability. Though I would arge that the bugs are
rarelly caused by the vector class itself (since the operations are
quite trivial) but by the type conversions.
- Might impact compile time. I did not saw a significant impact since
the usage is not really widespread.
- Functions needs to be rewritten to support arbitrary vector length.
For instance, one can't call `len_squared_v3v3` in
`math::length_squared()` and call it a day.
- Type cast does not work with the template version of the `math::`
vector functions. Meaning you need to manually cast `float *` and
`(float *)[3]` to `float3` for the function calls.
i.e: `math::distance_squared(float3(nearest.co), positions[i]);`
- Some parts might loose in readability:
`float3::dot(v1.normalized(), v2.normalized())`
becoming
`math::dot(math::normalize(v1), math::normalize(v2))`
But I propose, when appropriate, to use
`using namespace blender::math;` on function local or file scope to
increase readability.
`dot(normalize(v1), normalize(v2))`

####Consideration:
- Include back `.length()` method. It is quite handy and is more C++
oriented.
- I considered the GLM library as a candidate for replacement. It felt
like too much for what we need and would be difficult to extend / modify
to our needs.
- I used Macros to reduce code in operators declaration and potential
copy paste bugs. This could reduce debugability and could be reverted.
- This touches `delaunay_2d.cc` and the intersection code. I would like
to know @howardt opinion on the matter.
- The `noexcept` on the copy constructor of `mpq(2|3)` is being removed.
But according to @JacquesLucke it is not a real problem for now.

I would like to give a huge thanks to @JacquesLucke who helped during this
and pushed me to reduce the duplication further.

Reviewed By: brecht, sergey, JacquesLucke

Differential Revision: https://developer.blender.org/D13791
2022-01-12 12:57:07 +01:00
fb6bd88644 Revert "BLI: Refactor vector types & functions to use templates"
Includes unwanted changes

This reverts commit 46e049d0ce.
2022-01-12 12:50:02 +01:00
Clment Foucault
46e049d0ce BLI: Refactor vector types & functions to use templates
This patch implements the vector types (i.e:`float2`) by making heavy
usage of templating. All vector functions are now outside of the vector
classes (inside the `blender::math` namespace) and are not vector size
dependent for the most part.

In the ongoing effort to make shaders less GL centric, we are aiming
to share more code between GLSL and C++ to avoid code duplication.

####Motivations:
 - We are aiming to share UBO and SSBO structures between GLSL and C++.
 This means we will use many of the existing vector types and others
 we currently don't have (uintX, intX). All these variations were
 asking for many more code duplication.
 - Deduplicate existing code which is duplicated for each vector size.
 - We also want to share small functions. Which means that vector
 functions should be static and not in the class namespace.
 - Reduce friction to use these types in new projects due to their
 incompleteness.
 - The current state of the `BLI_(float|double|mpq)(2|3|4).hh` is a
 bit of a let down. Most clases are incomplete, out of sync with each
 others with different codestyles, and some functions that should be
 static are not (i.e: `float3::reflect()`).

####Upsides:
 - Still support `.x, .y, .z, .w` for readability.
 - Compact, readable and easilly extendable.
 - All of the vector functions are available for all the vectors types
 and can be restricted to certain types. Also template specialization
 let us define exception for special class (like mpq).
 - With optimization ON, the compiler unroll the loops and performance
 is the same.

####Downsides:
 - Might impact debugability. Though I would arge that the bugs are
 rarelly caused by the vector class itself (since the operations are
 quite trivial) but by the type conversions.
 - Might impact compile time. I did not saw a significant impact since
 the usage is not really widespread.
 - Functions needs to be rewritten to support arbitrary vector length.
 For instance, one can't call `len_squared_v3v3` in
 `math::length_squared()` and call it a day.
 - Type cast does not work with the template version of the `math::`
 vector functions. Meaning you need to manually cast `float *` and
 `(float *)[3]` to `float3` for the function calls.
 i.e: `math::distance_squared(float3(nearest.co), positions[i]);`
 - Some parts might loose in readability:
 `float3::dot(v1.normalized(), v2.normalized())`
 becoming
 `math::dot(math::normalize(v1), math::normalize(v2))`
 But I propose, when appropriate, to use
 `using namespace blender::math;` on function local or file scope to
 increase readability.
 `dot(normalize(v1), normalize(v2))`

####Consideration:
 - Include back `.length()` method. It is quite handy and is more C++
 oriented.
 - I considered the GLM library as a candidate for replacement. It felt
 like too much for what we need and would be difficult to extend / modify
 to our needs.
 - I used Macros to reduce code in operators declaration and potential
 copy paste bugs. This could reduce debugability and could be reverted.
 - This touches `delaunay_2d.cc` and the intersection code. I would like
 to know @howardt opinion on the matter.
 - The `noexcept` on the copy constructor of `mpq(2|3)` is being removed.
 But according to @JacquesLucke it is not a real problem for now.

I would like to give a huge thanks to @JacquesLucke who helped during this
and pushed me to reduce the duplication further.

Reviewed By: brecht, sergey, JacquesLucke

Differential Revision: https://developer.blender.org/D13791
2022-01-12 12:47:43 +01:00
e5766752d0 Revert "BLI: Refactor vector types & functions to use templates"
Reverted because the commit removes a lot of commits.

This reverts commit a2c1c368af.
2022-01-12 12:44:26 +01:00
Nathan Rozendaal
b2ccd8546c Compositor: Add Scene Time Node, Rename Time node
Fixes issue T94603
It adds a new compositor node called Scene Time which is already present as a geo node, having the same basic nodes available in all node trees is a nice thing to have.
Renames "Time" node to "Time Curve", this is done to avoid confusion between the Time node and the Scene Time node.

Reviewed By: jbakker

Maniphest Tasks: T94603

Differential Revision: https://developer.blender.org/D13762
2022-01-12 12:29:44 +01:00
a2c1c368af BLI: Refactor vector types & functions to use templates
This patch implements the vector types (i.e:float2) by making heavy
usage of templating. All vector functions are now outside of the vector
classes (inside the blender::math namespace) and are not vector size
dependent for the most part.

In the ongoing effort to make shaders less GL centric, we are aiming
to share more code between GLSL and C++ to avoid code duplication.

Motivations:
- We are aiming to share UBO and SSBO structures between GLSL and C++.
  This means we will use many of the existing vector types and others we
  currently don't have (uintX, intX). All these variations were asking
  for many more code duplication.
- Deduplicate existing code which is duplicated for each vector size.
- We also want to share small functions. Which means that vector functions
  should be static and not in the class namespace.
- Reduce friction to use these types in new projects due to their
  incompleteness.
- The current state of the BLI_(float|double|mpq)(2|3|4).hh is a bit of a
  let down. Most clases are incomplete, out of sync with each others with
  different codestyles, and some functions that should be static are not
  (i.e: float3::reflect()).

Upsides:
- Still support .x, .y, .z, .w for readability.
- Compact, readable and easilly extendable.
- All of the vector functions are available for all the vectors types and
  can be restricted to certain types. Also template specialization let us
  define exception for special class (like mpq).
- With optimization ON, the compiler unroll the loops and performance is
  the same.

Downsides:
- Might impact debugability. Though I would arge that the bugs are rarelly
  caused by the vector class itself (since the operations are quite trivial)
  but by the type conversions.
- Might impact compile time. I did not saw a significant impact since the
  usage is not really widespread.
- Functions needs to be rewritten to support arbitrary vector length. For
  instance, one can't call len_squared_v3v3 in math::length_squared() and
  call it a day.
- Type cast does not work with the template version of the math:: vector
  functions. Meaning you need to manually cast float * and (float *)[3] to
  float3 for the function calls.
  i.e: math::distance_squared(float3(nearest.co), positions[i]);
- Some parts might loose in readability:
  float3::dot(v1.normalized(), v2.normalized())
  becoming
  math::dot(math::normalize(v1), math::normalize(v2))
  But I propose, when appropriate, to use
  using namespace blender::math; on function local or file scope to
  increase readability. dot(normalize(v1), normalize(v2))

Consideration:
- Include back .length() method. It is quite handy and is more C++
  oriented.
- I considered the GLM library as a candidate for replacement.
  It felt like too much for what we need and would be difficult to
  extend / modify to our needs.
- I used Macros to reduce code in operators declaration and potential
  copy paste bugs. This could reduce debugability and could be reverted.
- This touches delaunay_2d.cc and the intersection code. I would like to
  know @Howard Trickey (howardt) opinion on the matter.
- The noexcept on the copy constructor of mpq(2|3) is being removed.
  But according to @Jacques Lucke (JacquesLucke) it is not a real problem
  for now.

I would like to give a huge thanks to @Jacques Lucke (JacquesLucke) who
helped during this and pushed me to reduce the duplication further.

Reviewed By: brecht, sergey, JacquesLucke

Differential Revision: http://developer.blender.org/D13791
2022-01-12 12:19:39 +01:00
d320f3677e Cleanup: make format 2022-01-12 11:29:18 +01:00
1e61b759c7 Fix T94797: crash when playing animation in eevee rendered view
The issue was caused by rBd09b1d2759861aa012ab2e7e4ce2ffa2.
Since this commit, the image users in gpu materials were updated
during depsgraph evaluation as well. However, there was a race
condition when one thread is deleting gpu materials in `BKE_material_eval`
while another thread is updating the image users at the same time.

The solution is to make sure that deleting gpu materials is done before
iterating over all gpu materials, by adding a new depsgraph relation.
2022-01-12 11:15:22 +01:00
145f1d1e0a Fix T94812: render layer sockets are missing after file load
The main issue was the use of `G_MAIN` during file load.
This patch refactors the code so that iterating over `G_MAIN`
is not necessary anymore. See D13800 for more details.

Differential Revision: https://developer.blender.org/D13800
2022-01-12 11:07:31 +01:00
7a2b181591 Fix T94041: Loading a new file gives crash while rendering in viewport
The issue was caused by Cycles display driver not being able to restore
window's OpenGL context after disposing Cycles-side OpenGL context.

This is due to the window OpenGL re-activation needing to access window
manager which gets cleared out form global main during file reading.

Defer clearing window manager from the global main to until after all
screens are "exited". This allows Cycles to properly stop rendering,
dispose its OpenGL context, and restore window's drawable context.

It is unclear why it was required to clear window manager list early
on. Guess is that it comes from an original code in a1c8543f2a where
there was an early return which then got replaced with an actual logic
without changing the order of de-initialization and window manager list
clear.

Differential Revision: https://developer.blender.org/D13799
2022-01-12 10:01:33 +01:00
ebad1d8d33 CMake: exclude linker options for APPLE and non-UNIX
These are only used for non-apple unix systems.
2022-01-12 18:55:13 +11:00
795cea2cce Revert "Cleanup GPencil strength previous commit"
This reverts commit e339946515.

This broken the tablet pressure and it was impossible to set a proper strength.
2022-01-12 08:45:57 +01:00
7f28084e2a Cleanup: use utility functions 2022-01-12 06:46:12 +01:00
77616082f4 Fix T89542: Crash when loading certain .hdr files
The direct cause of the bug in question was passing in the raw memory
buffer to sscanf. It should be called with a null-terminated buffer;
which isn't guaranteed when blindly trusting the file data.

When attempting to fuzz this code path, a variety of other crashes were
discovered and fixed.

Differential Revision: https://developer.blender.org/D11952
2022-01-11 20:48:32 -08:00
0dc309bef6 Cleanup: remove redundant const qualifiers for POD types 2022-01-12 12:51:11 +11:00
f4492629ea Cleanup: VSE channel drawing
Remove code that very slightly darkened line on bottom of timeline, when
backdrop is enabled. Purpose of the code wasn't dodumented, and 2.79
doesn't seem to produce this darkened line.
Rename drawing functions to appropriate names.
2022-01-12 01:46:27 +01:00
ef5d01d98f deps_builder: GMP 6.2.1
Pretty straightforward update, nothing noteworthy to report.

Differential Revision: https://developer.blender.org/D13278

Reviewed by: brecht, sybren
2022-01-11 16:26:30 -07:00
89145341e5 BLF: UI_fontstyle_draw Usage
Add maximum string length argument to UI_fontstyle_draw to reduce usage
of BLF_DRAW_STR_DUMMY_MAX. Reorders arguments to UI_fontstyle_draw_ex

See D13794 for more details.

Differential Revision: https://developer.blender.org/D13794

Reviewed by Campbell Barton
2022-01-11 14:52:39 -08:00
bbe59c6014 BLF: Reduction of use of BLF_DRAW_STR_DUMMY_MAX
Reduction of the number of uses of the define BLF_DRAW_STR_DUMMY_MAX
by using actual sizes of static character arrays.

See D13793 for more details.

Differential Revision: https://developer.blender.org/D13793

Reviewed by Campbell Barton
2022-01-11 14:08:38 -08:00
ab125f466c Fix T94751: ground created by Setup Tracking Scene not marked as Shadow Catcher
Change that was missing in {rBca64bd0aacda}.
2022-01-11 19:02:04 -03:00
947dc21979 Cleanup: Fix build warning with MSVC
comparing a bool > 0 make MSVC emit
warning C4804: '>': unsafe use of type 'bool' in operation.

int does the job nicely.
2022-01-11 14:57:54 -07:00
5a6ec0f003 Build: Enable unity build for bf_compositor
Blender's compositor code already makes extensive use of
namespace which makes it very simple to enable unity build.
There was one duplicated function that has since to be moved
to a common header.

I saw roughly a 3x speedup of bf_compositor using ninja on
linux using i5 8250u (1:34 down to 0:34).

Reviewed By: LazyDodo

Differential Revision: https://developer.blender.org/D13792
2022-01-11 16:55:45 -05:00
48ff9b57f8 Build: Add precompiled headers for bf_compositor
With this change, compilation saw a 2.4x improvement.

This can be combined with unity build to give an overall 4x improvement

Depends on D13797

Reviewed By: LazyDodo

Differential Revision: https://developer.blender.org/D13798
2022-01-11 16:50:35 -05:00
bdf99a5119 cleanup: hipew remove unused variables
caused 4 warnings, nothing even conditionally
uses them, can be safely removed.
2022-01-11 14:49:29 -07:00
e339946515 Cleanup previous commit
Don't need check minimum constant value, brush value is enough.
2022-01-11 22:48:26 +01:00
ac3d07ad17 Fix T94799: GPencil Strokes drawn at 0.0 Strength still visible
There was a clamp with a value greater than 0.
2022-01-11 22:45:50 +01:00
376e425c02 Fix T93588: some videos loaded flipped over Y axis on macOS Arm
Was not actually flipping in the need_aligned_ffmpeg_buffer case.
2022-01-11 21:43:32 +01:00
45bb6b836a IME Cleanup: Unused GHOST_TEventImeData Member
Removal of unused tmp member of GHOST_TEventImeData. Not used now,
nor was it used by the commit that added it to begin with.

Differential Revision: https://developer.blender.org/D11799

Reviewed by Ray Molenkamp
2022-01-11 12:35:11 -08:00
e95b4dc2dd Cleanup: Fix build warnings with MSVC
our UNUSED macro is essentially a no-op for MSVC, which lead to
the situation  where this well meant macro was emitting the
following warning:

C4189: 'UNUSED_i': local variable is initialized but not referenced

However since we have been on c++17 for a while now the UNUSED
macro can be replaced with the standard [[maybe_unused]] attribute
in cpp files.

This changes cleans up the use of the UNUSED macro in the
bf_nodes_geometry project.

Differential Revision: https://developer.blender.org/D12915

Reviewed by: JacquesLucke, Severin, Sergey, HooglyBoogly
2022-01-11 12:54:18 -07:00
259a71cd3c Build: use precompiled headers on all platforms
Since CMake 3.16, CMake has native precompiled header (PCH) support.

This change swaps Blender's own PCH implementation with the native implementation.
Previously, PCH was only enabled on Windows however,
this new implementation works on all platforms.

For more information see https://cmake.org/cmake/help/latest/command/target_precompile_headers.html

On my system, Linux with ninja running on an i5 8250U
I saw a 60% reduction in compile times for `bf_freestyle` + linking time.

Reviewed By: LazyDodo, brecht

Differential Revision: https://developer.blender.org/D13797
2022-01-11 14:18:58 -05:00
8cff1ecf9f Fix T94804: GPencil Simplify when strokes are Automerged in Draw Mode
The problem was the points were selected in edit mode and then sampled. Now, in draw mode, the points are always unselected to avoid this effect in the auto merge process.
2022-01-11 19:20:27 +01:00
Henrik Dick
631067e559 Add support for a longest diagonal quad triangulation mode
The new triangulation mode for quads is the opposite of the current default
shortest diagonal mode. It is optimal for cloth simulations using quad meshes.

Differential Revision: http://developer.blender.org/D13777
2022-01-11 18:51:25 +01:00
41ce7807a6 Fix T94299: Object asset set as visible but doesn't show
Differential Revision: https://developer.blender.org/D13738

Reviewed by: Bastien Montagne, Sergey Sharybin
2022-01-11 18:38:05 +01:00
ccac22fec5 Cleanup compiler warning in Windows
`bool` used instead of `int`
2022-01-11 16:48:16 +01:00
6774cae3f2 Fix T94728: Auto Depth problem with Cliping Region
Issue introduced in rB1d49293b80446b89b5b12fa0eeefaf14e5051e48

`drw_manager_init` must be called after `drw_context_state_init` as
`DST.draw_ctx.sh_cfg` (indicating when the view is clipped) must be set
first.

Differential Revision: https://developer.blender.org/D13795
2022-01-11 10:39:39 -03:00
fc0f315106 Cleanup: remove unnecessary 'use_opengl_context' parameter
The argument passed is always false.
2022-01-11 10:28:32 -03:00
Aleksi Juvani
0c94e5d166 Fix PSYS_GLOBAL_HAIR stripped even if connecting the hair fails
After disconnecting hair on an object, if you then hide the particle system, and try connecting the hair again, the operator is cancelled due to `remap_hair_emitter` returning `false` because `target_psmd->mesh_final` is NULL, but `connect_hair` will still strip the `PSYS_GLOBAL_HAIR` flag, which will cause the hair in the hidden particle system to be positioned incorrectly. The correct behavior is to strip the flag only if `remap_hair_emitter` succeeds.

Differential Revision: https://developer.blender.org/D13703
2022-01-11 13:08:13 +01:00
9dc9692b09 Select Similar: hide 'threshold' from UI when not used
When the 'threshold' is not used in the type we are comparing, just hide
it. This was obvious for some types (e.g. Materials), but maybe not so
on others (e.g. Polygon Sides) and potentionally confusing.

Reported by @hitrpr in chat.

Differential Revision: https://developer.blender.org/D13760
2022-01-11 11:47:57 +01:00
255727b752 GPU: Utility function to bind UBO to batches. 2022-01-11 09:57:22 +01:00
Evan Wilson
1949aece21 Explicit Color OCIO role comment fix.
This is an update to the correct OCIO role.

It changes `SceneReference` to `scene_linear`

See https://opencolorio.readthedocs.io/en/latest/guides/authoring/overview.html#config-roles

>     - reference - the color space against which the other color spaces are defined
>NOTE: The reference role has sometimes been misinterpreted as being the space in which “reference art” is stored in.
>
>    - scene_linear - the scene-referred linear-to-light color space, often the same as the reference space

The current OCIO UX working group doc says:

>reference: This role has had multiple interpreted meanings over the years and is a common point of confusion. It is kept in OCIO for backwards compatibility, but the recommendation is that it is not used by apps.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11398
2022-01-11 09:55:22 +01:00
4e8a883bcc Cleanup: use unity build for composite nodes
GIves about a 2.1x improvement in compilation times.
2022-01-11 02:57:14 -05:00
bc02ede98b Cleanup: Deduplicate finv_test function 2022-01-11 02:16:47 -05:00
d608b98145 Cleanup: quite missing-variable-declarations warnings 2022-01-11 18:16:00 +11:00
9af81c2b74 Cleanup: correct exception message 2022-01-11 18:16:00 +11:00
c77f837598 Revert "Cleanup: remove declaration for removed function"
This reverts commit aa363ec2ae.

The function still exists, this commit caused a warning with Clang
So keep MEM_printmemlist_pydict.
2022-01-11 18:16:00 +11:00
fd922f5940 Cleanup: Composite nodes: add namespace for every file
This puts all static functions in composite node files into a new
namespace. This allows using unity build which can improve
compile times significantly.

This is a follow up on rB1df8abff257030ba79bc23dc321f35494f4d91c5
but for compositor nodes.

The namespace name is derived from the file name.
That makes it possible to write some tooling that checks the names later on.
The filename extension (`cc`) is added to the namespace name as well.
his also possibly simplifies tooling but also makes it more obvious that this namespace is specific to a file.

Reviewed By: JacquesLucke, HooglyBoogly, jbakker

Differential Revision: https://developer.blender.org/D13466
2022-01-11 02:11:14 -05:00
f2fb9a0c59 Fix T94768: Crash in VSE prefetching
If timeline contains scene strip outside of edited meta strip, this will
cause crash. This is because prefetchin ignored meta strips being edited
when rendering, but did check for scene strips only inside edited meta
strip.

Change active seqbase pointer when entering meta strip. This makes it
possible to prefetch only content that is being presented to user.
2022-01-11 06:12:15 +01:00
f134341e03 Fix T94671: performance regression with subsurf modifier
rBeed45d2a239a introduced a GPU backend for OpenSubDiv which lets us do
the subdivision at render time. However, some tools might still need to
have the subdivision data available on the CPU side. For this a
subdivision mesh wrapper was also introduced, and is computed whenever a
CPU side mesh is needed. The subdivision settings for this wrapper are
stored during modifier evaluation if GPU subdivision can be done.

The performance regression is due to the fact that although the
subdivision mesh was already computed on the CPU, and no subdivision
wrapper is generated, some checks for creating subdivision data in
`BKE_mesh_wrapper_ensure_subdivision` where still run, one of which is
very expensive.

To fix this we first check the runtime settings of the mesh to see if
subdivision is needed at all.
2022-01-11 03:34:16 +01:00
922ae55a16 Spreadsheet: Add mesh topology information with a debug value
This commit adds topology information from mesh data structs to the
spreadsheet when the debug value `4001` is set. Eventually we could
expose these. For now it can be a useful tool for developers when
working on mesh algorithms.

Differential Revision: https://developer.blender.org/D13735
2022-01-10 16:45:53 -06:00
37b336a8af Cleanup: Remove unused "active ID" node flag
The value of this flag was only retrieved in `nodeGetActiveID`, which
wasn't used anywhere. Other than that, the `NODE_ACTIVE_ID` and
related functions seem to come from the Blender internal renderer.

Differential Revision: https://developer.blender.org/D13770
2022-01-10 16:42:50 -06:00
f4af21038d Geometry Nodes: Move normal field input to be usable elsewhere
This commit moves the normal field input to `BKE_geometry_set.hh`
from the node file so that normals can be used as an implicit input to
other nodes.

Differential Revision: https://developer.blender.org/D13779
2022-01-10 16:41:05 -06:00
fe82b8d1e8 Docs: correct doc-string for bl_run_operators_event_simulate
The event() action swapped type/value arguments.
2022-01-11 09:13:25 +11:00
4b8cf11fa5 macOS: fix xcrun sdk detection for minimal CLT
Differential Revision: https://developer.blender.org/D13783
2022-01-11 01:07:31 +05:30
a4a95c8d36 Docs: Add comments to node socket struct header 2022-01-10 12:29:09 -06:00
ccf06fffbc UI: Allow AltGr Key + C,V,X Text Input
Slight change to our processing of Ctrl-C, Ctrl-V, and Ctrl-X so that
they will not be triggered if Alt is also pressed. This allows entry
of AltGr-C, -V, -X when using International keyboard layouts.

See D13781 for more details

Differential Revision: https://developer.blender.org/D13781

Reviewed by Brecht Van Lommel
2022-01-10 09:52:19 -08:00
Takahiro Shizuki
57bea57f5e Fix T94434: Windows IME Pinyin Forward Slash
Treat "/" as a key that should be evaluated by the Win IME system when
the input language is Chinese. This fixes a duplication of the input
character and results in the expected output of a Chinese wide comma.

See D13771 for more details.

Differential Revision: https://developer.blender.org/D13771

Reviewed by Brecht Van Lommel
2022-01-10 09:09:13 -08:00
1a27d20df3 Tests: disable all but one simple test for the Cycles Metal device
Until all tests are passing, this lets us run a basic test on the buildbot.

Ref T92212
2022-01-10 17:35:07 +01:00
39ba82f25d Fix T94111: nurb normal calculation does not work
The normals were computed with an uninitialized tilt.
2022-01-10 17:25:42 +01:00
af6a30ebf1 Fix compilation error after recent fix
For some reason GCC accepted C++-style of unused variable marking.
2022-01-10 17:17:31 +01:00
b0a83a6ed4 Fix compile error with msvc 2022-01-10 17:10:07 +01:00
292c2cefe3 Fix T93727: Tiled render error in Cycles after changing temp directory
Consider temporary directory to be variant part of session configuration
which gets communicated to the tile manager on render reset.

This allows to be able to render with one temp directory, change the
directory, render again and have proper render result even with enabled
persistent data.

For the ease of access to the temp directory expose it via the render
engine API (engine.temp_directory).

Differential Revision: https://developer.blender.org/D13790
2022-01-10 16:54:12 +01:00
20cb2c72a5 Fix second render failure with Cycles persistent data
The issue was caused by the recent changes in the way how the
render result is drawn: the display driver now could hold an
OpenGL resources. Those resources are not shared across contexts
so whenever OpenGL context is destroyed those resources are to
be destroyed as well (and not attempted to be re-used for a next
render).

Do such destruction and entire driver re-creation since it does
simplifies things from API usage point of view without causing
measurable slowdown.

Steps to reproduce the issue:
- Set the render resolution to 2x of Full HD
- Enable persistent data
- Render (F12)
- Render again

Observe OpenGL state being corrupted. Easy to see in debug mode
where IMM abstraction level reports issues about the buffer size
not being the proper size. This was caused by the display driver
trying to use VAO from the previous OpenGL context.

Differential Revision: https://developer.blender.org/D13789
2022-01-10 16:53:44 +01:00
d9dd8c287f Fix T94661: Out-of-bounds memory access due to malformed DDS image file
Harden bounds check in the stream reader avoiding integer overflow.
2022-01-10 14:27:54 +01:00
76d69bbb08 Fix Cycles compilation with Optix on Windows.
Since Optix 7.3 is required, update the default path accordingly.
2022-01-10 13:39:53 +01:00
8dd163160e Fix T94766: texture coordinates from other object do not refresh
The core issue is that flushing dependencies are created from an object
to a node tree when it contains e.g. a Texture Coordinate node.
That is an issue because the evaluation of the node tree itself does not
depend on the object (node tree evaluation is essentially a no-op).

Only other systems that parse and evaluate the node tree in a specific
context actually depend on e.g. the position of the referenced object.
It can even be the case that the node tree depends on objects that
the actual evaluator (geometry nodes modifier/material) does not depend
on, because a node is not connected to the output.

Geometry nodes makes the distinction between dependencies to the
node tree and to the evaluator already. Shader nodes do not.
Therefore, shader nodes need a flushing relation from node groups
to their parent node groups.

This brings back some unnecessary updates from rB7e712b2d6a0d
(e.g. when creating a node group from nodes that are not connected
to the output). This is a bit unfortunate, but refactoring how
dependencies work with shader nodes is a out of scope for this fix.
2022-01-10 13:02:57 +01:00
Demeter Dzadik
3ec88ae21d Fix error when keyframing with Custom Properties
Since rBf9ccd26b037d, calling `data.path_resolve()` on custom properties
with `None` value do not cause a `ValueError` exception any more. This
is now taken into account in the keying sets targeting custom
properties.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D13787
2022-01-10 13:01:01 +01:00
f5e90a943f Remove GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR.
Shader isn't used and not accessible via py-api.
2022-01-10 12:51:21 +01:00
8a772645e2 Remove GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR.
Shader isn't used and not accessible via py-api.
2022-01-10 12:51:21 +01:00
1b57dcf320 Remove GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA.
Shader isn't used and not accessible via py-api.
2022-01-10 12:51:21 +01:00
6669431846 Remove GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR.
Shader isn't used and not accessible via py-api.
2022-01-10 12:51:21 +01:00
e12a707692 Remove GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR.
Shader isn't used and not accessible via the py-api.
2022-01-10 12:51:21 +01:00
f813aab787 Remove GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA.
Shader isn't used and isn't accessible via py-api.
2022-01-10 12:51:21 +01:00
cfb3f5062d Cleanup: Remove unused source files. 2022-01-10 12:51:21 +01:00
3488339475 Cleanup: Consistent naming GPU_SHADER_2D_AREA_BORDERS. 2022-01-10 12:51:21 +01:00
227fd753df GPU: Remove unused UV shaders.
The UV shaders have been migrated to the overlay engine and aren't
accessible via the python API.
2022-01-10 12:51:21 +01:00
bd8fa07a3d Cleanup: add utility macro to simplify using std::enable_if 2022-01-10 12:28:33 +01:00
934db6a820 Fix T94409: GPencil smooth stroke thickness operator weird result
The smooth was not working "smoothly" and any change in the factor produced a weird result.
2022-01-10 12:23:52 +01:00
5aac794b11 Fix compile error in gpu test. 2022-01-10 12:16:25 +01:00
1b1e947162 Fix T94600: Apply single shrinkwrap constraint fails
rBd6891d9bee2b introduced a way to apply a single constraint from the
constraint stack. For this we want to work in the evaluated domain, in
particular the constraint target should be evaluated (the shrinkwrap
constraint needs to have access to the target's evaluated mesh).

Thx a lot to @sergey for handholding here!

Maniphest Tasks: T94600

Differential Revision: https://developer.blender.org/D13765
2022-01-10 11:57:54 +01:00
101fadcf6b Motion Path: Tweak the User Interface
This moves the clear paths button ("X") to the same line of "Update All Paths",
and make it visible at all times.

1. The clear button affects all objects (by default). However the
Calculate/Update Paths only works on the selected objects/objects.
Better to not have them both on the same line.

2. The operator to clear object and pose paths can run even if the active
object/bone has no motion path. However the UI was not showing the button in
those cases.

Before:
{F12757500, size=full}

After:
{F12757502, size=full}

Differential Revision: https://developer.blender.org/D13609
2022-01-10 11:40:37 +01:00
62e8d80a61 Fix out of bounds memory access displaying the compositor crop gizmo
Regression from typo in cbca71a7cf.
2022-01-10 21:09:30 +11:00
6beaa29791 Compositing Convert color space node
Compositor node to convert between color spaces.

Conversion is skipped when converting between the same color spaces or to or from data spaces.
Implementation done for tiled and full frame compositor.

Reviewed By: Blendify, jbakker

Differential Revision: https://developer.blender.org/D12481
2022-01-10 08:59:00 +01:00
eb7333e772 Cleanup: Wintab input processing.
Switched populating GHOST_WintabInfoWin32 vector from resizing and
assigning to reserving and pushing.

Removed unnecessary state tracking for multiple button presses in a
single packet.

Paired initialization with definition, and added default initialization
for GHOST_WintabInfoWin32.
2022-01-09 19:38:11 -08:00
1705587e21 Cleanup: note that compositor vector blur shares logic with zbuf.c
Note that some functions have been copied between these files.
De-duplication isn't trivial as there are differences in some functions.
2022-01-10 13:47:13 +11:00
74c896c081 Cleanup: typos in comments, remove libnumaapi reference 2022-01-10 13:47:12 +11:00
c04d36e922 Cleanup: Missing internationization for socket description 2022-01-09 18:39:34 -05:00
37d6ae16be Fix mistake in previous commit 2022-01-09 18:32:26 -05:00
17c7bac405 Cleanup: redundent semicolons after function braces 2022-01-09 18:24:48 -05:00
6110f3aa1f Cleanup: Use new socket builder API 2022-01-09 17:44:36 -05:00
ca0c69eaeb UI: Make uiTemplateNodeLink work for all socket types
Currently the node link ui template only works with a few socket types.
This commit addes support for the rest of the socket type declarations.

As pointed out in D13776 currently after recent refactors
Shader nodes no longer display in the menu.

In the future more socket types will be used in the shader nodes
and makes the UI template work better for other node trees.

Differential Revision: https://developer.blender.org/D13778
2022-01-09 11:49:08 -05:00
5519a6a520 Fix T94243: weightpaint gradient panel shown in other places
Weightpaint gradient tool panel showed in other modes (and as a separate
panel).

Fix for fix, see
- rBf8a0e102cf5e
- rBe549d6c1bd2d

So now, check mode again and restrict to topbar (prevents an additional
panel since this is already included in the brush settings).

ref rB0837926740b3 in sculpt-dev branch, so thx @joeedh as well!

Maniphest Tasks: T94243

Differential Revision: https://developer.blender.org/D13630
2022-01-09 11:31:57 +01:00
c5ee3ac7e0 Cleanup: Remove no op socket templates 2022-01-09 01:03:39 -05:00
e17ac8dc58 Cleanup: Nodes: Begin splitting shader node buttons into individual files
Currently, most node buttons are defined in `drawnode.cc` however,
this is inconvenient because it requires editing many files when adding new nodes.
The goal is to minimize the number of files needed to add or update a node.

This commit moves most of the node layout functions for shader nodes into their respected
source/blender/nodes/shader/nodes file.

In the future, these functions will be simplified to node_layout.

Some nodes were left in `drawnode.cc` as this would require duplicating code
while this is likely fine it is best to leave that to a seperate commit.
2022-01-09 00:59:34 -05:00
ed1ced2484 Cleanup: Use new socket builder API 2022-01-08 23:16:55 -05:00
9620fdc986 Cleanup: Remove no op socket templates 2022-01-08 22:15:47 -05:00
45bc4e3209 Fix T94713: Alembic crash with empty frames and velocities
Some software or processing tools (videogrammetry in this case) may
export malformed files with velocity data even when the frame is empty
for some reason. We need to explicity compare the data size with the
vertex size, and refuse to load the attribute if there is a data size
mismatch.
2022-01-08 20:46:28 +01:00
d5e73fa13d Fix T94534: dangling pointer in internal link after removing socket
The dangling pointer caused errors further down the line.
The solution is to simply delete an internal link when one
of the corresponding sockets is removed (just like normal
links are removed as well).
2022-01-08 17:36:59 +01:00
937aa8e114 Cleanup: Use new socket builder API 2022-01-07 23:53:57 -05:00
90e5ce6ab5 Cleanup: Loop through socket listbase instead of array
The socket arrays will be removed when using the new socket builder.
So instead we have to loop through the node outputs list.
2022-01-07 23:53:45 -05:00
741ed5fcd2 Fix Cycles compile error after last own commit
We can't include `BLI_utildefines.h` in `RNA_types.h` since Cycles includes
that, but duplicates some of the util defines. So you'd have duplicated
definitions.
2022-01-08 00:28:19 +01:00
34e84d0ee8 Cleanup: Remove unused code from BKE_node.h
Remove a variety of unused functions, declarations without definitions,
incorrect comments, and defines that have been commented for years
2022-01-07 16:16:56 -06:00
09d6846839 Fix Adjust Last Operation panel showing session UUID number button
This is implementation specific data that should never be exposed to regular
users. Also make sure this data is not saved to presets.
2022-01-07 23:06:29 +01:00
3e11c7016e RNA: Support bitwise operators for property flags in C++
Needed for the following commit.
2022-01-07 22:50:55 +01:00
5ba5678e00 Cleanup: Use forward declaration of struct in header
This meant that BKE_mesh.h couldn't be used without
the DNA headers first.
2022-01-07 12:42:04 -06:00
Aleksi Juvani
1152caad32 Fix: connecting hair fails on meshes with no generative modifiers
Fixes a bug introduced in rB5dedb39d447b. `mesh_original` is not set if the
mesh has no generative modifiers, in which case we can use `mesh_final`, which
would seem to be consistent with the rest of the particle code. An alternative
approach would be to make sure that `mesh_original` is always set in
`deformVerts`.

Differential Revision: https://developer.blender.org/D13754
2022-01-07 18:05:03 +01:00
Olivier Maury
34d553671d Fix wrong shadow terminator geometry offset with deformation motion blur
Differential Revision: https://developer.blender.org/D13759
2022-01-07 17:20:04 +01:00
Olivier Maury
ee0928d4be Fix wrong shadow terminator geometry offset for instances
Must take into account SD_OBJECT_TRANSFORM_APPLIED to determine if the normal
was already in world space.

Differential Revision: https://developer.blender.org/D13639
2022-01-07 17:20:04 +01:00
ae28d90578 Fix T93350: Cycles renders shows black during rendering huge resolutions
The root of the issue is caused by Cycles ignoring OpenGL limitation on
the maximum resolution of textures: Cycles was allocating texture of the
final render resolution. It was exceeding limitation on certain GPUs and
driver.

The idea is simple: use multiple textures for the display, each of which
will fit into OpenGL limitations.

There is some code which allows the display driver to know when to start
the new tile. Also added some code to allow force graphics interop to be
re-created. The latter one ended up not used in the final version of the
patch, but it might be helpful for other drivers implementation.

The tile size is limited to 8K now as it is the safest size for textures
on many GPUs and OpenGL drivers.

This is an updated fix with a workaround for freezing with the NVIDIA
driver on Linux.

Differential Revision: https://developer.blender.org/D13385
2022-01-07 17:20:04 +01:00
Michael Jones
efe3d60a2c Cycles: Fix Metal build
This patch fixes a couple of new Metal kernel compilation errors: 1) a kernel parameter count overflow, and 2) missing address space qualifiers.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13763
2022-01-07 16:19:31 +00:00
b7ea6e9d0e LibOverrides: small refactor of resync main public function.
Simplify signature of `BKE_lib_override_library_resync` and make it a
shallow wrapper around new internal `lib_override_library_resync` that
can then be easily extended for other internal needs.

Not functional changes expected here.
2022-01-07 15:25:25 +01:00
Germano Cavalcante
5560f32447 Fix T94078: Wrong Bound Box calculated for curves
`DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN` creates temporary objects that
correspond to duplicates or instances.

These temporary objects can share same pointers with the original object
as in the case of Bounding Box.

Bound Box of temporary objects is marked dirty in
`BKE_object_replace_data_on_shallow_copy` since `ob->data` is different.

This causes the original Bounding Box, calculated for the evaluated
geometry, to be lost.

The solution in this commit is to change the boundbox reference of the
temporary objects, so the boundbox of the non-temporary object (with
the data curve) is not marked dirty.

Differential Revision: https://developer.blender.org/D13581
2022-01-07 10:42:13 -03:00
5085c622ea Cleanup: Remove unused numapi library 2022-01-07 12:19:02 +01:00
312aa67cc7 Remove dead numaapi code in blenlib
It it rather an old experiment now which didn't pay off.
The initial idea was to have main and jobs threads on fast
nodes of TR2 processors. This didn't really work reliably
because in Blender we need to be able to create nested
threads without their affinity set. This is not how some of
OS are creating nested threads, and we don't always have
access to child threads to reset their affinity.

So overall complexity of the initial idea implementation
became too much compared to the performance gain.
2022-01-07 12:19:02 +01:00
ed52de948c LibOverride: Add tag to libraries that had to be recursively resynced.
Request from studio, to help identify quickly libs that need update.

NOTE: Currently only outputing INFO log in console, display of this info
in the outliner will come in a separate commit.
2022-01-07 12:09:50 +01:00
2cc6b249c3 Cycles: Remove usage of libnumaapi
No need for it now since all the threading queries and
scheduling is done via TBB.

Should be no functional changes as all the removed code
is supposed to be unused.
2022-01-07 11:47:37 +01:00
Jagannadhan Ravi
361702f239 Fix T94310: Blender doesn't support with 128 threads well in Win11
Query TBB for the maximum allowed concurrency, which is free from a bug
in own concurrency detection code. One thing to keep in mind is that now
Cycles is limited by the number of threads in the TBB areana from which
Session is created. This isn't a problem for Blender since we do not limit
arena on Blender side. Could be something to watch out for in other Cycles
integrations.

Differential Revision: https://developer.blender.org/D13658
2022-01-07 11:37:30 +01:00
bef2412ca2 Fix T86952: Buffer overflow reading specific DDS images
Add a data boundary check in the flipping code.

This code now also communicates the number of mipmap levels
it processed with an intent to avoid GPU texture from using
more levels than there are in the DDS data.

Differential Revision: https://developer.blender.org/D13755
2022-01-07 11:15:17 +01:00
29e33cfff5 Fix T94659: crash when deleting instances (part 2)
This was missing from rB3e92b4ed2408eacd126c0.
Before only the Separate Geometry node was fixed, because that
node was used in the file from the bug report. The same issue
existed in the Delete Geometry node as well though.
2022-01-07 08:21:34 +01:00
6c906b7c21 Fix T94707: inverted output of separate geometry node incorrect
This was an oversight in rB3e92b4ed2408eacd126c0.
2022-01-07 08:11:25 +01:00
7c04bc9a01 Cleanup: exclude uiFont from DNA, rename filename -> filepath
This isn't saved to the preferences,
so there is no need to store in DNA.

Also remove unused `r_to_l` member.
2022-01-07 18:05:36 +11:00
f24854005d Fix T94708: negative reference count error with Python API callbacks
Regression in 7972785d7b that caused
Python callback arguments to be de-referenced twice - potentially
accessing freed memory. Making a new-file with a circle-select
tool active triggered this (for example).

Now arguments aren't de-referenced when Blender it's self has already
removed the callback handle.
2022-01-07 17:48:54 +11:00
1642028310 Cleanup: use the ELEM macro 2022-01-07 17:48:25 +11:00
82858ca3f4 Fix T94629: The IMB_flip API would fail with large images
Fix IMB_flip[xy] to handle cases where integer overflow might occur when
given sufficiently large image dimensions.

All of these fixes were of a similar class where the intermediate
sub-expression would overflow silently. Widen the types as necessary.

Differential Revision: https://developer.blender.org/D13744
2022-01-06 21:35:04 -08:00
b3dc1a17a0 Fix BKE_image_ensure_tile_token being called with a full path
Assert that only the file name component is passed in
since special handling for UDIM should only be applied to the file name.

Also remove an unnecessary NULL check on the filename argument.
2022-01-07 15:15:08 +11:00
2cd8238ce3 Cleanup: use static sets for comparison, quiet unused arg warnings 2022-01-07 14:47:27 +11:00
f48164b5ea Cleanup: rename sculpt_brushes.c -> sculpt_brush_types.c
This better differentiates sculpt brush types with brush data-blocks,
since the same sculpt brush type may be used for many brushes.
2022-01-07 14:28:49 +11:00
3d3bc74884 Cleanup: remove redundant const qualifiers for POD types
MSVC used to warn about const mismatch for arguments passed by value.
Remove these as newer versions of MSVC no longer show this warning.
2022-01-07 14:16:26 +11:00
bb69c19f08 Cleanup: Fix spelling in filename 2022-01-06 20:51:23 -05:00
e6ca0b33e9 Cleanup: Add bf_nodes_texture library
For sake of consistencey with other node tree types, create its own cmake module.
This change helps keep `bf_nodes` focused on  generic nodes files.

Texture nodes are end of life and hopefully for Blender 4.0 they can be removed.
It is not expected that these will see the updates that the other nodes are getting.
This change also helps isolate the end of life files, we may move some texture
specific node tree execution code out of `node_exec` and into a `node_texture_exec` files.

Differential Revision: https://developer.blender.org/D13743
2022-01-06 18:21:01 -05:00
ed9b21098d Cleanup: Use new socket builder API
This commit converts most shader or bsdf nodes.
2022-01-06 17:57:30 -05:00
3ae664363d Fix T94635: Sculpt Smooth in Surface mode with Anchored Stroke crash
Sculpt Smooth in Surface mode (as opposed to Laplacian) needs a cache
initialized on first time. In anchored stroke mode with spherical falloff
this was skipped though (because this starts of with no PBVH nodes and
an early return checks for this) and `first_time` was set to false before
cache initialization.

Now move the cache initalization to happen earlier (same as the cache
initialization for automasking).

Maniphest Tasks: T94635

Differential Revision: https://developer.blender.org/D13746
2022-01-06 20:55:43 +01:00
3a4952e7c2 Fix Cycles updating display unnecessarily when stopping 3D viewport
Debug code accidentally committed in 466b50d. This was found while
investigating issues with D13385.
2022-01-06 19:10:50 +01:00
0c6b29ee43 Fix T94672: incorrect Workbench shadows with GPU subdivision
The `lines_adjacency` IBO build in the GPU subdivision case was missing
edges at the boundaries of open meshes. As it is used for the shadow
pass, the shadows were then not clipped properly.

This would also make X-Ray mode render differently in those cases.

To fix this, we can simply reuse the buffer finalization routine from the
non-subdivision case, as such edges are handled there.
2022-01-06 16:25:09 +01:00
c2089ae53c GPU subdiv: fix wrong data sizes used for lines adjacency IBO
Function parameters were mismatched, causing an assertion failure in
debug builds.
2022-01-06 16:24:52 +01:00
ddae2d88fa Depsgraph: only link 'IK Constraint -> Init IK Tree' if animated.
This relation is intended to ensure that the properties of the IK
constraint are ready by the time the IK solver tree is built. This
however can cause spurious dependency cycles, because there is only
one init tree node for the whole armature, and the relation actually
implies dependency on all properties of the bone.

This patch reduces spurious dependencies by only creating the relation
if any properties of the IK constraint specifically are animated.

Differential Revision: https://developer.blender.org/D13714
2022-01-06 16:43:18 +03:00
1785286ecc Bone Overlay: support changing bone wireframe opacity.
When weight painting the bone overlay is extremely intrusive,
effectively requiring either extensive use of hiding individual
bones, or disabling the whole bone overlay between selections.

This addresses the issue by adding a bone opacity slider that
is used for the 'wireframe' armature drawing mode. It directly
controls the uniform opacity as a straightforward option.

Differential Revision: https://developer.blender.org/D11804
2022-01-06 16:43:18 +03:00
7bcf21e66e Depsgraph: fix spurious cycles with identically named idprops on bones.
If multiple bones have a custom property with the same name,
depsgraph didn't distinguish between them, potentially leading
to spurious cycles.

This patch moves ID_PROPERTY operation nodes for bone custom
properties from the parameters component to individual bone
components, thus decoupling them.

Differential Revision: https://developer.blender.org/D13729
2022-01-06 16:43:18 +03:00
08aa7861d6 Fix T94685: python error adding Space handlers for Spreadsheet
Oversight in {rB9cb5f0a2282a}.

Above commit made an entry in `rna_Space_refine()`, but the entry in
`rna_Space_refine_reverse()` was missing (and this is what python uses
for the Space callbacks).

Maniphest Tasks: T94685

Differential Revision: https://developer.blender.org/D13751
2022-01-06 13:47:35 +01:00
45277d804e Cleanup: use correct file namespace name 2022-01-06 13:25:42 +01:00
d31b8c316f Cleanup: typos in code. 2022-01-06 11:48:44 +01:00
88e15ff1e6 Fix T94674: crash reading ORCOs from an Alembic animation
The crash is caused as the data is only for the first frame, but the mesh
changes topology, so reading the data in subsequent frames causes a
buffer overflow. To fix this, we check that the data size matches the
mesh's vertex count.
2022-01-06 11:48:44 +01:00
ed3fecae8e Cleanup: USD/ABC, remove const from pass-by-value params
Remove `const` from pass-by-value parameters in function declarations.
The variables passed as parameters can never be modified by the function
anyway, so declaring them as `const` is meaningless. Having the
declaration there could confuse, especially as it suggests it does have
a meaning, training people to write meaningless code.
2022-01-06 11:41:03 +01:00
f9aa6376f1 Cleanup: anim, remove const declarations from pass-by-value params
Remove `const` from pass-by-value parameters in function declarations.
The variables passed as parameters can never be modified by the function
anyway, so declaring them as `const` is meaningless. Having the
declaration there could confuse, especially as it suggests it does have
a meaning, training people to write meaningless code.
2022-01-06 11:41:03 +01:00
1484fe260b Cleanup: Replace FINISHED with CANCELLED
As the operator does nothing, better use cancelled.
2022-01-06 10:22:32 +01:00
e766dc9189 Fix (unreported) crash in liboverride after yesterday's commit.
Own mistake in rBbfb760e16acb.
2022-01-06 10:01:07 +01:00
6f389f1bb8 Cleanup: move public doc-strings into headers
Some recent changes re-introduced public-style doc-strings
in the source file.
2022-01-06 19:25:24 +11:00
c12607baa3 Cleanup: quiet GCC stringop-overflow in bmesh_beautify.c
Also elaborate on the doc-string.
2022-01-06 13:54:56 +11:00
66a4da87f4 Cleanup: sort cmake file lists 2022-01-06 13:54:55 +11:00
ed68e18c1c Cleanup: remove unnecessary slashes and quotes from paths in CMake 2022-01-06 13:54:54 +11:00
2ee37e9031 Cleanup: remove redundant/unused assignment
SRC was being assigned invalid values then overwritten.
2022-01-06 13:54:53 +11:00
499fec6f79 Cleanup: spelling in comments 2022-01-06 13:54:52 +11:00
aa363ec2ae Cleanup: remove declaration for removed function 2022-01-06 13:54:51 +11:00
61e2384b7a Cleanup: compiler warnings 2022-01-06 13:54:49 +11:00
60757f010a CMake: add missing headers 2022-01-06 13:54:48 +11:00
0e53ea4cb5 Correct error when moving doc-strings into header
Error in ffc4c126f5,
which moved doc-strings from implementation into headers.

Some changes in BKE_animsys.h needed to done manually as there
were already doc-strings in both the header and implementation
(with overlapping information).
When making these changes some doc-strings were removed unintentionally.

Thanks for @sybren for the heads up.
2022-01-06 13:54:46 +11:00
4067367b6c Cleanup: Clang-tidy: modernize-redundant-void-arg 2022-01-05 21:44:22 -05:00
c0fb8ea8f3 Cleanup: Spelling/grammar in comments 2022-01-05 19:03:05 -06:00
1d9bac7d92 Cleanup: Use snake case for file names
This is so that we can have "proper" file namespace names in D13466
2022-01-05 17:15:13 -05:00
0e1da8dd12 In obj exporter test, fix a strncpy length and a stray test file left behind. 2022-01-05 17:05:53 -05:00
e55a6bf82b Cleanup: Remove empty node socket template array 2022-01-05 16:45:41 -05:00
c240ab70ae Cleanup: Use new socket builder API
Instead of looping through the old socket template array
looper through the node output listbase.
2022-01-05 16:27:29 -05:00
7c013f1154 Fix: MSVC build error
MSVC2017 and early 2019 versions are under
the impression struct OGLRender is non trivial
type due to the ThreadCondition field, not
entirely sure why, but it is what it is.

Differential Revision: https://developer.blender.org/D13742

Reviewed by: JacquesLucke
2022-01-05 14:02:07 -07:00
611da3b7d6 Cleanup: Use new socket builder API 2022-01-05 15:47:15 -05:00
50f694c7de Cleanup: Use new socket builder API
Also enables translation of socket names
2022-01-05 15:47:15 -05:00
a5b4373f95 Fix/workaround macOS Rosetta crash running Cycles AVX tests
Just disable these tests on macOS for now as fixing seems hard, and we want to
be able to cross-compile and test x86_64 on Arm machines on the buildbot.
2022-01-05 21:21:13 +01:00
cdd61bb6d7 Fix Cycles AVX test failure with x86_64 build running on Arm
Don't create const avx vectors before validating if CPU supports AVX.
2022-01-05 20:05:16 +01:00
f7a0f6a0e4 Fix T94563: Cycles standalone build error on with strict float/double casting
Thanks to John David for finding this.
2022-01-05 20:05:16 +01:00
1dc0bf86bb Fix T93695: Discontinuous cutting with the knife tool
An important check to reject edge linehits when a vertex of that edge
was already hit was accidentally removed in
rB6e77afe6ec7b6a73f218f1fef264758abcbc778a
2022-01-05 18:32:23 +00:00
a0edee712a Cleanup: Remove unused node_type_exec for shader node
From what I can tell these are left over from Blender Internal render.

Test still pass locally, also tested a couple eevee scenes.

Reviewed By: JacquesLucke, brecht

Differential Revision: https://developer.blender.org/D13732
2022-01-05 11:52:57 -05:00
8cd6d0fe68 Fix T94169: Missing grease pencil render with tiled rendering
Delay grease pencil for until after the render result is written
to the Blender side.

Differential Revision: https://developer.blender.org/D13740
2022-01-05 17:47:10 +01:00
3c04b44913 Fix Cycles allocating result too early
When tiled rendering was used the render result was
allocated at the end of every view layer render as
opposite of an intended end of all rendering.

Modify the render_result_end so that it only ensures
pixels are allocated if pixels are actually copied
over.
2022-01-05 17:47:10 +01:00
5e7e571b0d Fix Cycles using Cancel semantic on final result write
Seems like a copy-paste bug from another place.
2022-01-05 17:47:10 +01:00
bfb760e16a Fix T94650: LibOverride: Bad handling of (auto)resync in case of single override.
Overrides that are not created as part of an override hierarchy should
not be handled through (auto)resync at all. users are responsible to
hanlde those updates if they need it.

This is achieved by flagging overrides created outside of a hierarchical
process accordingly, and skipping them during resync process.
2022-01-05 17:30:22 +01:00
1403f034ff LibOverride: Cleanup some code.
No functional change.
2022-01-05 17:30:22 +01:00
b63f375775 Assets: disable automatic preview generation for node groups
The current preview generation is more confusing than useful.
Therefore it is better to disable it until better preview generation
methods are found.

Differential Revision: https://developer.blender.org/D13728
2022-01-05 17:01:52 +01:00
3e92b4ed24 Fix T94659: crash when deleting instances
The crash was caused by using `modify_geometry_sets` to modify
instances, which does not generally work unfortunately.
The intended behavior was wrong anyway. In instances mode,
only top level instances should be deleted.

Also removed the old error handling because it doesn't look like it
ever worked. all_is_error remained false all the time.
Furthermore, updating it was not thread safe.

Differential Revision: https://developer.blender.org/D13736
2022-01-05 16:55:09 +01:00
Aleksi Juvani
5dedb39d44 Fix T54488: hair disconnect/reconnect not working with modifiers
Take the Use Modifier Stack setting into account when connecting hair, and
fix wrong results results when using deforming modifiers also.

Differential Revision: https://developer.blender.org/D13704
2022-01-05 16:53:54 +01:00
1031638c51 Cleanup: rename mesh -> geom in some places that now handle multiple geom types 2022-01-05 16:06:34 +01:00
f64d7bfa4a Cleanup: compiler warnings about unused code 2022-01-05 16:06:23 +01:00
8393ccd076 Cycles: Add OptiX temporal denoising support
Enables the `bpy.ops.cycles.denoise_animation()` operator again and modifies it to support
temporal denoising with OptiX. This requires renders that were done with both the "Vector"
and "Denoising Data" passes.

Differential Revision: https://developer.blender.org/D11442
2022-01-05 15:58:36 +01:00
86141a75eb Cleanup: fix typos in source code in intern/
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D13532
2022-01-05 15:35:30 +01:00
29ab711efa Cleanup: Remove unused code (USE_COLOR_U32) 2022-01-05 15:00:07 +01:00
4c3f52e7dc Cycles: support rendering PointCloud motion blur from attribute
This adds support to render PointCloud motion blur from a standard
"velocity" attribute.

This implementation is similar to that of the Mesh geometry, and
perhaps some code could be deduplicated through a more generic API.
`mesh_need_motion_attribute` was renamed `object_need_motion_attribute`
as it does not really require a mesh and moved to `util.h` so that
it can be shared.

This fixes T94622.

Reviewed By: brecht

Maniphest Tasks: T94622

Differential Revision: https://developer.blender.org/D13719
2022-01-05 14:17:57 +01:00
b1bd0f8ffd Enable OpenEXR DWAB compresstion
The DWAB compression was disabled in the d59721c2c3 due to
a bug in the OpenEXR library which is now resolved.

Re-enable the DWAB compression for OpenEXR output. It is a
simple change, and DWAB often behaves better than DWAA.

Differential Revision: https://developer.blender.org/D13713
2022-01-05 14:07:21 +01:00
13e7065dd2 Fix T94564: Mirror clipping is not properly placed in sculpt mode
If a mirror object is used in a mirror modifier, sculptmode did not take
this into account (and instead always clipped on the sculpt objects
local axis).

Now take this into account by storing a matrix in the preparation
function `sculpt_init_mirror_clipping` and use that later in
`SCULPT_clip`.

Maniphest Tasks: T94564

Differential Revision: https://developer.blender.org/D13711
2022-01-05 13:23:37 +01:00
924d2b8df6 Fix T94506: Crash in Compositing 2022-01-05 12:31:37 +01:00
d960c78693 Fix T94545: support realizing instanced collections
This case wasn't handled in rBf5ce243a56a22d718 correctly.
Now `object_get_evaluated_geometry_set` just returns a geometry
set that contains the collection instance for collection instance objects.
2022-01-05 11:47:09 +01:00
33400ffcc9 IDManagement: Add assert against no-main IDs passed to BKE_id_delete.
This high-level function can only deal with IDs in main, trying to use
it to delete/free a no-main ID does nothing.
2022-01-05 10:39:09 +01:00
5df916f23f Fix T94366: Grease Pencil Automerge no immediate UI update
Just an oversight in rBe9607f45d85d.
Now add notifier that toolsettings changed.

Maniphest Tasks: T94366

Differential Revision: https://developer.blender.org/D13723
2022-01-05 09:13:52 +01:00
b7073fa797 Cleanup: Use new socket builder API 2022-01-05 00:59:18 -05:00
458be2ecc4 Nodes: Consistent link drag search for math and vector math nodes
Previously operations for the math node when connecting to
outputs weren't added. It also used a different method to
check whether the link would be valid.
2022-01-04 23:19:12 -06:00
5336fdc6e3 Cleanup: Make shade node util header CPP only
Now that all shader nodes are converted to CPP
this header can now be made into a CPP header.
2022-01-04 23:25:27 -05:00
713d59bcaf Fix T89587: Don't Change Line Width For Previews
Do not temporarily change U.pixelsize while creating object previews
in object_preview_render. It does nothing to the render, but the change
in line width can affect other UI drawing since it is done in a thread.

see D13717 for for details.

Differential Revision: https://developer.blender.org/D13717

Reviewed by Julian Eisel
2022-01-04 15:51:18 -08:00
e3748d7fa5 Fix T94145: Knife tool fails in orthographic mode
Calculating min and max orthographic extent forgot to convert to
worldspace coordinates.
2022-01-04 20:26:09 +00:00
07de17ded6 Cleanup: Dont use relative include
Instead let cmake determine the path for file includes
2022-01-04 11:58:21 -05:00
Aaron Carlisle
25018dc061 Cleanup: Nodes: Convert generic shader node files to c++
Along with the general changes to CPP this commit does the following

- Use static casts where possible
- Use new CPP MEM library functions instead of cast
- Use listbase macros where possible
- Declare variables where initialized

Reviewed By: HooglyBoogly, JacquesLucke

Differential Revision: https://developer.blender.org/D13718
2022-01-04 11:42:40 -05:00
f7c0287278 Fix: Link drag search error with random value node from color socket
Dragging from a color socket would hit an assert in a debug build.
The node does not have a color mode currently, so use the vector mode
instead when connecting to a color socket.
2022-01-04 10:32:32 -06:00
55842b4244 Fix T94620: GPencil AutoMerge does not work when Draw On Back is enabled
The problem was the stroke was added to head and the `prev` pointer was NULL. Now check if there is the list is empty`next`.
2022-01-04 17:08:05 +01:00
ad8e2d6661 Fix T94308: Window Manager console error 2022-01-04 17:00:05 +01:00
bbd0c4118b Fix: Build issue with MSVC
std::min was used without including the algorithm
header. Seems to be implicitly included by
something in newer MSVC versions and GCC, however
vs16.4 needed a little help here.
2022-01-04 07:15:51 -07:00
54e2f851a4 Cleanup: Code formatting. 2022-01-04 14:07:27 +01:00
070948b5f1 Fix T94546: Remove soft limit for the Clamp Node value socket. 2022-01-04 12:26:16 +01:00
f7018f7b06 Fix T94544: crash removing image used as camera background via python
Since 2.8, background images are tied to cameras (in 2.79 these were
tied to a View3D I think).
Code in `BKE_library_id_can_use_idtype` wasnt taking this relation
between `Camera` and `Image` into account, thus leading to ID deletion/
unlinking not working properly -- in particular `libblock_remap_data`
not doing its thing (and leaving the camera as a user of the image),
then things went downhill from there...

Now make the "Camera-can-use-an-Image" relation clear in
`BKE_library_id_can_use_idtype`.

Maniphest Tasks: T94544

Differential Revision: https://developer.blender.org/D13722
2022-01-04 12:13:05 +01:00
b2867d4365 Fix T94599: Assert on usercount when deleting image created via operator.
`IMAGE_OT_new` operator would not properly clear the by-default one user
generated by 'new id' code, in case it could not tie the image to
anything.
2022-01-04 10:03:31 +01:00
Manuel Castilla
a2a02e3994 Fix T90830: Crop node cropping is one pixel short
Currently the crop higher limits are inclusive too which contradicts
the documentation as it says that if Left and Right are both 50, it
will result in a zero-sized image. And the result is one pixel out of
the crop gizmo, which is another hint that this is not intended.

In "Full Frame" experimental mode it's two pixels short because of
a misuse of `BLI_rcti_isect_pt` as it considers max limits inclusive.

Reviewed By: jbakker

Maniphest Tasks: T90830

Differential Revision: https://developer.blender.org/D12786
2022-01-04 08:22:37 +01:00
Aidan Davey
325beef7af Fix T91160 - Movie Clip Editor - frame indicator/controller is not displayed
The frame indicator/controller is not displayed when in the Graph or Dopesheet view of the Movie Clip Editor

To solve this we could call the function ED_time_scrub_draw_current_frame in clip_draw_dopesheet_main and graph_region_draw in space_clip.c

Reviewed By: jbakker

Maniphest Tasks: T91160

Differential Revision: https://developer.blender.org/D12659
2022-01-04 08:21:13 +01:00
Aaron Carlisle
7af01de802 Shader Nodes: Unity Build
Enable unity builds for  `bf_nodes_shader`, gives about a 2.7x speedup
of total compile times when just building `bf_nodes_shader`.
On my machine, this equates to saving about 30 seconds.

Differential Revision: https://developer.blender.org/D13720
2022-01-03 23:10:36 -05:00
a9e0caa92d Cleanup: Move node storage macro inside file namespace
Must have been a mistake in previous commits,
this fix is needed to enable unity builds.
2022-01-03 21:52:20 -05:00
d2cc672b0c Fix soft light blend mode math
Function `blend_color_softlight_float` used math different to compositor and
produced result that had abrupt value changes.

Use math based on modified screen blend mode as compositor does.
2022-01-04 02:11:38 +01:00
9c85acf61d Fix out of range color in blend modes
Result of Exclusion and Pin Light blend modes could be greater than 255
which caused artifacts. Limit color value to 0-255 range.
2022-01-04 02:11:38 +01:00
Aaron Carlisle
d3ad04172d Cleanup: Remove bNodeType flag from base registration functions
This flag is only used a few small cases, so instead
of setting the flag for every node only set the
required flag for the nodes that require it.

Mostly the flag is used to set `ntype.flag = NODE_PREVIEW`
For nodes that should have previews by default which
is only some compositor nodes and some texture nodes.

The frame node also sets the `NODE_BACKGROUND` flag.

All other nodes were setting a flag of 0 which has no purpose.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13699
2022-01-03 19:33:14 -05:00
9793bc30ce BLI: Add slice method to MutableSpan
Span had a slice method with an IndexRange argument, but MutableSpan
did not, yet. This commit makes the two types consistent.
2022-01-03 16:27:13 -06:00
675d3cdd69 Cleanup: Clang tidy 2022-01-03 13:52:55 -06:00
4e44cfa3d9 Add a new C++ version of an exporter for the Wavefront .obj format.
This was originally written by Ankit Meel as a GSoC 2020 project.
Howard Trickey added some tests and made some corrections/modifications.
See D13046 for more details.

This commit inserts a new menu item into the export menu called
"Wavefront OBJ (.obj) - New".
For now the old Python exporter remains in the menu, along with
the Python importer, but we plan to remove it soon (leaving the
old addon bundled with Blender but not enabled by default).
2022-01-03 14:49:31 -05:00
c6069c439c Fix T94581: Incorrect geometry delete behavior with instances
Compare the start of the range to zero to figure out whether the
indices for the instances to keep starts at zero. Also rename the
selection argument, since it made it seem like the selected indices
should be removed rather than kept.
2022-01-03 13:19:04 -06:00
a42e972e1b Fix T94316: Asset catalog tree scrolls away when renaming a catalog
The activation of the text button is a bit special, since it happens during
drawing, the layout isn't computed yet then. Comparable cases where the button
is added on top don't use the layout system, so this didn't become an issue
until now. Trigger a delayed call to `UI_but_ensure_in_view()`.
2022-01-03 19:55:49 +01:00
1b9e103a30 Fix T94594: Incorrect spreadsheet data set region type in old files
This completes 1a721c5dbe by versioning old files to correct the
region type. The "tools" region type is relatively standard for this type
of region and doesn't require any changes to the theme, unlike
the "nav bar" type, which would have been a reasonable choice.
2022-01-03 12:54:40 -06:00
b7ad58b945 Geometry Nodes: Edge Angle Node
Calculates the angle in radians between two faces that meet at an edge.
0 to PI in either direction with flat being 0 and folded over on itself PI.
If there are not 2 faces on the edge, the angle will be 0.

For valid edges, the angle is the same as the 'edge angle' overlay.

For the Face and Point domain, the node uses simple interpolation to calculate a value.

Differential Revision: https://developer.blender.org/D13366
2022-01-03 11:16:50 -06:00
ca143fafa6 Cleanup: Silence "integer conversion resulted in a change of sign" warning in Cycles kernel code
Occured because "PATH_RAY_SHADOW_CATCHER_BACKGROUND" is expressed as an unsigned
integer, because too large for a signed integer, but the "PathRayFlag" enum type defaulted to a
signed integer still.
2022-01-03 16:28:44 +01:00
8f9f65bc29 Allow overrides for cloth, collision and force field properties.
Allow overriding simple properties of cloth simulations, colliders
and force fields. Vertex group and shape key selectors in cloth are
still not overridable since they are tied to mesh data.

Force fields have a number of physical fields shared between multiple
RNA fields. Until they are decoupled, they will produce redundant
overrides, and cannot have different hard range limits.

Differential Revision: https://developer.blender.org/D13710
2022-01-03 18:06:13 +03:00
8189471912 Fix T94392: 3D Cursor surface projection onto hidden geometry
Regression introduced in rB098008f42d8127d9b60717c7059d3c55a3bfada7

Previously the selected geometry was ignored along with the hidden one.

The mentioned commit caused neither the hidden nor the selected one to be ignored.

But hidden geometry needs to be ignored.
2022-01-03 11:52:02 -03:00
a230445cae Depsgraph: Remove object-level visibility from geometry builders
Continuation of the D13404 which finished the design of not having
geometry-level nodes dependent on object-level.

Differential Revision: https://developer.blender.org/D13405
2022-01-03 15:30:14 +01:00
a3e634d4d7 Cleanup: Unused variable in Cycles code 2022-01-03 14:46:10 +01:00
6a4ee3fd56 Fix (unreported) i18n utils failing to create MO files in trunk.
Not really important anymore, since those are not used by Blender, but
better be consistent.
2022-01-03 11:48:24 +01:00
e51864a357 Add Georgian to our list of languages.
CC @Tamuna who started the translation for this language.
2022-01-03 11:13:15 +01:00
0a4bd32e59 Blender font: Add georgian script.
Weirdly enough, our 'mono' font already had it, but not the main one.

Copied from DeJaVu sans font.

CC @Tamuna who started the translation for that language.
2022-01-03 11:12:55 +01:00
add4aa7d25 Install_deps: Also cleanup CLANG CMAKE variables
Needed together with LLVM cleanup, otherwise things fail when LLVM gets
updated.
2022-01-03 10:39:37 +01:00
2e00d90938 Cleanup: Renamed to_object_value to to_dictionary_value. 2022-01-03 10:25:16 +01:00
e2fdc6226a Cleanup: rename ValueType.Object to ValueType.Dictionary. 2022-01-03 10:23:09 +01:00
ea8d749587 Cleanup: Rename ObjectValue to DictionaryValue (Serialization).
ObjectValue was to confusing as it is the term from JSON.
2022-01-03 08:10:21 +01:00
180b66ae8a UDIM: Support virtual filenames
This implements the design detailed in T92696 to support virtual
filenames for UDIM textures. Currently, the following 2 substitution
tokens are supported:

| Token | Meaning |
| ----- | ---- |
| <UDIM>   | 1001 + u-tile + v-tile * 10 |
| <UVTILE> | Equivalent to u<u-tile + 1>_v<v-tile + 1> |

Example for u-tile of 3 and v-tile of 1:
filename.<UDIM>_ver0023.png   --> filename.1014_ver0023.png
filename.<UVTILE>_ver0023.png --> filename.u4_v2_ver0023.png

For image loading, the existing workflow is unchanged. A user can select
one or more image files, belonging to one or more UDIM tile sets, and
have Blender load them all as it does today. Now the <UVTILE> format is
"guessed" just as the <UDIM> format was guessed before.

If guessing fails, the user can simply go into the Image Editor and type
the proper substitution in the filename. Once typing is complete,
Blender will reload the files and correctly fill the tiles. This
workflow is new as attempting to fix the guessing in current versions
did not really work, and the user was often stuck with a confusing
situation.

For image saving, the existing workflow is changed slightly. Currently,
when saving, a user has to be sure to type the filename of the first
tile (e.g. filename.1001.png) to save the entire UDIM set. The number
could differ if they start at a different tile etc. This is confusing.
Now, the user should type a filename containing the appropriate
substitution token. By default Blender will fill in a default name using
the <UDIM> token but the user is free to save out images using <UVTILE>
if they wish.

Differential Revision: https://developer.blender.org/D13057
2022-01-02 20:48:59 -08:00
Aaron Carlisle
367fc69dc1 Nodes: Convert several shader nodes to c++
Also add file namespace

This is needed to use new node APIs

Differential Revision: https://developer.blender.org/D13690
2022-01-02 23:35:20 -05:00
8be217ada5 Geometry Nodes: add field node type for constants
It is common to have fields that contain a constant value. Before this
commit, such constants were represented by operation nodes which
don't have inputs. Having a special node type for constants makes
working with them a bit cheaper.

It also allows skipping some unnecessary processing when evaluating
fields, because constant fields can be detected more easily.

This commit also generalizes the concept of field node types a bit.
2022-01-02 14:27:16 +01:00
4c46203cb5 Geometry Nodes: small refactor towards supporting partially lazy nodes
Currently, a node either supports lazyness during execution (like the Switch
node), or it doesn't. If it does support lazyness, then every input is computed
lazily. However, usually not all inputs actually have to be computed lazily.
E.g. the boolean switch input is always required, while the other inputs
should be computed lazily.

Better support for such sockets  can avoid unnecessary round trips through
the node execution function.
2022-01-01 12:50:48 +01:00
Charlie Jolly
6844304dda Nodes: Add Compare node operations to link drag search menu
Exposes compare operations via rna emums.
This uses the rna enum to build the search list using
named operations linked to socket A.
This also weights the Math Node comparison operations lower
for geometry node trees.

Differential Revision: https://developer.blender.org/D13695
2021-12-31 20:32:42 +00:00
e79b4523b4 LineArt: Correct collection intersection mask logic.
The logic used to be:

"if collection doesn't have child collection, check if ob is from this one"

The correct logic should be:

"if collection child does not have this ob, then check this collection".
2021-12-31 21:54:07 +08:00
97ae08c9fc LineArt: Correct clamping of out of bound isect index
Handles rare cases where line doesn't intersect the triangle correctly.
2021-12-31 21:26:39 +08:00
d09b1d2759 Fix T94464: video texture is not refreshing
In the past that worked because the `GPUMaterial` referenced the
`ImageUser` from the image node. However, that design was incompatible
with the recent node tree update refactor (rB7e712b2d6a0d257d272e).
Also, in general it is a bad idea to have references between data that is
owned by two different data blocks.

This incompatibility was resolved by copying the image user from the node
to the `GPUMaterial` (rB28df0107d4a8). Unfortunately, eevee depended
on this reference, because the image user on the node was update when the
frame changed. Because the image user was copied, the image user in the
`GPUMaterial` did not receive the frame update anymore.

This frame update is added back by this commit. The main change is that
the image user iterator now also iterates over image users in `GPUMaterial`s
on material and world data blocks. An issue is that these materials don't
exist on the original data blocks and that caused the check in
`build_animation_images` in the depsgraph to give the wrong answer.
Therefore the check is extended.

Right now the check is not optimal, because it results in more depsgraph
nodes than are necessary. This can be improved when it becomes cheaper
to check if a node tree contains any references to a video texture.
The node tree update refactor mentioned before makes it much easier
to construct this kind of run-time data from the bottom up, instead of
scanning the entire node tree recursively every time some information
is needed.
2021-12-31 14:24:11 +01:00
56344fb30f Cleanup: Silence warning for wrong const char comparison
Incorrectly used comparison for empty string.

Reported in chat by @jacqueslucke.
2021-12-31 13:05:58 +00:00
018272ee5b Fix T94416: incorrect handling when nodes are linked in a loop
This just skips the entire algorithm when there are cycles.
In the future, cycles could be handled more gracefully in the
algorithm, but for now that's not worth it and is not necessary
to fix the bug.
2021-12-31 11:33:47 +01:00
Charlie Jolly
71468f475b Nodes: Weight drag link search for Math nodes
As @hooglyboogly suggested in D13680, this patch adds weighting
to the search results. Dragging from a vector/rgba socket weights
the Vector Math node higher than a float Math node, and vice versa.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13691
2021-12-31 02:34:23 +00:00
0aa7315608 Fix (unreported): remove menu separators from drag link search
Search was picking up the menu separator entries.
Add check for these which are defined by empty identifier strings.
2021-12-31 01:15:00 +00:00
bf4358ed0c Cleanup: Use switch to get gpu shader name
Rather than using the array syntax that doesnt work in C++,
use a switch state which is also much easier to read.
2021-12-30 17:39:23 -05:00
ee2b72fd29 Nodes: Convert several shader nodes to c++
Also add file namespace

This is needed to use new node APIs

Differential Revision: https://developer.blender.org/D13690
2021-12-30 12:42:12 -05:00
e0d1e66732 Fix T93868: GPencil material filter does not work with instances
When the material is used in several objects, the filter by material is not working as expected because the internal pointers are different due eval version.

Now, the original version of the material is compared to keep same address.
2021-12-30 12:48:51 +01:00
Shen Ciao
52da1afbf6 Fix T93134: Set origin broken for curve edit mode
Bug: Set Origin causes unexpected offset on Grease Pencil strokes when Curve Editing is enabled.
Fix: Add transformation of editcurve points in `object_origin_set_exec`.

Reviewed By: #grease_pencil, antoniov

Maniphest Tasks: T93134

Differential Revision: https://developer.blender.org/D13273
2021-12-30 11:29:09 +01:00
49a18cc91e Fix T93163: GPencil scale thickness fails in negative scales
Before the negative scales produced a thickness invalid. Now, the value is used in absolute value to avoid this situation.
2021-12-30 11:18:05 +01:00
0b73b2c6cf Nodes: Improve link drag search for Math and Vector Math nodes
Exposes math operations via rna emums.

This uses the rna enum to build the search list.

Differential Revision: https://developer.blender.org/D13680
2021-12-30 01:22:10 +00:00
6d7dbdbb44 Point Cloud: Optimize bounding box calculation
This is analagous to 6a71b2af66 which did the same
thing for mesh data. Two differences are that here the coordinates
are simply `float3`, and we account for the radius if it's available.
Here I observed a similar performance increase, from 50ms
average to 10ms average, with 16 million points, a 5x speedup.

The calculation is about 1.4 times faster when no radius is used, down
 to 7.3ms average. Before, the calculation was only 1.2 times faster.
2021-12-29 18:39:41 -06:00
9d3264b4fd Cleanup: clang-tidy modernize-redundant-void-arg 2021-12-29 18:51:10 -05:00
d3a31311b9 Nodes: Convert shader, texture category nodes to c++
Also add/correct file namespace

This is needed to use new node APIs

Differential Revision: https://developer.blender.org/D13688
2021-12-29 18:36:15 -05:00
c0fdf16561 Fix T94454: Python API curve to mesh use after free without depsgraph
This was caused by a mistake in eb0eb54d96, which removed
the clearing of the curve edit mode pointers that are set when creating
the temporary data for the conversion. If they are not cleared, the
generic ID free function will also free the edit mode data, which is
wrong when the source curve is in edit mode.
2021-12-29 16:53:02 -06:00
04ead39dae Modifiers: decrease maximum allocation size for Weld vertices
At the time of allocating the buffer with vertices in context, we don't
know exactly how many vertices are affected, but we do know that it is
less than or equal to twice the number of vertices killed.
2021-12-29 17:45:56 -03:00
bb0da7dbbd Fix (unreported): missing relations update after adding scene time node
This just moves the relations update to a lower level function that is used
by other functions. Eventually, the special case for this node should be
generalized.
2021-12-29 19:40:14 +01:00
5e8b42bf86 Cleanup: Remove unused DerivedMesh functions 2021-12-29 12:37:01 -06:00
a94d80716e Geometry Nodes: Support instances in the delete geometry node
Ever since the instance domain was added, this was exposed, it just
didn't do anything. This patch implements the instances domain in the
delete and separate geometry nodes, where it acts on the top-level
instances.

We act on a mutable instances input, with the idea that eventually
copy on write attribute layers will make this less expensive. It also
allows us to keep the instance references in place and to do less
work in some situations.

Ref T93554

Differential Revision: https://developer.blender.org/D13565
2021-12-29 11:31:58 -06:00
a836ded990 Geometry Nodes: Accumulate Fields Node
This function node creates a running total of a given Vector, Float, or
Int field.

Inputs:
  - Value: The field to be accumulated
  - Group Index: The values of this input are used to aggregate the input
    into separate 'bins', creating multiple accumulations.
Outputs:
  - Leading and Trailing: Returns the running totals starting
   at either the first value of each accumulations or 0 respectively.
  - Total: Returns the total accumulation at all positions of the field.

There's currently plenty of duplicate work happening when multiple outputs
are used that could be optimized by a future refactor to field inputs.

Differential Revision: https://developer.blender.org/D12743
2021-12-29 10:25:39 -06:00
279085e18e Fix: Issues with attribute comparison in geometry nodes tests
A few typos in 17770192fb lead to an incorrect count of custom
data layers in the test meshes. We only want to consider layers that are
not anonymous, and there was a copy and paste mistake.
2021-12-29 10:23:53 -06:00
d5b77fd522 Nodes: Composite: UI fixes to time node
- Use default size consistent with other curve nodes
- Use column instead of row for properties
2021-12-29 11:16:44 -05:00
Germano Cavalcante
1c7d7c9150 Fix T94113: Local view + Geometry Nodes is broken for instances
`GeometrySet::compute_boundbox_without_instances` may not initialize min
max in some cases such as meshes without vertices.

This can result in a Bounding Box with impossible dimensions
(min=FLT_MAX, max=-FLT_MAX).

So repeat the same solution seen in `BKE_object_boundbox_calc_from_mesh`
and set boundbox values to zero.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13664
2021-12-29 12:36:58 -03:00
d786b48aab Cleanup: Remove dead code 2021-12-29 10:31:17 -05:00
Aaron Carlisle
465bd66519 Nodes: Cleanup: Remove no op registration functions
All these function paramaters are set to NULL so they arent necessary.

Reviewed By: HooglyBoogly, JacquesLucke

Differential Revision: https://developer.blender.org/D13686
2021-12-29 10:00:50 -05:00
Germano Cavalcante
b7f6377e38 gpu.types.GPUOffScreen: accept format argument for color texture
Some projects need more than 8-bit RGBA off-screen, so add the ability to
accept color format and defaults to RGBA8 so existing code should not be
affected.

Currently supported formats:
- RGBA8 (default)
- RGBA16
- RGBA16F
- RGBA32F

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D13650
2021-12-29 11:46:53 -03:00
bdcc258305 Fix: VSE colormix blend factor not working
Blend factor was used to adjust alpha of background image, which is not
correct. This was done in fdee84fd56 where another change was, that
background alpha is copied into result, which is correct.

Apply blend factor to foreground image alpha channel.
2021-12-29 15:00:57 +01:00
4bf74afacc Fix T94422: Shading/Normals break on array modifier caps
The array modifier does not necessarily tag normals dirty.
If it doesnt, normals are recalculated "internally" using the offset ob
transform. This was happening for the array items, but not for the caps.

Now do the same thing for caps.

Maniphest Tasks: T94422

Differential Revision: https://developer.blender.org/D13681
2021-12-29 10:16:48 +01:00
dc0bf9b702 Fix T94453: Weld modifier crash after recent cleanup
I had assumed that the span's size was the same as the length variable.
In the future, separate lengths could be removed in favor of using
lengths directly from spans.
2021-12-29 00:16:54 -06:00
ba38b06a97 Nodes: Convert shader, shader category nodes to c++
Also add file namespace

This is needed to use new node APIs

Differential Revision: https://developer.blender.org/D13684
2021-12-28 22:51:57 -05:00
b92ef379b7 Cleanup: clang-tidy
Fixes two instances of `-Wunused-but-set-variable`

There are several more of these but these were low hanging
and noisy with one being in a header functions.
2021-12-28 21:53:41 -05:00
53ed7ec7f2 Cleanup: clang-tidy
- modernize-deprecated-headers
- modernize-redundant-void-arg

Missed in rB11ac276caaa6e6d42176452526af97cf972abb5f
2021-12-28 20:58:50 -05:00
c34ea3323a Cleanup: Remove unused node tree "local sync" functions 2021-12-28 18:25:18 -06:00
7006d4f0fb Cleanup: Use indices instead of pointers
This improves code readability.

Take the opportunity and improve the comments too.
2021-12-28 20:42:21 -03:00
1464eff375 Cleanup: Return early, organize variable declarations 2021-12-28 15:36:59 -06:00
c32ce881e8 Nodes: Enable unity build for function nodes
Unity build saves 5 seconds off the total build time when compiling `bf_nodes_function`.
Total build times went from 25s to 20s (20% reduction),
tested with ninja on linux running i5 8250U.
2021-12-28 15:49:42 -05:00
Aaron Carlisle
1e9175e1d7 Nodes: Add bf_nodes_function module
In the future this will be used to support unity builds for function nodes

Differential Revision: https://developer.blender.org/D13682
2021-12-28 15:18:17 -05:00
2668f9181c Nodes: Split shader color ramp into its own file 2021-12-28 14:18:31 -05:00
715e0faabc Nodes: Declare function nodes in individual file namespace
To be used in the future to support unity builds
2021-12-28 14:18:31 -05:00
955748ab1e Fix: Duplicate link search entries for attribute statistic node
Using the output declarations is incorrect because there is a
declaration for each type. Instead loop over the names directly,
since it will make it easier to add an integer mode that only
supports some of the outputs.
2021-12-28 12:44:36 -06:00
4cbcfd22f5 Fix T94442: Trim curve node can crash with duplicate point
The calculation to find the factor between two evaluated points assumed
that the points were not at the same location. This assumption is some-
what reasonable, since we might expect `lower_bound` to skip those
point anyway. However, the report found a case where the first two
evaluated points were coincident, and there is no strong reason not
to make this safe, so add a check for 0 length before the division.
2021-12-28 12:22:14 -06:00
d7c556de32 GPencil: Avoid crashes calling from python
This is part of T94439
2021-12-28 18:50:07 +01:00
2e6ae11326 Nodes: Add bf_nodes_composite module
In the future this will be used to support unity builds for composite nodes

Differential Revision: https://developer.blender.org/D13678
2021-12-28 12:22:06 -05:00
1a721c5dbe Fix T94380: Scrolling zooms in spreadsheet data set region
The region used to be type "Channels", but the standard for this
type is "Tools", which is what the file browser uses. This follows
the changes in rB01df48a98394, which also make the region more
"standard."
2021-12-28 11:05:31 -06:00
0e38002dd5 Cleanup: Loops in VSE effect processing
Some effect functions looped over alternating lines, previously with
different factors. Since only one factor is used, code can be
simplified by looping all lines in one for loop.

There should be no functional changes.
2021-12-28 16:40:09 +01:00
bd9d09ca82 Fix T94439: Some GPencil operators crash when calling from console
This fix avoid the segment fault for several operators.
2021-12-28 16:07:07 +01:00
9bacd54312 LibOverride: better handling of the "no override of bones' shapes" case.
Also avoid overriding collections of bone shape objects, if possible.
2021-12-28 15:08:10 +01:00
23ac79f2c2 LibOverride: Tweak RNA 'need resync' detection code.
* Assert about source ID of an overridden pointer property not being a
  liboverride was not necessary, just skip in that case.
* Tag actual 'real' ID owner for resync, and not (potentially) an embedded one.
2021-12-28 15:08:10 +01:00
44db9f192e Cleanup: Factor in VSE effect processing
2 factor variables were passed to effects, but they were hard coded to
have same value.

Remove duplicate variable from arguments, rename single argument to
`fac`. Inverted factor variables were renamed to `mfac`. Any other
factor related variables are prefixed with `temp_`.

There should be no functional changes.
2021-12-28 14:30:21 +01:00
a7dca135dc Fix loss of cloth disk cache on reload in library overrides.
If the override system creates an override record for the cache
name (no idea why though), it trashes the disk cache on file load.

The reason is that it tries to rename cache files in update handler
when assigning the name, and BLI_rename deletes the target file even
if both names are the same.

This is a safe fix that simply aborts the pointless rename attempt.

Differential Revision: https://developer.blender.org/D13679
2021-12-28 14:56:09 +03:00
b29e33caa2 Fix T94408: missing sockets after adding node group 2021-12-28 11:21:07 +01:00
e28222966b Fix compile error when building without OpenSubDiv
Stubs were missing for functions added to opensubdiv_evaluator_capi.h
2021-12-28 09:36:30 +01:00
d25fa3250a Fix T94420: deadlock with subsurf modifiers
The deadlock was caused as the lock on the Mesh mutex used to compute
the subdivision wrapper was not released in some early exits of the
function.
2021-12-28 09:20:17 +01:00
f6699bfccf Revert "LineArt: Intersection function additional clamping"
This reverts commit 0a68fa8e14.
2021-12-28 11:55:37 +08:00
0a68fa8e14 LineArt: Intersection function additional clamping
To handle a rare case where it leads to a -1 index in isect order lookup
2021-12-28 11:21:25 +08:00
8c4edd1b37 Cleanup: clang format 2021-12-27 16:23:23 -05:00
d5b72fb06c Nodes: Declare shader nodes in individual file namespace
To be used in the future to support unity builds
2021-12-27 16:21:31 -05:00
336f6f4bbd GPencil: Fix error in previous Cleanup 2021-12-27 19:51:32 +01:00
d6dd2f51bb Cleanup: Use vector function 2021-12-27 13:16:47 -05:00
5814de65f9 Cleanup: Store cursor location in tGPspoint as an array
Fixes many instances of `-Wstringop-overread` warning on GCC 11

Differential Revision: https://developer.blender.org/D13672
2021-12-27 12:31:31 -05:00
11ac276caa Cleanup: clang tidy
Use c++ headers; use nullptr; redundant `void` in parameter list;
inconsistent parameter name.
2021-12-27 18:18:37 +01:00
1c9d8fcb47 Render: move editor/render module to c++
Doing this in preparation for some work on asset preview generation.

Differential Revision: https://developer.blender.org/D13676
2021-12-27 17:26:09 +01:00
644e6c7a3e Fix T93941: geometry proximity breaks with high resolution mesh
The calls to `.fill` were overwriting indices that are processed by
other threads.
2021-12-27 17:21:09 +01:00
eed45d2a23 OpenSubDiv: add support for an OpenGL evaluator
This evaluator is used in order to evaluate subdivision at render time, allowing for
faster renders of meshes with a subdivision surface modifier placed at the last
position in the modifier list.

When evaluating the subsurf modifier, we detect whether we can delegate evaluation
to the draw code. If so, the subdivision is first evaluated on the GPU using our own
custom evaluator (only the coarse data needs to be initially sent to the GPU), then,
buffers for the final `MeshBufferCache` are filled on the GPU using a set of
compute shaders. However, some buffers are still filled on the CPU side, if doing so
on the GPU is impractical (e.g. the line adjacency buffer used for x-ray, whose
logic is hardly GPU compatible).

This is done at the mesh buffer extraction level so that the result can be readily used
in the various OpenGL engines, without having to write custom geometry or tesselation
shaders.

We use our own subdivision evaluation shaders, instead of OpenSubDiv's vanilla one, in
order to control the data layout, and interpolation. For example, we store vertex colors
as compressed 16-bit integers, while OpenSubDiv's default evaluator only work for float
types.

In order to still access the modified geometry on the CPU side, for use in modifiers
or transform operators, a dedicated wrapper type is added `MESH_WRAPPER_TYPE_SUBD`.
Subdivision will be lazily evaluated via `BKE_object_get_evaluated_mesh` which will
create such a wrapper if possible. If the final subdivision surface is not needed on
the CPU side, `BKE_object_get_evaluated_mesh_no_subsurf` should be used.

Enabling or disabling GPU subdivision can be done through the user preferences (under
Viewport -> Subdivision).

See patch description for benchmarks.

Reviewed By: campbellbarton, jbakker, fclem, brecht, #eevee_viewport

Differential Revision: https://developer.blender.org/D12406
2021-12-27 16:35:54 +01:00
31e120ef49 Nodes: Support linking to existing group input from link drag search.
Before one could only create a new group input using the link drag search.
With this patch it becomes possible to create a Group Input node for an
existing input.

Differential Revision: https://developer.blender.org/D13674
2021-12-27 16:15:11 +01:00
51a131ddbc BLI: add utility to check if type is any specific type
This adds `blender::is_same_any_v` which is the almost the same as
`std::is_same_v`. The difference is that it allows for checking multiple
types at the same time.

Differential Revision: https://developer.blender.org/D13673
2021-12-27 16:08:11 +01:00
594438ef0d Allocator: add missing include
The placement-new operator requires `#include <new>`.
It is used in `MEM_new`.
2021-12-27 15:41:56 +01:00
7cf5f4cc63 LineArt: Protecting bounding area links.
In case they overflowed the bounding area maximum link count,
Protect the link array so it doesn't crash.
2021-12-27 14:33:58 +08:00
52585b39a1 LineArt: Remove duplicated edge-boundbox linking.
The edge is linked twice from differen calls during line art calculation
Probably caused by a merge and both calls stayed for some reason.
This would lead to edge link overflowing its limit of 2^16 items.
2021-12-27 14:22:09 +08:00
20b438d523 Cleanup: Use array for BKE cursor functions
Missed this function in rB67525b88d2e
2021-12-26 15:08:41 -05:00
5cf993f951 Cleanup: Fix compile warning
Own mistake in rB67525b88d2e
2021-12-26 15:08:41 -05:00
28a8d434d5 Fix T94387: Mesh sequence cache, crash when clicking a panel
The crash happens when opening a panel (added in rB43f5e761a66e87fed664a199cda867639f8daf3e)
when no CacheFile is set in the modifier.

To fix this, check that the CacheFile pointer is not null before attempting to draw anything.
2021-12-26 13:45:49 +01:00
dd3a72f275 Docs: Add to and cleanup attribute API docs
Most of the comment block is similar to the text in the source
code documentation wiki. It's helpful to have some text in
a header file too, so it's closer for programmers already looking
at the code.

This also uses more consistent syntax and wording in the comments
about the attribute API in `GeometryComponent`.

Ref T93753

Differential Revision: https://developer.blender.org/D13661
2021-12-25 15:08:38 -06:00
ceed8f7c06 Cleanup: Use more common variable name
It's preferred to use `area` as a name for `ScrArea` variables.
2021-12-25 14:57:07 -06:00
85abac7e87 Cleanup: Move customdata.c to C++
Differential Revision: https://developer.blender.org/D13666
2021-12-25 14:28:22 -06:00
Christoph Lendenfeld
f7ddb1ed8a Breakdown Implementation
This patch adds the breakdown (or tween) functionality to the graph editor.

The factor defines the linear interpolation from left key to right key.

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D9375
Ref: D9375
2021-12-25 20:58:47 +01:00
Aaron Carlisle
fbd01624e3 Shader Nodes: Convert bump node to use new socket builder
This node is a bit special in that it uses two internal sockets
for a hack for Eevee; see rBffd5e1e6acd296a187e7af016f9d7f8a9f209f87

As a result, the `SOCK_UNAVAIL` flag is exposed to socket builder API.

Reviewed By: JacquesLucke, fclem

Differential Revision: https://developer.blender.org/D13496
2021-12-25 11:13:15 -05:00
Aaron Carlisle
c5862da5ad Cleanup: use new c++ guarded allocator API in nodes
Also simplify the allocation name to `__func__`

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13665
2021-12-25 11:12:08 -05:00
Christoph Lendenfeld
9085b4a731 Blend To Neighbor Implementation
This patch adds the blend to neighbor operator to the Graph editor.

The operator acts like the blend to neighbor operator for a pose context, just working on keyframes.

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D9374
Ref: D9374
2021-12-25 13:40:53 +01:00
e505957b47 Fix T94375: Python error when trying to add Grease Pencil brush preset
The prop name was wrong.
2021-12-25 12:53:35 +01:00
28df0107d4 Fix T94362: GPUMaterialTexture references freed ImageUser
The issue was caused by rB7e712b2d6a0d257d272ed35622b41d06274af8df
and the fact that `GPUMaterialTexture` contains an `ImageUser *` which
references the `ImageUser` on e.g. `NodeTexImage`.

Since the node tree update refactor, it is possible that the node tree changes
without changing the actual material. Therefore, either the renderer should
check if the node tree has changed or it should not store pointers to data in
node storage. The latter approach is implemented in this patch.

Differential Revision: https://developer.blender.org/D13663
2021-12-25 11:14:02 +01:00
f1e04116f0 Cleanup: Do not use magic number 2021-12-25 00:02:45 -05:00
67525b88d2 Cleanup: Use array for BKE cursor functions
Differential Revision: https://developer.blender.org/D12962
2021-12-24 23:59:33 -05:00
95c7e8aa13 Update RNA to user manual mapping file 2021-12-24 22:54:59 -05:00
fc45b00720 Cleanup: Define node tree icon in register function
I suppose this was done to reduce then dependencies.
However, most nodes already depend on UI code so this isnt too useful.
2021-12-24 22:47:58 -05:00
6e0cf86e73 Cleanup: use new c++ guarded allocator API
API added in rBa3ad5abf2fe85d623f9e78fefc34e27bdc14632e
2021-12-24 22:18:04 -05:00
79012c6784 Cleanup: Use consistent order for custom data mesh masks
Loops come last in the struct's definition, use the same order when
initializing the common masks in customdata.c (they were switched
with the poly masks).
2021-12-24 18:26:11 -06:00
26c7be71d7 Nodes: Migrate bump shader node to cpp
Needed for D13496
2021-12-24 15:42:58 -05:00
291d2a2222 Cleanup: Remove misleading comments
Most of these custom data layers weren't BMesh only, and the
one that actually looks to be BMesh only has `BM` in its name.
2021-12-24 11:00:01 -06:00
d48fc7d156 Cleanup: Use vector instead of linked list 2021-12-24 10:05:47 -06:00
dd01ce2cd0 Fix T94322: add missing updates after recent refactor
This was a regression in rB7e712b2d6a0d257d272ed35622b41d06274af8df.
2021-12-24 13:39:50 +01:00
ba4b7b4319 Fix T94162: incorrect handling when there are multiple group outputs
Typically a node group should only have a single Group Output node.
However, currently Blender already supports having multiple group outputs,
one of which is active. This wasn't handled correctly by geometry nodes.

Differential Revision: https://developer.blender.org/D13611
2021-12-24 12:34:04 +01:00
c0db8a9a3b Cleanup: remove unused button function
rB05f900e3466b45a19e13bea6dd641e4f7b8b46e9 removed unused button functions,
but since that commit the `uiDefIconTextButBit()` static function sits
unused as well. It's now been removed.
2021-12-24 10:39:36 +01:00
81b3933abb Fix T94357: Node Ungroup operator copies current node tree
This was a mistake in rBfdc4a1a590d8befb1ff which copied the parent
node tree into itself rather than accessing the node group's nodes.
2021-12-23 22:48:55 -06:00
35bd6fe993 Fix T94344: Incorrect size for edge vertices node output
This looks like a copy and paste error from the original commit.
The virtual array output used the number of mesh polygons instead
of the number of edges.
2021-12-23 16:22:07 -06:00
2df912466c Cleanup: Remove outdated comment
After rB01df48a983944ab3f8a, this comment no longer applies.
2021-12-23 13:28:44 -06:00
582f6032fc Cleanup: Move hair object type files to C++
Differential Revision: https://developer.blender.org/D13657
2021-12-23 11:46:45 -06:00
05f900e346 Cleanup: Remove unused UI button definition functions
These were part of the older buttons API that shouldn't be used in
more places at this point. Most layouts should be built with the regular
layout system API and RNA properties. This sort of button can still be
created though, since these were just shortcuts anyway.
2021-12-23 11:30:11 -06:00
43f5e761a6 Cache File: use panels to organize UI
This adds interface panels to organize the Cache File UI parameters for
modifiers and constraints into related components: velocity, time, and
render procedural.

Properties relating to the three aforementioned components are separated
from `uiTemplateCacheFile` into their own functions (e.g.
`uiTemplateCacheFileVelocity` for the velocity one), which are in turn
called from the specific panel creation routines of the modifiers and
constraints (for constraints, the functions are exposed to the RNA).

`uiTemplateCacheFile` now only shows the properties for the file path,
and in the case of constraints, the scale property.

The properties that are only defined per modifier (like the velocity
scale), are shown in the proper modifier layout panel if applicable.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D13652
2021-12-23 18:05:26 +01:00
Christoph Lendenfeld
7a71a95f32 Graph Slider Ops: Show error when no valid keys are found
When using graph slider operators like D9374
it showed a warning when no keys were selected.
However since that stops the modal operation it should be an Error.
Also the message was misleading
since it could error for different reasons than stated.

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D13655
Ref: D13655
2021-12-23 14:31:28 +01:00
d71009d980 Avoid exception when no weight paint settings exist
Just an extra check for `None` before accessing its properties.
2021-12-23 14:10:24 +01:00
025c921416 Cleanup: remove BKE_animdata_driver_path_hack
The `BKE_animdata_driver_path_hack()` function has had almost no effect
since rB51b796ff1528, and basically boils down to:

```
return base_path ? base_path : RNA_path_from_ID_to_property(ptr, prop);
```

Since `base_path` was `NULL` in the majority of cases, it's just been
replaced by a direct call to `RNA_path_from_ID_to_property()`. The
conditional now just appears in one remaining case.

This relates to T91387.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D13646
2021-12-23 13:49:58 +01:00
00965c98cb LibOverride: protect better against using on complex inter-dependency cases.
Do not allow 3DView operator to run on the liboverride of an
instantiating Empty object. And tweak behavior in the Outliner
operations too.

Related to T94226.

Note that this remains fairly exotic, bad idea not recommended cases,
such complex inter-dependencies between different libraries inside a
same liboverride hierarchy is just not possible to handle properly.
2021-12-23 10:13:07 +01:00
710e279b19 Fix missing type declaration compile error
rBbd3bd776c893 broke compilation here due to missing type declaration
for basic types as the source file is not including this header. In any
case, it is the responsibility of header files to include headers for
types used by value in function parameters or struct definitions.
2021-12-23 08:01:43 +01:00
41f3164e57 Cleanup: typo in comment 2021-12-23 07:53:47 +01:00
1931387799 Fix: Curve trim node test failure
Caused by 60c59d7d61. The position wasn't copied into the correct
place on each spline. Somehow I didn't catch that in the tests I ran.
2021-12-22 18:38:30 -06:00
8f89196be2 Fix T94232: No selection with set material node empty material list
If the input mesh had no materials already, the new material would
become the only material on the mesh, meaning the material was
added to all of the faces, instead of just the selected faces.

The mesh primitive nodes in geometry nodes already add an empty
slot by default, so this only affects outside geometry.

The fix is just adding an empty slot before the new slot, so the
non-selected material indices can still point to an empty slot.

Differential Revision: https://developer.blender.org/D13654
2021-12-22 18:15:21 -06:00
60c59d7d61 Cleanup: Remove spline add_point method, refactor mesh to curve node
It's better to calculate the size of a spline before creating it, and this
should simplify refactoring to a data structure that stores all point
attribute contiguously (see T94193). The mesh to curve conversion is
simplified slightly now, it creates the curve output after gathering all
of the result vertex indices. This should be more efficient too, since
it only grows an index vector for each spline, not a whole spline.
2021-12-22 17:39:35 -06:00
c593db5a2f Nodes: Add link drag search support for map range node
Previously only the float version of the node was connected to.
This adds connection operations for vector sockets, and exposes
the "Steps" socket properly when it's selected.
2021-12-22 17:22:10 -06:00
6b662ebdb9 Cleanup: Return early 2021-12-22 17:18:37 -06:00
9033d270d5 Fix: Extra space at the front of "Sample Curve" node name 2021-12-22 17:13:16 -06:00
dca5be9b94 Fix: Wrong node link drag search menu items for attribute statistic
Caused by capturing local variables by reference in a function that
outlives the scope it was created in. Also use a more generic function
for the first two inputs.
2021-12-22 16:45:41 -06:00
14621e7720 Fix: Potential use after scope in curve to mesh node
I don't think this has been visible, since I only ran into it after
changing other code that affected this. However, some attributes
can keep a reference to the source component to use when tagging
caches dirty (like the position attribute tagging the normals dirty).
Here, the component was created inside a function, then the attributes
were used afterwards.

Also add some comments warning about this in the header file.
2021-12-22 16:29:00 -06:00
Michael
c6e7fc9744 Fix: Large stack allocation in compositor
When COM_EXPORT_GRAPHVIZ is enabled, DebugInfo::graphviz
uses a char[1000000] as local variable. When this function
is called this is allocated on the stack, which has a size
of just 1MB on mac and may cause a stack overflow.

This patch allocates the memory on the heap and frees
the memory at the end of the function.

Reviewed By: LazyDodo

Differential Revision: https://developer.blender.org/D13628
2021-12-22 13:49:52 -07:00
0fd72a98ac Cleanup: Avoid adding points to splines sequentially
This should be faster because it avoids reallocating the internal
vectors when the size is known beforehand, but it may also help
a potential refactor to a different data structure (see T94193).
2021-12-22 14:35:46 -06:00
b4f978e901 Fix: Missing update when toggling node mute
Toggling node mute doesn't cause node trees to reevaluate after
rB7e712b2d6a0d257. Toggling a link mute still works though. To fix this,
the operator tags the node and node with a new update tag function
(that uses an existing tag internally).

Differential Revision: https://developer.blender.org/D13653
2021-12-22 14:00:34 -06:00
586e2face6 Fix T93408: Snap performance regression at high poll rate
Caused by {rBfba9cd019f21f29bad1a6f3713370c5172dbc97f}.

The snap timer was accidentally modified and damaged.
2021-12-22 16:11:05 -03:00
e2a9e7e803 Nodes: Remove unnecessary node tree socket tagging
`SOCK_IN_USE` is now set in `update_socket_used_tags` in
`node_tree_update.cc` when a node tree is changed.
It doesn't need to run every single redraw. Removing this
results in a small speedup of 0.4 ms when drawing a tree
with about 4000 nodes (from about 70 ms total).

Differential Revision: https://developer.blender.org/D13645
2021-12-22 11:25:55 -06:00
6a71b2af66 Mesh: Parallelize bounding box calculation (WIP)
This replaces the single-threaded calculation of mesh min and max
positions with a `parallel_reduce` loop. Since the bounding box
of a mesh is retrieved quite often (at the end of each evaluation,
currently 2(?!) times when leaving edit mode, etc.), this makes for a
quite noticeable speedup actually.

On my Ryzen 3700x and a 4.2 million vertex mesh, I observed
a 4.4x performance increase, from 14 ms to 4.4 ms.

I added some methods to `float3` so they would be inlined, but
they're also a nice addition, since they're used often anyway.

Differential Revision: https://developer.blender.org/D13572
2021-12-22 11:04:03 -06:00
3579a9e0fc Cleanup: Remove debug print. 2021-12-22 17:53:00 +01:00
921708fc76 Fix (unreported) potential bug in collections parenting update code.
Own mistake in rB2ef192a55b2c. Did not seem to have any visible effect
though...
2021-12-22 17:50:10 +01:00
f577abc5cd Cleanup: Use LISTBASE_FOREACH_ macros. 2021-12-22 17:39:53 +01:00
8d3e57f338 Fix T93799: Outliner: Remaping objects could result in duplicates in a collection.
Fix is similar to how CollectionObject with NULL object pointers are handled.

Using one of the 'free' pad bytes in Object_Runtime struct instead of a
gset (or other external way to detect object duplicates), as this is
several times faster.

NOTE: This makes remapping slightly slower again (adds 10 extra seconds
to file case in T94059).

General improvements of remapping time complexity, especially when
remapping a lot of IDs at once, is a separate topic currently
investigated in D13615.
2021-12-22 17:34:13 +01:00
902318f0fd Fix part of T93799: Outliner: Remap Users crash (for ID Type Object).
This commit fixes the crash itself, however this can still lead to a
same collection 'owning' the same object several time.

Issue here was a bad assumption in layer resync code, that would lead to
removing valid objects from the viewlayer's `object_bases_hash` in
`BKE_layer_collection_sync`, when deleting no-more-used bases, in case
of bases duplicate.
2021-12-22 17:03:20 +01:00
978a930d9c Fix: Build issue on 32 bit archs
The cast to size_t leads to a build issue on 32
bit archs. cursor_delim_type_utf8 expects an int
so an additional cast to size_t is not required.

Reported by user frispete on devtalk.
2021-12-22 08:39:33 -07:00
aba91a745a Fix T93999: GPencil Box tool allows decreasing subdiv, but not increase
The problem was the number of points for each edge of the box was wrong and the wheelmouse effect was anulated.

Also fixed the value displayed in the status bar to keep consistency with subdivision value.

Reviewed By: lichtwerk

Maniphest Tasks: T93999

Differential Revision: https://developer.blender.org/D1363
2021-12-22 16:07:48 +01:00
dbbf0e7f66 Nodes: Improve node tree copy performance
When copying a full node tree, we can avoid an O(n^2) loop finding a
unique name for every node if we assume they already have unique names.
That is a reasonable assumption, since unique names are verified
elsewhere when adding a new node.

Copying a node tree with about 4000 nodes took 42 ms before,
now it takes 6 ms.

Differential Revision: https://developer.blender.org/D13644
2021-12-22 08:52:46 -06:00
fdc4a1a590 Nodes: Refactor to remove node and socket "new" pointers
These pointers point to the new nodes when duplicating,
and their even used to point to "original" nodes for
"localized" trees. They're just a bad design decision
that make code confusing and buggy.

Instead, node copy functions now optionally add to a map
of old to new socket pointers. The case where the compositor
abused these pointers as "original" pointers are handled
by looking up the string node names.

Differential Revision: https://developer.blender.org/D13518
2021-12-22 08:47:46 -06:00
d6224db8f1 Geometry Nodes: improve multi socket handling in evaluator
Previously, the values passed to a multi-input socket were stored
in the order that they arrived in. Then, when the values are accessed,
they are sorted depending on the link order.

Now, the ordering is determined in the beginning before execution starts.
Every value is assigned to the right index directly, avoiding the sort
in the end. This makes the ordering more explicit.
2021-12-22 13:16:01 +01:00
2ce2bffc4d Fix T94295: VSE fades error when no suitable sequences selected
This errored out in two scenarios:
- current frame not in strips framerange (this was reported)
- no strips selected at all

Now handle these cases properly in the operator and give appropriate
report info.

Maniphest Tasks: T94295

Differential Revision: https://developer.blender.org/D13642
2021-12-22 09:28:31 +01:00
d2bf60cc17 Cleanup: Clang tidy, restore alphabetical sorting 2021-12-21 14:32:22 -06:00
Germano Cavalcante
6db0919724 Fix T94191: correct (time) translation headers not showing DeltaX
Caused by {rBb0d9e6797fb8}

For the header (both Graph Editor case in general `headerTranslation` as
well as `headerTimeTranslate`) we are interested in deltas values
(not absolute values).

Since culprit commit, `snapFrameTransform` was not working with deltas
anymore, but we have to compensate for this.

For the Graph Editor, this only worked "by accident" in rB7192e57d63a5,
since `ival` is still zero at this point.

So now, reacquire the delta right after the snap operation.

Also use a more appropriate center value in the translate operator.

Maniphest Tasks: T94191

Differential Revision: https://developer.blender.org/D13641
2021-12-21 13:00:51 -03:00
aa7105f759 Cleanup: use BKE_pose_is_layer_visible in more places
This was added in rBd13970de8627, now use in more places.
2021-12-21 16:45:46 +01:00
bdbd0cffda Nodes: Improve performance when freeing a node tree
This commit makes freeing a node tree about 25 to 30 times faster.
Freeing a node tree happens whenever it is edited. Freeing a node
tree with about 4000 nodes went from 30-50ms to about 2 ms.

This was so slow before because for every node that was freed
when freeing the node tree, `node_free_node` looped over all
other nodes to detach frames, and then looped over all links to
remove any links connected to the node. That was all pointless
work because everything else is about to be freed anyway.

Instead, move that "detaching" behavior to the dedicated function
for removing a single node, and to the "local" version of the free
function to be safe, since I know less about what that version expects.

Differential Revision: https://developer.blender.org/D13636
2021-12-21 09:23:48 -06:00
8cf1994455 Fix T93960: Asset Catalogs I/O fails with unicode file paths on Windows
On Windows, encode file paths as UTF-16 before trying to open the file
for reading/writing.

This introduces a new class `blender::fstream`, which wraps
`std::fstream` and provides this UTF-16 encoding. This class should also
be used in other areas, like the Alembic importer/exporter.

Manifest Task: T93960

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13633
2021-12-21 15:54:09 +01:00
d66a6525c3 Assets: log message when catalog definitions cannot be loaded
Log a message (via `CLOG`) when asset catalog definitions cannot be
loaded.

Reviewed by @jacqueslucke in D13633
2021-12-21 15:53:57 +01:00
7e712b2d6a Nodes: refactor node tree update handling
Goals of this refactor:
* More unified approach to updating everything that needs to be updated
  after a change in a node tree.
* The updates should happen in the correct order and quadratic or worse
  algorithms should be avoided.
* Improve detection of changes to the output to avoid tagging the depsgraph
  when it's not necessary.
* Move towards a more declarative style of defining nodes by having a
  more centralized update procedure.

The refactor consists of two main parts:
* Node tree tagging and update refactor.
  * Generally, when changes are done to a node tree, it is tagged dirty
    until a global update function is called that updates everything in
    the correct order.
  * The tagging is more fine-grained compared to before, to allow for more
    precise depsgraph update tagging.
* Depsgraph changes.
  * The shading specific depsgraph node for node trees as been removed.
  * Instead, there is a new `NTREE_OUTPUT` depsgrap node, which is only
    tagged when the output of the node tree changed (e.g. the Group Output
    or Material Output node).
  * The copy-on-write relation from node trees to the data block they are
    embedded in is now non-flushing. This avoids e.g. triggering a material
    update after the shader node tree changed in unrelated ways. Instead
    the material has a flushing relation to the new `NTREE_OUTPUT` node now.
  * The depsgraph no longer reports data block changes through to cycles
    through `Depsgraph.updates` when only the node tree changed in ways
    that do not affect the output.

Avoiding unnecessary updates seems to work well for geometry nodes and cycles.
The situation is a bit worse when there are drivers on the node tree, but that
could potentially be improved separately in the future.

Avoiding updates in eevee and the compositor is more tricky, but also less urgent.
* Eevee updates are triggered by calling `DRW_notify_view_update` in
  `ED_render_view3d_update` indirectly from `DEG_editors_update`.
* Compositor updates are triggered by `ED_node_composite_job` in `node_area_refresh`.
  This is triggered by calling `ED_area_tag_refresh` in `node_area_listener`.

Removing updates always has the risk of breaking some dependency that no
one was aware of. It's not unlikely that this will happen here as well. Adding
back missing updates should be quite a bit easier than getting rid of
unnecessary updates though.

Differential Revision: https://developer.blender.org/D13246
2021-12-21 15:18:56 +01:00
1abf2f3c7c Cleanup: clang format
Missed in rB7c9e4099854a, sorry.
2021-12-21 14:28:04 +01:00
d13970de86 Fix T92930: Outliner "Show Active" bone fails in certain situations
Outliner would frame the armature object instead of the bone if the bone
was on a hidden armature layer.

Similar to issues reported in e.g. T58068 and T80464, this is due to the
fact that `BKE_pose_channel_active` always checks for the armature layer
(and returns NULL if a bone is not on a visible armature layer).

Now propose to make this layer check **optional** (and e.g. from the
Outliner be more permissive). This also introduces
`BKE_pose_channel_active_if_layer_visible` which just wraps
`BKE_pose_channel_active` with the check being ON.

Maniphest Tasks: T92930

Differential Revision: https://developer.blender.org/D13154
2021-12-21 14:07:48 +01:00
fac42e3fa1 Tests: initialise BKE callbacks before loading blend file
Initialise the BKE callback system in
`BlendfileLoadingBaseTest::SetUpTestCase()`. This allows certain tests
to run in debug mode (when `BLI_assert` is enabled).
2021-12-21 11:12:47 +01:00
68f1b2c671 Fix T93757: Do not force-instantiate indrectly linked objects in linking case. 2021-12-21 10:09:01 +01:00
bb4de77b82 Fix T93839: Copy/Paste of empty instantiating a collection.
Do not also instantiate a collection in the view layer, if it is already
instantiated through an empty object.
2021-12-21 09:52:53 +01:00
c0f06ba614 Fix build error in debug builds from recent commit
r7acd3ad7d8e58b913c5 converted a pointer to a reference,
but an assert still compares the variable to a pointer.
2021-12-20 22:48:31 -06:00
e4de5b4657 Fix T94280: Crash when splitting meta strip
This happens because in `SEQ_time_update_sequence` function
`SEQ_get_meta_by_seqbase` returns uninitialized value. This isn't nice,
but it shouldn't happen in first place. Problem is, that
`SEQ_edit_strip_split` does move strips into detached `ListBase`, so
other functions can't see them anymore. Detached `ListBase` is used
solely to preserve relationships during duplication.

Move strips to original `ListBase` immediately after duplication and
return `NULL` if `SEQ_get_meta_by_seqbase` can't find meta strip.

Splitting itself can still rely on fact, that number of original and
duplicated strips is same and they are placed next to each other in
exactly same order at the end of original `ListBase`.
2021-12-21 05:27:46 +01:00
5457b66301 Cleanup: Use span instead of raw pointer
This is a followup to the previous commit.
2021-12-20 18:10:29 -06:00
7acd3ad7d8 Cleanup: Use simpler loops in weld modifier
In this commit I changed many loops to range-based for loops.
I also removed some of the redundant iterator variables, using
indexing inside the loop instead. Generally an optimizing compiler
should have no problem doing the smartest thing in that situation,
and this way makes it much easier to tell where data is coming from.

I only changed the loops I was confident about, so there is still more
that could be done in the future.

Differential Revision: https://developer.blender.org/D13637
2021-12-20 18:03:06 -06:00
59221476b0 Fix T94262: Grease Pencil Blur Effect DoF mode wrong
This was visible outside of camera view and was not respecting the
"Depth of Field" checkbox on the Camera properties.

Now return early if DoF should not be visible.

Maniphest Tasks: T94262

Differential Revision: https://developer.blender.org/D13631
2021-12-20 21:52:42 +01:00
399f84d479 Run clang-format 2021-12-20 14:30:29 -05:00
d93dd85951 Sculpt: split sculpt.c into three files
Sculpt.c is now three files:

* Sculpt.c: main API methods and the brush stroke operator
* Sculpt_brushes.c: Code for individual brushes.
* Sculpt_ops.c: Sculpt operators other than the brush stroke operator.

TODO: split brush stroke operator into a new file (sculpt_stroke.c?).
2021-12-20 14:20:51 -05:00
Wannes Malfait
e9092110ff Fix T94144: Duplicate edges in dual mesh node
The duplicated edges were caused by 'oversubdivided' edges, i.e. edges
where some of the vertices on them are only connected to two polygons.
The fix finds these vertices and 'dissolves' them so that only one edge
is created.

For most 'normal' meshes this shouldn't occurr, or only very little, so
the performance impact of this change should be neglegible. In practice
this is also avoidable by triangulating the mesh first.

Differential Revision: https://developer.blender.org/D13445
2021-12-20 13:08:05 -06:00
bdb5852e28 Cleanup: Remove mesh valid assertions in debug builds
These are useful for development, but when the primitive nodes
aren't actively changing, the performance cost is not worth it.
2021-12-20 12:46:40 -06:00
Piotr Makal
70de992afe Fix: Incorrect assert conditions in NURBSpline
This fix provides better conditions for asserts in `NURBSpline::knots`
method accounting for cyclic NURBS curves.

Differential Revision: https://developer.blender.org/D13620
2021-12-20 12:43:14 -06:00
76cb11e332 Cleanup: Remove unused node type flag
This flag was checked, but not set anywhere.
2021-12-20 11:03:24 -06:00
82fa2bdf3f Cleanup: Comment formatting in node.cc
Also remove a SCOPED_TIMER I added by mistake in a previous commit.
2021-12-20 10:48:01 -06:00
cb96435047 Geometry Nodes: Parallelize mesh grid primitive
On a Ryzen 3700x, this ended up 2.5x faster than before. More
benchmarking details are included in the differential revision.

For smaller grids, all this should do is increase the
code size a bit, and add a few more if statements.

Differential Revision: https://developer.blender.org/D13617
2021-12-20 10:34:31 -06:00
1d25ba175e Cleanup: Remove unused arguments 2021-12-20 09:57:18 -06:00
6c33a0f6d6 Update our USD 21.02 patch to support gcc-11
There are two issues in USD code that break building it with gcc-11,
one (in `demangle.cpp`) was already fixed upstream, the other (in
`singularTask.h`) is still pending (reported upstream, see
https://github.com/PixarAnimationStudios/USD/issues/1721).

CC #platforms_builds_tests_devices project.
2021-12-20 16:17:42 +01:00
edb3ab0617 Fix T94251: Cycles wrong pointcloud normal for instanced objects
Refactor code a bit also so we need to do fewer matrix transforms for shader
data setup of points and curves.
2021-12-20 14:14:43 +01:00
e2e7f7ea52 Fix Cycles OptiX crash with 3D curves after point cloud changes
Includes refactoring to reduce the number of bits taken by primitive types,
so they more easily fit in the OptiX limit.
2021-12-20 14:14:43 +01:00
Maxime Chambonnet
5adc06d2d8 install_deps: Fix OIIO and OSL build with OpenEXR
Root path variables for those libraries is now using the 'standard' naming
scheme.

With tweaks/cleanups from @mont29.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D13591
2021-12-20 12:52:07 +01:00
deb3d566a5 BLI: fix Vector.prepend declaration
Using `&&` there was a typo. With `&&` the `prepend` method
could not be called with a const reference as argument.
2021-12-20 10:46:43 +01:00
ffd1a7d8c8 Fix T93570: VSE image transforms in preview dont autokey
This was basically not implemented, do this via
`ED_autokeyframe_property` in a new dedicated function in
special_aftertrans_update.

Maniphest Tasks: T93570

Differential Revision: https://developer.blender.org/D13608
2021-12-20 09:12:37 +01:00
fdb2167b4a Docs: use doxygen formatting for BLI
Differentiate doc-strings from title/section text.
2021-12-20 19:07:10 +11:00
5c63c0a58c Docs: use doxygen formatting for DNA
Differentiate doc-strings from title/section text.
Also use explicit doxygen references to struct members
so it's not ambiguous which member is being referenced.

Note that these changes aren't complete (some files weren't touched).
2021-12-20 19:07:10 +11:00
528fc35fed Docs: minor correction to doc-string
The text editor no longer accumulates changes.
2021-12-20 17:42:27 +11:00
0b69793487 Fix T94254: Crash using view_all operator in VSE
Caused by `NULL` dereference in `SEQ_meta_stack_active_get()`.

Check if `Editing` is `NULL` before accessing meta stack.
2021-12-20 02:18:59 +01:00
34fac7a670 Fix: Meta strip not created with alpha over blend mode
Meta add function wasn't updated. All strips now use alpha over
blending, so set it in `SEQ_sequence_alloc()`.
2021-12-20 01:52:40 +01:00
cc367908cd Cleanup: Remove more texture nodes preview handling
Similar to the previous commit, this allowed removing a function to set
a single pixel of a node preview.
2021-12-19 18:37:57 -06:00
0966eab8e9 VSE: Clamp sound strip when adding movie strip
When adding multiple movie strips and sound stream is longer than video,
this results in gaps between video strips, which is undesirable.
2021-12-20 01:35:25 +01:00
c27d0cb7b9 Cleanup: Remove more no-op node preview code
This is a follow-up to rB43875e8dd1d76ee, removing some
processing of non-existent node previews in the shader and
texture nodes systems.
2021-12-19 18:11:47 -06:00
eac6aff741 Cleanup: Const arguments, remove unused argument 2021-12-19 17:57:51 -06:00
6878897a6d Cleanup: Clang tidy lamda function name 2021-12-18 17:18:41 -06:00
8a91673562 Cleanup: Move weld modifier to C++
This moves `MOD_weld.cc` to C++, fixing compiler warnings
coming from the change. It also goes a little bit further and converts
the code to use C++ data structures: `Span`, `Array`, and `Vector`.
This makes the code more shorter and easier to reason about, and
makes memory maneagement more automatic.

Differential Revision: https://developer.blender.org/D13618
2021-12-18 13:42:48 -06:00
491b9cd2b9 Fix: Build error from missing include 2021-12-18 13:41:56 -06:00
b9861055ad Fix: Link drag search missing field nodes from function nodes
When dragging from the inputs of function nodes, other function
nodes wouldn't connect, because their socket declaration field types
weren't set correctly. Instead, they relied on code properly checking
the *node* declaration's `is_function_node()` method. However,
that increases complexity and requires passing the node instead of
just the socket in more places. Instead, set the proper field types
in the socket declaration during building.

Differential Revision: https://developer.blender.org/D13600
2021-12-18 13:31:06 -06:00
d15d512a68 Fix T94173: Missing update for frame node size
Before d56bbfea7b, nodes were updated (size calculated and
buttons added) in reverse order. Instead, now calculate the size of
frame nodes after all other nodes. Separating the drawing further
may be a good step to removing the O(n^2) loop later on.
2021-12-18 13:27:05 -06:00
4c3f57ffa7 Cleanup: compiler warnings with clang
Includes use of memcpy to avoid warnings about deprecated members.
2021-12-18 18:36:34 +01:00
3471b0016c Fix T94215: compositer denoise node UI wrongly shows as disabled
After recent refactoring in 4e98d974b5.
2021-12-18 05:53:38 +01:00
214a56ce8c GPU: add memory barriers for vertex and index buffers
This adds memory barriers to use with `GPU_memory_barrier` to ensure that
writes to a vertex or index buffer issued before the barrier are
completed after it, so they can be safely read later by another shader.

`GPU_BARRIER_VERTEX_ATTRIB_ARRAY` should be used for vertex buffers (`GPUVertBuf`),
and `GPU_BARRIER_ELEMENT_ARRAY` should be used for index buffers (`GPUIndexBuf`).

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D13595
2021-12-18 00:55:54 +01:00
Christoph Lendenfeld
8e31e53aa0 Function to return a list of keyframe segments
Add a function that returns a list of keyframe segments
A segment being a continuous selection of keyframes
Will be used by future operators in the graph editor

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D13531
Ref: D13531
2021-12-17 22:43:02 +00:00
76fd2ff9fa Fix T94184: Outliner: Collection dragging tooltip is not updating
In the context of the dragdrop tooltip, the event referenced to the window
is out of date and contains invalid `mval` values.

Avoid using `win->eventstate` as much as possible.
2021-12-17 19:13:14 -03:00
4b21067aea Fix T94116: Drivers can have multiple variables with same name
The RNA setter now ensures that driver variables are uniquely named
(within the scope of the driver).

Versioning code has been added to ensure this uniqueness. The last
variable with the non-unique name retains the original name; this
ensures that the driver will still evaluate to the same value as before
this fix.

This also introduces a new blenlib function `BLI_listbase_from_link()`,
which can be used to find the entire list from any item within the list.

Manifest Task: T94116

Reviewed By: mont29, JacquesLucke

Maniphest Tasks: T94116

Differential Revision: https://developer.blender.org/D13594
2021-12-17 17:31:15 +01:00
2648d920d8 Theme: Node Group color only needs RGB, not RGBA
The node group alpha theme was used for the overlay drawing in the node
editor. Since this was removed (919e513fa8) the alpha channel doesn't
need to be exposed anymore.

Reported as part of T93654.
2021-12-17 16:47:06 +01:00
Hans Goudey
0aabaa4583 Cleanup: Use signed integers in the weld modifier
The style guide mentions that unsigned integers shouldn't be used to
show that a value won't be negative. Many places don't follow this
properly yet. The modifier used to cast an array of `uint` to `int` in
order to pass it to `BLI_kdtree_3d_calc_duplicates_fast`. That is no
longer necessary.

Differential Revision: https://developer.blender.org/D13613
2021-12-17 12:40:01 -03:00
552dce0de7 Cleanup: quiet warning due to incompatible pointer types 2021-12-17 15:46:00 +01:00
77760194fe Cleanup: use new c++ guarded allocator api in some files 2021-12-17 15:42:28 +01:00
a3ad5abf2f Allocator: simplify using guarded allocator in C++ code
Using the `MEM_*` API from C++ code was a bit annoying:
* When converting C to C++ code, one often has to add a type cast on
  returned `void *`. That leads to having the same type name three times
  in the same line. This patch reduces the amount to two and removes the
  `sizeof(...)` from the line.
* The existing alternative of using `OBJECT_GUARDED_NEW` looks a out
  of place compared to other allocation methods. Sometimes
  `MEM_CXX_CLASS_ALLOC_FUNCS` can be used when structs are defined
  in C++ code. It doesn't look great but it's definitely better. The downside
  is that it makes the name of the allocation less useful. That's because
  the same name is used for all allocations of a type, independend of
  where it is allocated.

This patch introduces three new functions: `MEM_new`, `MEM_cnew` and
`MEM_delete`. These cover the majority of use cases (array allocation is
not covered).

The `OBJECT_GUARDED_*` macros are removed because they are not
needed anymore.

Differential Revision: https://developer.blender.org/D13502
2021-12-17 15:42:28 +01:00
Phil Stopford
c0d96ca9a5 UI: make Remap User dialog in outliner wider
The previous size was too small for common object names.

Differential Revision: https://developer.blender.org/D13604
2021-12-17 15:21:12 +01:00
Alessio Monti di Sopra
3b965ba10b UI: Fix node socket alignment in some cases
The patch fixes some misalignments in the nodes' sockets/options
recently introduced in 26d2caee3b, while maintaining the original
fix for T92268.

The original fix made the top padding always of the same size; while
that works when the first row of the other node is `Socket | Socket`,
it doesn't for other more common cases, `like Socket | Node Option`,
where the text results misaligned.

Differential Revision: https://developer.blender.org/D13451
2021-12-17 08:04:28 -06:00
b386f960f6 Fix error in Cycles geometry update tagging after pointcloud addition
Thanks to Christophe Hery for spotting this.
2021-12-17 14:59:24 +01:00
Michael
67734d1853 Fix T94142, T94182: Cycles metal broken after pointcloud changes
Missing ccl_private form an older patch.

Differential Revision: https://developer.blender.org/D13612
2021-12-17 14:46:52 +01:00
f3c1d0e3a3 Fix T94137: GPencil: Eraser does not erase first point
The eraser checks the current, previous and next point (and sets pc0,
pc1 & pc2 corresponding to that for futher occlusion/brush/clipping
checks). For the very first point, it sets pc0 to pc1 [which makes sense,
there is no previous point, so we should assume the previous segment is
"visible" as soon as the first point is], but does so *before* pc1 is
even calculated. This makes following occlusion/brush/clipping checks
work with zero values [which leads to no earsing in most cases].

Now *first* calculate pc1, *then* set pc0 to pc1.

Maniphest Tasks: T94137

Differential Revision: https://developer.blender.org/D13593
2021-12-17 14:38:11 +01:00
7c9e409985 Outliner ID Remap Users: hide ID type from the UI
The correct type should be set by invoke already, changing it to a non-
matching type (e.g. trying to remap Mesh users with a Camera block) does
not really make sense afaict, reason being that we would be presented
with the "Invalid old/new ID pair" message in such case anyways (code
checks GS(old_id->name) == GS(new_id->name)).

This alone wouldnt be a pressing issue, but since doing this with an
object ID type crashes atm., it seems to make sense to clean this up now
(of course the crash should be looked into, but this is for a separate
patch -- if that is solved, we could also think about adding the "Remap
Users" entry back in the context menu for objects as well [which was
removed in rB17bd5c9d4b1e for some reason]).

Part of T93799.

Differential Revision: https://developer.blender.org/D13512
2021-12-17 13:58:25 +01:00
9690b7c91b Fix (unreported): missed running versioning code in some files
The versioning code was accidentally put not at the very bottom.
That lead to a situation where it wasn't run on some files that happened
to be within a specific short time frame.

Since the versioning code is idempotent, it can just run again on existing
files. Therefore, this commit just moves it back to the bottom so that it
is executed on all files again.

Broken Commit: rB5b61737a8f41688699fd1d711a25b7cea86d1530.
2021-12-17 13:49:53 +01:00
367b484841 Fix T94166: set handle position node crashed after refactor
This was an oversight in rB8e2c9f2dd3118bfdb69ccf0ab2b9f968a854aae4.
2021-12-17 10:40:01 +01:00
b9d6271916 GPU: Sort SSBOs In Shader Interface.
SSBOs weren't sorted, but other types were. This was an
oversight when SSBOs were introduced (GPU compute pipeline).

Issue identified by @fclem.
2021-12-17 08:16:06 +01:00
7788293954 Cleanup: Silenced unused var warnings. 2021-12-17 08:04:35 +01:00
0e1bb232e6 UI: move "undo history" from a custom popup to a menu type
This lets the undo history expand as a regular sub-menu
instead of being a popup.

Also disable the active undo step menu item as this is a no-op.
2021-12-17 17:28:57 +11:00
c536eb410c Cleanup: spelling in comments 2021-12-17 15:26:28 +11:00
6b3c3454d3 Cleanup: use more common naming suffix for item callbacks 2021-12-17 15:11:16 +11:00
Johannes Jakob
1f50c2876e UI: Correct "QuickTime" Spelling
Change the spelling of the QuickTime output video container item from
"Quicktime" to "QuickTime"

Differential Revision: https://developer.blender.org/D10929

Reviewed by Harley Acheson
2021-12-16 17:59:06 -08:00
b7e151d876 Cleanup: Simplify logic in set material node 2021-12-16 15:44:50 -06:00
da2c564bb0 Geometry Nodes: Support point clouds in the set material node
Now that point clouds can be rendered with cycles, it makes sense
to allow assigning a material to them. Note that like volumes, they
only support a single material though.
2021-12-16 15:39:59 -06:00
35b1e9fc3a Cycles: pointcloud rendering
This add support for rendering of the point cloud object in Blender, as a native
geometry type in Cycles that is more memory and time efficient than instancing
sphere meshes. This can be useful for rendering sand, water splashes, particles,
motion graphics, etc.

Points are currently always rendered as spheres, with backface culling. More
shapes are likely to be added later, but this is the most important one and can
be customized with shaders.

For CPU rendering the Embree primitive is used, for GPU there is our own
intersection code. Motion blur is suppored. Volumes inside points are not
currently supported.

Implemented with help from:
* Kévin Dietrich: Alembic procedural integration
* Patrick Mourse: OptiX integration
* Josh Whelchel: update for cycles-x changes

Ref T92573

Differential Revision: https://developer.blender.org/D9887
2021-12-16 20:54:04 +01:00
2229179faa Revert "Cycles-X: Add hysteresis to resolution divider algorithm"
This reverts commit d8b4275162. It causes reduced
viewport render resolution. Revert for now until I have time to look into this
more closely.
2021-12-16 18:29:27 +01:00
bd12855110 Cleanup: Move curve.c to C++
I need this for a refactor I'm looking into for bounding boxes.
It may be helpful in the future when using `CurveEval` in more places.

Differential Revision: https://developer.blender.org/D13596
2021-12-16 11:22:48 -06:00
197b3502b0 LibOverride: Further improve creation/resync pre-process speed.
Fully get rid of `BKE_collection_object_find` in
`lib_override_group_tag_data_object_to_collection_init`, even if only
used a few times this function was still noticeable in profiling data.

Now instead loop over collections' objects to build required
object-to-collections mapping.

Adds an extra 5-10% speed-up compared to previous commit rB0624fad0f3ff.

Related to T94059.
2021-12-16 18:15:19 +01:00
9765ddf4eb Fix T94109: 3d cursor crash when using shortcut
Operator was erroneously starting edge_slide operation.

Revert part of the changes in rB3fab16fe8eb4 as obedit_type was being
confused with object_mode.
2021-12-16 13:45:35 -03:00
0624fad0f3 LibOverride: Improve speed of resync and creation of liboverrides.
`BKE_collection_object_find` has extremely bad performances (very high
time complexity). While ideally this should be fixed in that API, for
now cache its results once at the beginning of the resync/creation
process.

This makes loading of complex production files with a lot of
liboverrides to resync three to four times faster.

Thanks to @brecht for the profiling in T94059.
2021-12-16 17:27:38 +01:00
b1f865f9d3 LibOverride: Cleanup log about unfound subitems.
Not finding subitem when its name and index are invalid/unset is
expected behavior, and does happen when e.g. inserting a new constraint
or modifier at the begining of the stack.
2021-12-16 16:48:00 +01:00
0f589f8d3c Fix T94115: Selecting current action in undo history undoes all
When selecting the current undo step there is no need to do anything.

Fix and minor refactor to de-duplicate refreshing after running
undo/redo & undo history.
2021-12-16 23:40:11 +11:00
d6902668e3 UI: support Copy To Selected for id-properties [GN modifier properties]
Both {key Alt} editing behavior as well as `Copy To Selected` were not
working on geometry nodes modifiers (even if these matched exactly -
having the same nodegroup - on multiple objects)

Reason is that code checks pointer equality on the discovered properties
[geometry nodes modifier properties are stored as ID properties], but
these are not the same across objects (since these are fetched from
NodesModifierSettings - which are different on different objects).

note: if general custom properties are "API defined" on existing classes,
this was working, we are getting the exact property for different IDs in
this case

Now be more permissive with ID properties not defined on classes in
general and dont check pointer equality for them. For ID properties on
specific IDs (not the ones defined on classes) this //might// be undesired
(havent spotted issues though, even if equally named ID properies with
different types existed -- this then simply does nothing).

For geometry nodes modifiers, new code also checks if the nodegroups are
the same [since generic naming "Input_XXX" is shared for all modifiers --
and starting to copy over things to unrelated modifiers is not desired
here].

Fixes T93983.

Maniphest Tasks: T93983

Differential Revision: https://developer.blender.org/D13573
2021-12-16 13:18:19 +01:00
6da23db5e0 UI: deduplicate code for Copy To Selected and Alt-button tweaking
This resolves an old TODO to deduplicate code in copy_to_selected_button
& ui_selectcontext_begin.
This is also in hindsight of adding id-property support [incl. Geometry
Nodes modifier properties] for this in the next commit.
No behavior change expected here.

ref T93983 & D13573
2021-12-16 13:18:19 +01:00
3e04d37529 Cleanup: correct docstring for driver_variable_name_validate
No functional changes.
2021-12-16 12:54:25 +01:00
59774d64f0 Docs: add doc-strings for BLI_path functions 2021-12-16 21:58:04 +11:00
21c7689b77 Animation: send notifier when keyframe is inserted
`<some_id>.keyframe_insert()` now sends a notifier that animation data
was changed, so that animation-related editors can properly refresh.

Since this function is quite high-level (if necessary it creates the
Action and FCurves), I thought this would be a suitable location for the
notifier. If high keyframing speed is required, it is still recommended
to use `FCurveKeyframePoints.insert(options={'FAST'})` instead.
2021-12-16 11:26:21 +01:00
1818110459 Fix compile error on Windows. 2021-12-16 10:08:31 +01:00
8dbd406ea0 WM: various changes to file writing behavior
Saving with only a filename (from Python) wasn't being prevented,
while it would successfully write the file to the working-directory,
path remapping and setting relative paths wouldn't work afterwards
as `Main.filepath` would have no directory component.

Disallow this since it's a corner case which only ever occurs
when path names without any directories are used from Python,
the overhead of expanding the working-directory for all data saving
operations isn't worthwhile.

The following changes have been made:

- bpy.ops.wm.save_mainfile() without a filepath argument
  fails & reports and error when the file hasn't been saved.

  Previously it would write to "untitled.blend" and set the
  `G.main->filepath` to this as well.

- bpy.ops.wm.save_mainfile(filepath="untitled.blend")
  fails & reports and error as the filename has no directory component.

- `BLI_path_is_abs_from_cwd` was added to check if the path would
  attempt to expand to the CWD.
2021-12-16 16:27:35 +11:00
15c3617009 Cleanup: simplify file saving logic
Revert part of the fix from 073669dd85
that initialized the file-path on first save as it's no longer needed.

Also remove relbase argument to BLI_path_normalize as the destination
file paths shouldn't use relative locations.
2021-12-16 16:27:35 +11:00
Aaron Carlisle
4e98d974b5 Nodes: Begin splitting composite node buttons into individual files
Currently, most node buttons are defined in `drawnode.cc` however,
this is inconvenient because it requires editing many files when adding new nodes.
The goal is to minimize the number of files needed to add or update a node.

This commit moves most of the node layout functions for composite nodes into their respected
`source/blender/nodes/composite/nodes` file.

In the future, these functions will be simplified to `node_layout` once files have their own namespace.
See {D13466} for more information.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13523
2021-12-15 21:30:29 -05:00
5de109cc2d Remove G.relbase_valid
In almost all cases there is no difference between `G.relbase_valid`
and checking `G.main->filepath` isn't an empty string.

In many places a non-empty string is already being used instead of
`G.relbase_valid`.

The only situation where this was needed was when saving from
`wm_file_write` where they temporarily became out of sync.
This has been replaced by adding a new member to `BlendFileWriteParams`
to account for saving an unsaved file for the first time.

Reviewed By: brecht

Ref D13564
2021-12-16 11:41:46 +11:00
4b12f521e3 Cleanup: spelling 2021-12-16 11:38:09 +11:00
807efa8538 Cleanup: clang-format 2021-12-16 11:38:08 +11:00
366ec5f0f8 Cleanup: unused variable warning 2021-12-16 11:38:06 +11:00
b265b447b6 Fix various cases of incorrect filtering in node link drag search
Some nodes didn't check the type of the link's socket for filtering.
Do this with a combination of manually calling the node tree's validate
links function and using the helper function for declarations.

Also clean up a few cases that added geometry sockets manually
when they can use the simpler helper function.
2021-12-15 18:05:45 -06:00
36a830b4d3 Fix: Compare node missing from link drag search
This was missing from rB11be151d58ec0ca955f.
It uses the same approach as the quadrilateral node.
2021-12-15 17:37:55 -06:00
49311a73b8 Fix: Crash in nodes modifier with missing node group
We cannot depend on node->id being non-null for group nodes.
2021-12-15 15:00:20 -06:00
aa55cb2996 Cleanup: Use const arguments, references
Also slightly change naming to avoid camel case.
2021-12-15 14:51:58 -06:00
43875e8dd1 Cleanup: Remove no-op node preview function calls
This patch removes no-op node editor preview code (`PR_NODE_RENDER`)
and most calls to `BKE_node_preview_init_tree`. The only remaining call is
in the compositor.

 - Shader nodes previews don't seem to do anything.
 - In-node previews for the texture node system doesn't work either.

This is a first step to refactoring to remove `preview_xsize`,
`preview_ysize`, and `prvr` from nodes in DNA, aligned with
the general goal of removing runtime/derived data from data
structs.

Differential Revision: https://developer.blender.org/D13578
2021-12-15 14:27:38 -06:00
b32f5a922f Fix T93995: Cycles camera motion blur not working in right stereo view
Thanks to Michael (michael64) for identifying the solution.

Ref D13567
2021-12-15 20:47:54 +01:00
11be151d58 Node Editor: Link Drag Search Menu
This commit adds a search menu when links are dragged above empty
space. When releasing the drag, a menu displays all compatible
sockets with the source link. The "main" sockets (usually the first)
are weighted above other sockets in the search, so they appear first
when you type the name of the node.

A few special operators for creating a reroute or a group input node
are also added to the search.

Translation is started after choosing a node so it can be placed
quickly, since users would likely adjust the position after anyway.

A small "+" is displayed next to the cursor to give a hint about this.

Further improvements are possible after this first iteration:
 - Support custom node trees.
 - Better drawing of items in the search menu.
 - Potential tweaks to filtering of items, depending on user feedback.

Thanks to Juanfran Matheu for developing an initial patch.

Differential Revision: https://developer.blender.org/D8286
2021-12-15 09:51:57 -06:00
474adc6f88 Refactor: Simplify spreadsheet handling of cell values
Previously we used a `CellValue` class to hold the data for a cell,
and called a function to fill it whenever necessary. This is an
unnecessary complication when we have virtual generic arrays
and most data is already easily accessible that way anyway.
This patch removes `CellValue` and uses `fn::GVArray` to provide
access to data instead.

In the future, if rows have different types within a single column,
we can use a `GVArray` of `blender::Any` to interface with the drawing.

Along with that, the use of virtual arrays made it easy to do a
few other cleanups:
 - Use selection domain interpolations from rB5841f8656d95
   for the mesh selection filter.
 - Change the row filter to only calculate for necessary indices.

Differential Revision: https://developer.blender.org/D13478
2021-12-15 09:34:13 -06:00
d79868c4e6 Fix T93975: add more nested instance limit checks
Differential Revision: https://developer.blender.org/D13585
2021-12-15 15:46:39 +01:00
Michael
5f52684a0f Initialize the fourth and final instance variable of MemoryProxy
The constructor of MemoryProxy initializes 3 of 4 instances variables.
If a MemoryProxy is constructed and MemoryProxy::free is called
on this instance, buffer_ is undefined and 'delete buffer_;' causes errors.

Although this misuse pattern does not exist in the current codebase
it already tripped up the Address Sanitizer on various occasions
while debugging unrelated problems.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D13569
2021-12-15 15:46:28 +01:00
1a833dbdb9 Geometry Nodes: Add Selection to Attribute Statistics
This adds a bool field selection input to the Attribute Statistics node.
This is useful for running calculations on a subset of the input field data
rather that then whole set.

Differential Revision: https://developer.blender.org/D13520
2021-12-15 08:04:49 -06:00
e85d7d5a28 Fix T93971: "Center Cursor & Frame All" fails to redraw
bda9e4238a changed smooth-view
not to redraw when there were no changes made.
Redrawing is needed for repositioning the cursor.

Subscribe to changes to the 3d cursor to ensure all view ports
are updated (not just the current one).
2021-12-16 00:15:13 +11:00
c101ded463 Cleanup: remove disabled code
Originally pointcache wasn't supported when the file wasn't saved.
Remove commented code as this hasn't been the case for a long time.
2021-12-15 23:45:11 +11:00
a9d8ff6e21 Cleanup: unused variable warning 2021-12-15 23:43:31 +11:00
883e4c089a MetaBall: optimize memory allocation for meta-ball tessellation
Double the allocation size when the limit is reached instead of
increasing by a fixed number.

Also re-allocate to the exact size once complete instead of over
allocating. This gives a minor speedup in my tests ~19% faster
tessellation for ~1million faces.
2021-12-15 23:40:39 +11:00
6a885e5d89 Fix meta-ball bound-box calculation reading past buffer bounds
This broke "test_undo.view3d_multi_mode_select" test in
"lib/tests/ui_simulate" and is likely exposed by recent changes to
bounding box calculation.

The missing check for DL_INDEX4 dates back to code from 2002 which
intended to check this but was checking for DL_INDEX3 twice
which got removed as part of a cleaned up.

This could be hidden from memory checking tools as meta-balls
over-allocate vertex arrays.
2021-12-15 23:40:33 +11:00
3a856f7967 Fix compile errors on windows. 2021-12-15 11:51:03 +01:00
6051b80dd2 Cleanup: Use pixel in stead of texels in naming. 2021-12-15 11:19:29 +01:00
723fb16343 Images: 1,2,3 channel support for transform function.
Added support for 1, 2, 3 float channel source images. Destination
images must still be 4 channels.
2021-12-15 11:09:31 +01:00
67b657f07c Fix T94082: Curve to point empty evaluated NURBS crash
This is basically the same as rBee4ed99866fbb7ab04, the fix is
simply to check if the spline has evaluated points when deciding
the offsets into the result points array.
2021-12-14 18:57:45 -06:00
644eb68524 Fix T93949: Preview Image Error When No Screen
Fix an error if "File Preview Type" is "Auto" and there is no screen.

See D13574 for details.

Differential Revision: https://developer.blender.org/D13574

Reviewed by Julian Eisel
2021-12-14 13:50:40 -08:00
40aee0b2e9 Fix possible use-after-free on error handling during VR view drawing
Whenever an exception happens in VR session code, we cancel the entire
session. Alongside that, we removed the "surface" item used to draw into
an offscreen context. This would mess up the iterator of the surface
draw loop.
Similar to 7afd84df40.
2021-12-14 20:57:39 +01:00
4cfa21f09b Fix null-pointer dereference on error handling during VR view drawing 2021-12-14 20:44:17 +01:00
7afd84df40 Fix possible use-after-free on error handling during VR view drawing
Whenever an exception happens in VR session code, we cancel the entire
session. Alongside that, we removed the "surface" item used to draw into
an offscreen context. But this may still be stored as active surface,
leading to a use-after-free when deactivating this active surface, for
example.
2021-12-14 20:13:58 +01:00
7e8912eb96 Fix Cycles compilation with CUDA / Optix after recent Map Range additions. 2021-12-14 20:01:30 +01:00
Charlie Jolly
5b61737a8f Nodes: Add vector support to Map Range node
This replaces lost functionality from the old GN Attribute Map Range node.
This also adds vector support to the shader version of the node.

Notes:
This breaks forward compatibility as this node now uses data storage.

Reviewed By: HooglyBoogly, brecht

Differential Revision: https://developer.blender.org/D12760
2021-12-14 18:27:01 +00:00
44232a2ce6 Cleanup: Remove unused arguments 2021-12-14 12:16:28 -06:00
d56bbfea7b Cleanup: Remove runtime uiBlock pointer from nodes
Code is simpler when the uiBlocks used during drawing are simply
stored in an array. Additionally, looping can be simpler when we use
an vector to hold a temporary copy of the tree's linked list of nodes.

This patch also slightly changes how uiBlocks are "named" in
`node_uiblocks_init`. Now it uses the node name instead of the
pointer, which is helpful so we rely less on the node's address.

Differential Revision: https://developer.blender.org/D13540
2021-12-14 11:19:47 -06:00
fdd41ac49e Cleanup: Simplify node group input and output socket verification
This commit refactors the way the socket lists for group nodes,
and group input/output nodes are verified to match the group's
interface.

Previously the `bNodeSocket.new_sock` pointer was used to
temporarily mark the new sockets. This made the code confusing
and more complicated than necessary.

Now the old socket list is saved, and sockets are moved directly from
the old list to a new list if they match, or a new socket is created
directly in the new list.

This change is split from D13518, which aims to remove the `new_node`
and `new_sock` pointers. In the future this code might be removed
entirely in favor of using node socket declarations.

Differential Revision: https://developer.blender.org/D13543
2021-12-14 10:56:12 -06:00
f5ce243a56 Geometry Nodes: support instance attributes when realizing instances
This patch refactors the instance-realization code and adds new functionality.
* Named and anonymous attributes are propagated from instances to the
  realized geometry. If the same attribute exists on the geometry and on an
  instance, the attribute on the geometry has precedence.
* The id attribute has special handling to avoid creating the same id on many
  output points. This is necessary to make e.g. the Random Value node work
  as expected afterwards.

Realizing instance attributes has an effect on existing files, especially due to the
id attribute. To avoid breaking existing files, the Realize Instances node now has
a legacy option that is enabled for all already existing Realize Instances nodes.
Removing this legacy behavior does affect some existing files (although not many).
We can decide whether it's worth to remove the old behavior as a separate step.

This refactor also improves performance when realizing instances. That is mainly
due to multi-threading. See D13446 to get the file used for benchmarking. The
curve code is not as optimized as it could be yet. That's mainly because the storage
for these attributes might change soonish and it wasn't worth optimizing for the
current storage format right now.

```
1,000,000 x mesh vertex:       530 ms -> 130 ms
1,000,000 x simple cube:      1290 ms -> 190 ms
1,000,000 x point:            1000 ms -> 150 ms
1,000,000 x curve spiral:     1740 ms -> 330 ms
1,000,000 x curve line:       1110 ms -> 210 ms
10,000 x subdivided cylinder:  170 ms ->  40 ms
10 x subdivided spiral:        180 ms -> 180 ms
```

Differential Revision: https://developer.blender.org/D13446
2021-12-14 15:57:58 +01:00
8e2c9f2dd3 Geometry Nodes: simplify using selection when evaluating fields
We often had to use two `FieldEvaluator` instances to first evaluate
the selection and then the remaining fields. Now both can be done
with a single `FieldEvaluator`. This results in less boilerplate code in
many cases.

Performance is not affected by this change. In a separate patch we
could improve performance by reusing evaluated sub-fields that are
used by the selection and the other fields.

Differential Revision: https://developer.blender.org/D13571
2021-12-14 15:40:27 +01:00
b44a500988 Fix T93920: Wrong field inferencing state with unavailable socket
This commit ignores unavailable sockets in one more place, to fix the
case in T93920.

Differential Revision: https://developer.blender.org/D13562
2021-12-14 08:30:45 -06:00
b5c18288f5 Fix T93649: Blender freezes when saving with active VR session
Dead-lock when VR viewport drawing and depsgraph updates would fight for
the draw-manager GL lock. This didn't usually cause issues because the
depsgraph would be evaluated at this point already, except in rare
exceptions like after file writing.

Fix this by ensuring the XR surface gets its depsgraph updated after
handling notifiers, which is where regular windows also do the depsgraph
updating.
2021-12-14 15:23:50 +01:00
5cce6894d2 Cleanup: consistent naming for the blender file name 2021-12-14 21:32:14 +11:00
381cef1773 Cleanup: remove oudated comment from early COW development
Added in 161ab6109e
2021-12-14 21:17:06 +11:00
c9e5897bb0 Cleanup: use typed enum for wmDrag.flags
Also use 'e' prefix for enum type name.
2021-12-14 21:08:30 +11:00
f6fd3a84c2 Cleanup: reorganize doxygen modules
- Nest compositor pages under the compositor module
- Nest GUI, DNA/RNA & externformats modules under Blender.
- Remove modules from intern which no longer exist.
- Add intern modules (atomic, eigen, glew-mx, libc_compat, locale,
  numaapi, rigidbody, sky, utfconv).
- Use 'intern_' prefix for intern modules since some of the modules
  use generic terms such as locale & atomic.
2021-12-14 20:56:11 +11:00
a207c1cdaf Cleanup: resolve parameter mis-matches in doc-strings
Renamed or removed parameters which no longer exist.
2021-12-14 18:35:23 +11:00
c097c7b855 Cleanup: correct unbalanced doxygen groups
Also add groups in some files.
2021-12-14 16:17:10 +11:00
c1f5d8d023 Fix T91005: Autosplit produces unusable files
Audio PTS was reset for each new file. This caused misalignment of video
and audio streams. In Blender, these files can't be loaded, other
players will fail to align audio and video.

Since timestamps are reset intentionally, reset also video stream
timestamps.

There were other bugs:
After timestamp was reset for audio, write_audio_frames started
encoding from timeline start until target frame, so each split video
had more audio than it should.

Also audio for last frame before splitting was written into new file.

Differential Revision: https://developer.blender.org/D13280
2021-12-14 01:16:24 +01:00
b647509913 Fix T93844: High memory usage during VSE preview
Since 88c02bf826 FFmpeg handles are freed if image is not displayed.
This change did not work correctly if strips are inside meta strip,
because overlap did not consider meta strip boundary, only strips inside
of meta strip.

Pass frame range to `sequencer_all_free_anim_ibufs`, if strip is inside
of meta strip, frame range is reduced to fit meta strip boundary, but if
meta strip is being edited, range must be set to +/-`MAXFRAME`,
otherwise playback performance would be too bad.
2021-12-14 00:43:54 +01:00
2a0a6a0541 Remove G.save_over
The difference between G.save_over and G.relbase_valid was minor.

There is one change in functionality. When saving the default-startup
file from an already loaded blend file - future save actions will
continue to write to the originally loaded file instead of prompting
the user to select a location to save the file.

This change makes saving the startup file behave the same way
"Save a Copy" does.

Reviewed By: brecht

Ref D13556
2021-12-14 09:42:46 +11:00
a603bb3459 Cleanup: clang-format 2021-12-14 09:42:44 +11:00
e688c927eb Fix T94022: Both options GPU/CPU checked under preferences cause viewport render crash. (ARM/Metal)
This fixes crash T94022 when selecting live viewport render with both GPU & CPU devices selected. It is caused by incorrect `KernelBVHLayout` assignment. Similar to `BVH_LAYOUT_MULTI_OPTIX` for Optix, this patch adds a `BVH_LAYOUT_MULTI_METAL` to correctly redirect to the correct Metal BVH layout type.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13561
2021-12-13 22:34:48 +00:00
Piotr Makal
b8952ecec9 Cleanup: Remove unused curve types from enum
There were a few unused enum values: `CU_CARDINAL` and `CU_BSPLINE`
This commit cleans them up from code as they were not used for
anything meaningful.

Differential Revision: https://developer.blender.org/D13554
2021-12-13 15:13:47 -06:00
0606adceb3 UI: String Search: Add an optional weight parameter
This builds off of rBf951aa063f7, adding a weight parameter which can
be used to change the order of items when they have the same match
score. In the future, if string searching gets a C++ API, we could
use an optional parameter for the weight, since it is not used yet.

This will be used for the node link drag search menu (D8286).

Differential Revision: https://developer.blender.org/D13559
2021-12-13 13:58:30 -06:00
Cody Winchester
a90c356467 GPencil: Add randomize options to Length modifier
This patch adds a randomize factor for the start/end lengths in the Length modifier.

Reviewed By: #grease_pencil, antoniov, pepeland, HooglyBoogly

Differential Revision: https://developer.blender.org/D12928
2021-12-13 17:14:44 +01:00
459af75d1e GPencil: New Shrinkwrap modifier
his new modifier is equals to the existing mesh modifier but adapted to grease pencil.

The underlying functions used to calculate the shrink are the same used in meshes.

{F11794101}

Reviewed By: pepeland, HooglyBoogly

Differential Revision: https://developer.blender.org/D13192
2021-12-13 17:09:22 +01:00
49802af7cd Cycles: add text explaining minimum requirements for Metal when no device found 2021-12-13 15:40:59 +01:00
Brecht Van Lommel
3f96555123 Cycles: enable Metal GPU rendering
This adds the remaining bits to enable Metal on macOS. There are still
performance optimizations and other improvements planned, but it should
now be ready for early testing.

This is currently only enabled on in Arm builds for M1 GPUs. It is not
yet working on AMD or Intel GPUs.

Ref T92212

Differential Revision: https://developer.blender.org/D13503
2021-12-13 13:57:13 +01:00
8ba6302696 Geometry Nodes: fix combining field inputs
This was an oversight in rB7b88a4a3ba7eb9b839afa6c42d070812a3af7997.
2021-12-13 13:51:42 +01:00
8709cbb73e Fix T93704: StructRNA.path_resolve fails silently with missing keys
Resolving the path to a missing pose-bone (for example),
was not raising an error as it should have.

Regression introduced in f9ccd26b03,
which didn't update collection lookup logic to fail in the case the
key of a collection wasn't found.
2021-12-13 23:48:17 +11:00
1686979747 Geometry Nodes: move up destruct instructions in procedure
This implements an optimization pass for multi-function procedures.
It optimizes memory reuse by moving destruct instructions up.
For more details see the in-code comment.

In very large fields with many short lived intermediate values, this change
can improve performance 3-4x. Furthermore, in such cases, peak memory
consumption is reduced significantly (e.g. 100x lower peak memory usage).

Differential Revision: https://developer.blender.org/D13548
2021-12-13 13:28:33 +01:00
e549d6c1bd Fix T93169: Weightpaint falloff popover drawn twice
This came with {rBf8a0e102cf5e}.

The panel was meant specifically for the gradient tool, but since it was
given the ".weighpaint" context, it would also draw as part of generic
header toolsettings drawing.

Now remove this context on purpose and only draw this specifically from
the gradient tools ToolDef.

Maniphest Tasks: T93169

Differential Revision: https://developer.blender.org/D13268
2021-12-13 09:38:17 +01:00
bea5a9997d Cleanup: clang-format 2021-12-13 16:22:21 +11:00
36c6b2e893 Cleanup: spelling in comments
Also move notes about where noise functions come from
into the function body as it's not relavant to the public doc-string.
2021-12-13 16:22:20 +11:00
8ad2642c47 Cleanup: use "filepath" term for Main, BlendFileData & FileGlobal
Use "filepath" which is the current convention for naming full paths.

- Main use "name" which isn't obviously a file path.
- BlendFileData & FileGlobal used "filename" which is often
  used for the name component of a path (without the directory).
2021-12-13 16:22:19 +11:00
27231afce5 Cleanup: remove checks for invalid input for Python Run utilities
These arguments must be non-null for useful functionality,
there is no need for paranoid checks.

The return value in case of invalid input for BPY_run_string_as_number
was also wrong (casting -1 to a bool, when false was expected).
2021-12-13 16:22:18 +11:00
80f1527762 Cleanup: Point cloud vs point-cloud in comments
Point cloud is two separate words, this just changes comments in
a few places where we were inconsistent. A small wording change
to another comment is also included.
2021-12-12 23:00:39 -06:00
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
f5679838bc Docs: document all Global (G) struct members 2021-12-13 14:05:31 +11:00
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
03015a9b22 Cleanup/docs: Add comment to spline lookup factor method 2021-12-12 18:03:30 -06:00
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
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
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
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
96387a2eff Cleanup: const, autoreleasepool, remove unneeded cast.
Early return in some places also.
De-duplicate getSystemDir and getUserDir also.

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D13211
2021-12-11 19:07:36 +05:30
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
4c705ab8fe Fix compilation error on Windows platform. 2021-12-11 09:48:43 +01:00
8c7d970e2c Sky: Use Gauss-Laguerre quadrature for optical depth calculation
This allows to use fewer evaluations (30 msec down to 23 for me) while giving more accurate results (3x-10x less relative absolute error) compared to classic ray marching.

Not a massive difference, but meh, it's better. For Cycles the speedup doesn't really matter much, but I also have a patch for Eevee support.

I've also tried Gauss-Legendre and Gauss-Lobatto - the latter was always worse, while the former was slightly better at 2deg elevation but notably worse on 15deg.

Unfortunately the same approach can't be used for the integration along the primary ray, since there we also need the accumulated transmission so far at every integration point, not just the total result.

Differential Revision: https://developer.blender.org/D13521
2021-12-11 01:02:11 +01:00
1a02c0d7dd Cleanup: Return early for null check 2021-12-10 16:42:34 -06:00
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
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
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
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
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
60a9703de8 Added support for large images to openexr. 2021-12-10 15:38:46 +01:00
05df6366a4 Added support for large texture to OCIO. 2021-12-10 15:38:25 +01:00
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
37e799e299 Fix crash using 32k images.
Use IMB_get_rect_len to solve overflow issues.
2021-12-10 12:28:48 +01:00
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
63f8d18c0f Cleanup: move public doc-strings into headers for 'python/intern'
Ref T92709
2021-12-10 21:40:53 +11:00
3060217d39 Cleanup: move public doc-strings into headers for 'nodes'
Ref T92709
2021-12-10 21:40:30 +11:00
715f57371b Cleanup: spelling in comments 2021-12-10 21:28:56 +11:00
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
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
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
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
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
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
Andrii
b8f41825e8 Fix Cycles wrong adaptive sampling render when using sample offset
Sample offset was not accounted for in the adaptive sampling code and caused
issues, like immediately applied adaptive filtering, with non-zero values.

Differential Revision: https://developer.blender.org/D13510
2021-12-09 20:54:41 +01:00
Andrii
dbd64a5592 Cycles: support merging images rendered with adaptive sampling
This patch adds support for merging images rendered with adaptive sampling to
the merge operator (which is currently only exposed in the Python API).

To do this an sample count buffer is created for each render layer from the
sample count pass if it exists, or from the metadata otherwise. This is then
used for averaging passes.

Differential Revision: https://developer.blender.org/D13457
2021-12-09 20:52:46 +01:00
Andrii
20987b0f29 Cleanup: use more modern C++ in Cycles merge operator
Use structured binding and for-each loop, remove reduntant type casts, use
find_if instead of loop.

Differential Revision: https://developer.blender.org/D13456
2021-12-09 20:52:46 +01:00
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
ad44f22397 Fix T93498: Cycles fast GI add method affected by bounces settings
This is only for the replace method.
2021-12-09 18:17:48 +01:00
4b00a779ec Fix T93890: Cycles error with shadow catcher + OptiX denoise without passes 2021-12-09 18:01:26 +01:00
56fa6f58a0 Fix T93874: Cycles crash with fast GI approximation 2021-12-09 17:46:21 +01:00
e427e4dbb1 Fix T93871: Image.has_data returns True for images that failed to load 2021-12-09 17:36:19 +01:00
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
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
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
d812e46f40 Cleanup: move public doc-strings into headers for 'io/usd'
Ref T92709
2021-12-09 22:47:58 +11:00
74e57efb2d Cleanup: move public doc-strings into headers for 'io/alembic'
Ref T92709
2021-12-09 22:37:24 +11:00
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
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
50f378e5c8 Cleanup: move public doc-strings into headers for 'io/collada'
Ref T92709
2021-12-09 22:25:45 +11:00
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
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
65de17ece4 Cleanup: move public doc-strings into headers for 'freestyle'
Ref T92709
2021-12-09 21:09:54 +11:00
bc01003673 Cleanup: move public doc-strings into headers for 'nodes/geometry'
Ref T92709
2021-12-09 20:58:39 +11:00
cd4a7be5b2 Cleanup: move public doc-strings into headers for 'io/gpencil'
Ref T92709
2021-12-09 20:34:14 +11:00
3647a1e621 Cleanup: move public doc-strings into headers for 'geometry'
Ref T92709
2021-12-09 20:23:10 +11:00
8ef8f3a60a Cleanup: spelling in comments 2021-12-09 20:21:26 +11:00
15a428eab0 Cleanup: move public doc-strings into headers for 'gpencil_modifiers'
Removed doc-strings for operator definitions as they didn't provide
useful information in addition to the operators own description.

Ref T92709
2021-12-09 20:11:29 +11:00
8aed5dbcf8 Cleanup: move public doc-strings into headers for 'compositor'
Ref T92709
2021-12-09 20:01:49 +11:00
7c76bdca1b Cleanup: move public doc-strings into headers for 'gpu'
Ref T92709
2021-12-09 20:01:47 +11:00
9f546d6908 Cleanup: move public doc-strings into headers for 'imbuf'
Ref T92709
2021-12-09 20:01:45 +11:00
9e365069af Cleanup: move public doc-strings into headers for 'blenlib'
- 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.
- Minor improvements to doc-strings.

Ref T92709
2021-12-09 20:01:44 +11:00
Alaska
d8b4275162 Cycles-X: Add hysteresis to resolution divider algorithm
Adds hysteresis to the resolution divider algorithm to avoid having the resolution bounce around when on the boundary of two resolutions.

Reviewed By: brecht, leesonw

Differential Revision: https://developer.blender.org/D12385
2021-12-09 09:18:47 +01:00
894269ad12 Fix incorrect copying of XR action map items
After using MEM_dupallocN() on the original item, the bindings ListBase
for the new item needs to be cleared and each binding copied separately.
2021-12-09 16:29:05 +09:00
30cebf5747 Cleanup: Remove empty node button layout function
Was unused since the first commit:
rB658b4c0d56dffbcf1476c2a2a019fa0ecfb79376
2021-12-08 22:02:45 -05:00
cf6be711e2 Fix T93869: snap cursor may fail in orthographic view
Float precision issues cause the `ED_view3d_win_to_3d_on_plane` to return
a value even when the view ray is parallel to the plane.

A more general solution might be desired in this case, as other areas that
use `ED_view3d_win_to_3d_on_plane` might have the same problem.

For now, just work around the problem for the snap cursor.
2021-12-08 23:47:26 -03:00
3753a0b72b Fix T93523: Memory leak in Menu Search
Fixes a memory leak introduced by D13225.
Caused by not freeing the hash-map in some cases.

Differential Revision: https://developer.blender.org/D13432
2021-12-09 01:48:11 +01:00
be2213472f Fix T93858: Zstd-compressed .blend files from external tools aren't recognized
The issue here was that after the seek table check, the underlying file wasn't
rewound to the start, so the code that checks for the BLENDER header
immediately reaches EOF and fails.

Since Blender always writes files with a seek table, this bug isn't triggered
by files saved in Blender itself. However, files compressed in external tools
generally don't have a seek table.
2021-12-08 23:35:47 +01:00
f32b63ec58 Fix T93642: value used as transform offset is ignored in some modes
If a transform operator is executed as modal and has a "value" set, that value works as an offset.

However few transform modes were supporting this.

Include more transform modes as supported.
2021-12-08 14:21:57 -03:00
6ebc581b52 Cleanup: Avoid lookup the same property string multiple times
This is a micro-optimization that is useful for operators with many properties.
2021-12-08 14:21:57 -03:00
069d63561a Geometry Nodes: Mesh Island Node
This node is a field input that outputs a separate index for each mesh island.
The indices are based on the order of the lowest-numbered vertex in each island.

Authoring help from @hooglyboogly

Differential Revision: https://developer.blender.org/D13504
2021-12-08 10:14:03 -06:00
72b39d3f92 Fix T93728: Greasepencil separate will loose all vertex groups
Caused by {rB3b6ee8cee708}

The raw data is copied here correctly
[`BKE_gpencil_stroke_weights_duplicate` in
`BKE_gpencil_stroke_duplicate`] but the vertex groups names are missing.
Prior to above commit is was enough to have `ED_object_add_duplicate`
(this seemingly took care of duplicating object's defbase).
Now vertex groups names sit on the `bGPdata` rather than the `Object`,
and since the separate operation creates **new** `bGPdata` we have to
copy vertex groups names - and active index - over [via
`BKE_defgroup_copy_list`].

Maniphest Tasks: T93728

Differential Revision: https://developer.blender.org/D13509
2021-12-08 16:10:07 +01:00
e23b54a59f Cycles: Fix OS version warnings
This patch suppresses OS version warnings and hides currently unsupported Metal GPUs when enumerating devices.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13506
2021-12-08 15:08:12 +00:00
Campbell Barton
5e9dba822d Cleanup: Avoid error prone pointer storage in SnapObjectParams
eed48a7322 caused the `SnapObjectParams` to be stored in the `SnapObjectContext`.

As this pointer is always passing in stack memory, so it seems error prone to keep a reference to this in `SnapObjectContext` since failure to set this will reference undefined stack memory.

So avoid this by moving params out of `SnapObjectContext`.

Differential Revision: https://developer.blender.org/D13401
2021-12-08 12:05:36 -03:00
98bb8e6955 Fix T91680: viewport selection broken in macOS x86 build with Xcode 13
There is an apparent compiler bug here, tweak the code to avoid it. This did
not affect official builds as we were still using Xcode 12.
2021-12-08 15:46:15 +01:00
5b06759473 Cleanup: Use float2 for node view functions
Though the interfacing with `rctf` becomes slightly more complicated,
this should be more helpful as more of this code usese `float2` instead
of two separate floats.
2021-12-08 09:44:02 -05:00
61776befc3 Cleanup: move public doc-strings into headers for 'editors'
Ref T92709
2021-12-09 01:14:10 +11:00
8f1997975d ImBuf: Performance IMB_transform.
This change uses generics to reduce code duplication an increases
flexibility and performance. Performance increase isn't measurable
for end users.
2021-12-08 13:02:55 +01:00
32b1a13fa1 Cleanup: move public doc-strings into headers for 'sequencer'
Ref T92709
2021-12-08 21:05:06 +11:00
e89d42ddff Cleanup: move public doc-strings into headers for 'draw'
Ref T92709
2021-12-08 20:30:05 +11:00
a46ff1dd38 Cleanup: move public doc-strings into headers for 'shader_fx'
Ref T92709
2021-12-08 20:30:05 +11:00
2c0ccb0159 Cleanup: move public doc-strings into headers for 'simulation'
Ref T92709
2021-12-08 20:30:05 +11:00
07726ef1b6 Cleanup: move public doc-strings into headers for 'blentranslation'
Ref T92709
2021-12-08 20:30:05 +11:00
ca0c9757f2 Cleanup: moved IMB_transform to transform.cc.
Part of a refactoring to make IMB_transform more generic to reduce
unneeded branching.
2021-12-08 09:54:52 +01:00
a7b64a714d Cleanup: Silence clang-tidy warnings. 2021-12-08 09:52:38 +01:00
4f48b2992b Cleanup: move public doc-strings into headers for 'blenloader'
Ref T92709
2021-12-08 17:51:45 +11:00
93ba5e2375 Cleanup: move public doc-strings into headers for 'render'
Ref T92709
2021-12-08 17:12:43 +11:00
7e92717439 Cleanup: move public doc-strings into headers for 'windowmanager'
Ref T92709
2021-12-08 17:12:41 +11:00
db795a4727 Cleanup: move public doc-strings into headers for 'makesrna'
Ref T92709
2021-12-08 17:12:40 +11:00
da67a19ed9 Cleanup: move public doc-strings into headers for 'makesdna'
Ref T92709
2021-12-08 17:12:39 +11:00
2545119112 Cleanup: move public doc-strings into headers for 'blendthumb'
Ref T92709
2021-12-08 17:12:37 +11:00
d6c3ea9e7a Cleanup: move public doc-strings into headers for 'blenfont'
Ref T92709
2021-12-08 17:12:35 +11:00
00f3957b8e Cleanup: move public doc-strings into headers for 'modifiers'
Ref T92709
2021-12-08 17:12:33 +11:00
c1279768a7 Cleanup: Clang-Tidy modernize-redundant-void-arg 2021-12-08 00:31:20 -05:00
cbcd74de22 Cleanup: Missing braces in array declaration 2021-12-08 00:30:36 -05:00
b71e29b3da Cleanup: clang-format 2021-12-07 23:12:13 -05:00
47b36ddcce Cleanup: Nodes: clang-tidy modernize-redundant-void-arg 2021-12-07 23:09:19 -05:00
2964c4e1d0 Cleanup: spelling in comments 2021-12-08 13:31:19 +11:00
333dc7b5c4 Nodes: Add Shader Socket to new decleration API
This commit adds the shader socket type to the new socket builder api.

Re commits part of rB0bd3cad04edf4bf9b9d3b1353f955534aa5e6740
2021-12-07 21:05:13 -05:00
0d8c479225 Shader Nodes: Use camel case for file names
Recommits part of rBf60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c
2021-12-07 20:57:25 -05:00
1552c92fb1 Cycles: Fix Metal BVH crash caused by missing WITH_METAL define
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13505
2021-12-07 21:23:52 +00:00
5568455d63 Cleanup: Extend a few comments in BKE_spline.hh 2021-12-07 15:17:10 -05:00
204ae33d75 Revert "Fix T93350: Cycles renders shows black during rendering huge resolutions"
This reverts commit 5e37f70307.

It is leading to freezing of the entire desktop for a few seconds when stopping
3D viewport rendering on my Linux / NVIDIA system.
2021-12-07 20:49:34 +01:00
b815088416 Tests: add Cycles perspective/ortho/panoramic camera regression tests
Ref D12691
2021-12-07 20:08:12 +01:00
Håkan Ardö
24e0165463 Cycles: add Fisheye Lens Polynomial camera model
This allows real world cameras to be modeled by specifying the coordinates of a
4th degree polynomial that relates a pixels distance (in mm) from the optical
center on the sensor to the angle (in radians) of the world ray that is
projected onto that pixel.

This is available as part of the panoramic lens type, however it can also be
used to model lens distortions in projective cameras for example.

Differential Revision: https://developer.blender.org/D12691
2021-12-07 20:05:57 +01:00
205254150a Build: don't look for CUDA toolkit if not using Cycles CUDA device 2021-12-07 19:52:54 +01:00
763cd2e0be Cleanup: fix compiler warning 2021-12-07 19:52:54 +01:00
5bd41b2e25 Shader Nodes: Create a new bf_nodes_shader library
Re commits rBf72cc47d8edf849af98e196f721022bacf86a5e7 but without the unity build
2021-12-07 13:20:22 -05:00
63bd356faf Cleanup: Missing include
This included is needed for the `ATTR_NONNULL` macro used in the header.
As found in a recent c --> c++ if the includes get ordered in a different order
this could result in an error.

Re commits rBc20098e6ec6adee874a12e510aa4a56d89f92838
2021-12-07 13:20:22 -05:00
b9641cfc37 Cleanup: clang-tidy: modernize-redundant-void-arg
Re commits part of rB0578921063fbb081239439062215f2538a31af4b
2021-12-07 13:20:22 -05:00
7fbb767259 Docs: Add more comments to geometry set header
This adds a bit more information to `GeometrySet` and each of the
geometry components. There is probably still more that can be written,
but this includes the most important information that I could think of.

I'd like to include some more general information about the
attribute API in a separate patch.

Differential Revision: https://developer.blender.org/D13501
2021-12-07 13:04:32 -05:00
Sergey Sharybin
5e37f70307 Fix T93350: Cycles renders shows black during rendering huge resolutions
The root of the issue is caused by Cycles ignoring OpenGL limitation on
the maximum resolution of textures: Cycles was allocating texture of the
final render resolution. It was exceeding limitation on certain GPUs and
driver.

The idea is simple: use multiple textures for the display, each of which
will fit into OpenGL limitations.

There is some code which allows the display driver to know when to start
the new tile. Also added some code to allow force graphics interop to be
re-created. The latter one ended up not used in the final version of the
patch, but it might be helpful for other drivers implementation.

The tile size is limited to 8K now as it is the safest size for textures
on many GPUs and OpenGL drivers.

Differential Revision: https://developer.blender.org/D13385
2021-12-07 19:01:42 +01:00
Mikhail Matrosov
a92805bf24 Fix T93418: Cycles shadow terminator Geometry Offset artifacts with translucency
Differential Revision: https://developer.blender.org/D13468
2021-12-07 19:01:39 +01:00
484714992c Build: remove Cycles CUDA/HIP/OPTIX build options on macOS
So those device types are not listed in the preferences. Metal will be
added instead as the only option.
2021-12-07 19:01:39 +01:00
13af88b23f Build: clean up handling of some Cycles build options
* Don't link embree / OSL when WITH_CYCLES is disabled
* Simplify lite config by disabling Cycles as a whole using this
* Remove code handling the removed WITH_CYCLES_NETWORK option
2021-12-07 19:01:39 +01:00
e14f8c2dd7 Cycles: Reintroduce device-only memory handling that got lost in Cycles X merge
Somehow only a part of rBf4f8b6dde32b0438e0b97a6d8ebeb89802987127 ended up in
Cycles X, causing the issue that commit fixed, "OPTIX_ERROR_INVALID_VALUE" when the
system is out of memory, to show up again.
This adds the missing changes to fix that problem.

Maniphest Tasks: T93620

Differential Revision: https://developer.blender.org/D13488
2021-12-07 18:50:10 +01:00
a37dac0a88 Cycles: add Metal device type to device_type_for_description
Add a `DEVICE_METAL` case to the enum-value-to-string mapping function.
2021-12-07 17:47:35 +01:00
fee4b58627 Cycles: fix build on non-Apple systems
Skip compiling `metal.mm` unless `WITH_CYCLES_DEVICE_METAL` is enabled.
2021-12-07 17:46:52 +01:00
c4cee2e221 Geometry Nodes: Edge Neighbors Node
Creates a new Edge Neighbors node which outputs a field
containing the number of faces connected to each edge.

Differential Revision: https://developer.blender.org/D13493
2021-12-07 10:07:24 -06:00
9558fa5196 Cycles: Metal host-side code
This patch adds the Metal host-side code:

- Add all core host-side Metal backend files (device_impl, queue, etc)
- Add MetalRT BVH setup files
- Integrate with Cycles device enumeration code
- Revive `path_source_replace_includes` in util/path (required for MSL compilation)

This patch also includes a couple of small kernel-side fixes:

- Add an implementation of `lgammaf` for Metal [Nemes, Gergő (2010), "New asymptotic expansion for the Gamma function", Archiv der Mathematik](https://users.renyi.hu/~gergonemes/)
- include "work_stealing.h" inside the Metal context class because it accesses state now

Ref T92212

Reviewed By: brecht

Maniphest Tasks: T92212

Differential Revision: https://developer.blender.org/D13423
2021-12-07 15:52:21 +00:00
565b33c0ad Geometry Nodes: new Geometry to Instance node
This adds a new Geometry to Instance node that turns every
connected input geometry into an instance. Those instances
can for example be used in the Instance on Points node.

Differential Revision: https://developer.blender.org/D13500
2021-12-07 15:37:12 +01:00
a8e0fe6a54 Geometry Nodes: move type conversions to blenkernel
The type conversions do not depend on other files in the nodes
module. Furthermore we want to use the conversions in the
geometry module without creating a dependency to the
nodes module there.
2021-12-07 15:22:08 +01:00
2309fa20af Cleanup: Add macro and functions for node storage
The `node_storage` functions to retrieve const and mutable structs
from a node are generated by a short macro that can be placed at the
top of each relevant file. I use this in D8286 to make code snippets
in the socket declarations much shorter, but I thought it would be
good to use it consistently everywhere else too.

The functions are also useful to avoid copy and paste errors,
like the one corrected in the cylinder node in this commit.

Differential Revision: https://developer.blender.org/D13491
2021-12-07 09:09:30 -05:00
Yuchen Wen
6a9775ec6f Fix T93467: Use world bg color for pose library previews
Use the World viewport color when rendering pose library previews.

The World's viewport color is chosen instead of the World shading nodes,
as the latter would require rendering with `OB_RENDER` (instead of
`OB_SOLID`), which would take considerably longer.

Manifest Task: T93467

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D13470
2021-12-07 14:25:00 +01:00
0f48b37aae Revert moving all shader nodes to c++
This reverts to following commits:
* rB5cad004d716da02f511bd34983ac7da820308676
* rB97e3a2d935ba9b21b127eda7ca104d4bcf4e48bd
* rBf60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c
* rB0bd3cad04edf4bf9b9d3b1353f955534aa5e6740
* rBf72cc47d8edf849af98e196f721022bacf86a5e7
* rB3f7014ecc9d523997062eadd62888af5fc70a2b6
* rB0578921063fbb081239439062215f2538a31af4b
* rBc20098e6ec6adee874a12e510aa4a56d89f92838
* rBd5efda72f501ad95679d7ac554086a1fb18c1ac0

The original move to c++ that the other commits depended upon had some issues
that should be fixed before committing it again. The issues were reported in
T93797, T93809 and T93798.

We should also find a better rule for not using c-style casts going forward,
although that wouldn't have been reason enough to revert the commits.
Introducing something like a `MEM_new<T>` and `MEM_delete<T>`
function might help with the the most common case of casting the return
type of `MEM_malloc`.

Going forward, I recommend first committing the changes that don't
require converting files to c++. Then convert the shading node files
in smaller chunks. Especially don't mix fairly low risk changes like
moving some simple nodes, with higher risk changes.
2021-12-07 13:26:39 +01:00
ae5a89e80a Fix T93797, T93809: Crash/undefined-behavior when opening demo file
Error in d5efda72f5. Was changing an iteration that would free items
to an iterator that is not safe for use in such cases.

There still seem to be significant issues with the rendering, but that's
a separate issue to be fixed.
2021-12-07 12:03:10 +01:00
4312cb8545 Fix memory leak when loading large asset libraries 2021-12-07 11:47:06 +01:00
cd494087c1 Fix crash when switching back from render preview.
Issue is that external engine uses the gpu info. but overwrote the
instance data. The draw manager would then detect instance data and
required the engine type to have a instance free callback.

The solution is to save some space in the engine data to hold an empty
and unused instance_data attribute to comply with `ViewportEngineData`
struct.
2021-12-07 11:30:50 +01:00
Jeroen Bakker
b069218a55 DrawManager: Engine Instance Data.
In the original design draw engines had to copy with a limitation that
they were not allowed to reuse complex data structures between drawing
calls. Data that could be reused were limited to:
- GPUFramebuffers
- GPUTextures
- Memory that could be removed calling MEM_freeN (storage list)
- DRWPass

This is fine when the storage list contains arrays or structs but when
more complex data types (vectors, maps) etc wasn't possible.

This patch adds instance_data that can be reused between drawing calls.
The instance_data is controlled by the draw engine and doesn't need to
be limited as described above.

When an engines stores instance_data it must implement the
`DrawEngineType.instance_free` callback to free the data.

The patch originates from eevee rewrite. But was added to master as the
image engine rewrite also has a need for it.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D13425
2021-12-07 10:34:38 +01:00
Jeroen Bakker
e2f0b4a0cb Cleanup: Use rcti marking dirty regions when texture painting.
Dirty regions when painting are not using rcti. Meaning less
understandable code. Found issue when refactoring the image_gpu partial
update. In a future change gpu partial update API will be using rcti
also what makes the code even cleaner.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D13260
2021-12-07 10:33:23 +01:00
1de3636624 Cleanup: note that functions in BKE_node.h aren't part of blenkernel 2021-12-07 18:55:57 +11:00
512a560cde Cleanup: remove BKE_ptcache_remove
No longer needed as the temporary directory is cleared on exit.
2021-12-07 18:47:01 +11:00
a55d318d71 Cleanup: sort DNA renaming
Add note at the beginning & end so it's not overlooked.
2021-12-07 18:44:28 +11:00
c6a200c693 Cleanup: clang-format 2021-12-07 18:39:16 +11:00
1e7ef83e46 Cleanup: clarify source/destination args for BKE_spacedata_copylist 2021-12-07 18:26:35 +11:00
a37a6fb445 Cleanup: remove incorrect/unhelpful comments 2021-12-07 18:23:57 +11:00
6483dee141 Cleanup: replace int with bool type 2021-12-07 18:15:15 +11:00
ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- 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.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +11:00
luzpaz
f159d49f56 Cleanup: Fix various source typos
This is a continuation of D13462 to clean up source typos.

Differential Revision: https://developer.blender.org/D13471
2021-12-06 22:39:52 -05:00
luzpaz
92dae5775f Cleanup: Fix typos in source code
Source typos corrected

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D13462
2021-12-06 22:23:17 -05:00
50fb0fd636 Docs: Incorrect link to context type
Fixes T93773
2021-12-06 22:07:38 -05:00
5cad004d71 Cleanup: clang format 2021-12-06 18:52:08 -05:00
97e3a2d935 Shader Nodes: Migrate shader category to new node socket declaration API
No functional changes, tests passed and I double checked the nodes by hand.
2021-12-06 18:52:08 -05:00
Christoph Lendenfeld
b1696702cd Fix: Remove line from common invoke
The line that sets the factor_prop in graph_slider_ops.c
has been left in the common invoke function by accident.

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D13477
Ref: D13477
2021-12-06 22:27:04 +00:00
Christoph Lendenfeld
ae6f3056fc Cleanup: renames in graph_slider_ops
rename percentage_prop to factor_prop
rename remove_ratio to factor
remove "graphkeys" prefix from functions

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D13476
Ref: D13476
2021-12-06 22:19:00 +00:00
78ae587649 Cleanup: Use C++ types for multi input socket sorting
The algorithm used is still quite inefficient, but at least the code
is easier to read and a little bit simpler now.
2021-12-06 17:12:46 -05:00
aa23e870ec Cleanup: Remove unused includes 2021-12-06 16:50:44 -05:00
01779970c2 Cleanup: Remove unused node flag 2021-12-06 16:35:38 -05:00
b91ac86cfc Cleanup: Remove unnecessary generic includes from headers 2021-12-06 16:04:14 -05:00
5705db5bb3 Fix: Compile error in field input
Instead of essentially hashing a bool, just use a ternary operator.

Differential Revision: https://developer.blender.org/D13494
2021-12-06 15:47:09 -05:00
0ed254574f macOS: Fix build error in hash functions
Remove unneeded recent static_cast attempt.

Reviewed By: HooglyBoogly
Differential Revision: https://developer.blender.org/D13492
2021-12-07 01:38:14 +05:30
Aaron Carlisle
f60b95b532 Shader Nodes: Split each node into own file
This improves both code finding,  for example "color ramp" now has its own file.
And now each node has its own namespace so function names can be simplified
similar to rBfab39440e94

This commit also makes all file names use snake case instead of camel case.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13482
2021-12-06 14:47:49 -05:00
c3c69fee09 Cleanup: Fix warnings about copied Map loop variables
The `Map::items()` iterator does not return references.
2021-12-06 13:49:37 -05:00
86d520f268 Fix: Attempt to fix build error on macOS 2021-12-06 13:47:53 -05:00
Aaron Carlisle
9792994311 Nodes: Add function to set compact socket flag for vectors
This flag is currently only used for vector sockets
so the function is limited to the vector builder.

The flag is only used by two shader nodes at the moment
and this is needed to port them over to the new socket declaration API.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13490
2021-12-06 13:40:02 -05:00
2d4c7fa896 Geometry Nodes: reduce code duplication with new GeometyrFieldInput
Most of our field inputs are currently specific to geometry. This patch introduces
a new `GeometryFieldInput` that reduces the overhead of adding new geometry
field input.

Differential Revision: https://developer.blender.org/D13489
2021-12-06 19:13:24 +01:00
2814740f5b Geometry Nodes: 4 Field Inputs for Mesh Topology Data
Creates 4 new nodes which provide topology information
for the mesh. Values are interpolated from the primary
domain in each case using basic attribute interpolation.

Vertex Neighbors
  - Vertex Count
  - Face Count
Face Neighbors
  - Vertex Count
  - Neighboring Face Count
Edge Vertices
  - Vertex Index 1
  - Vertex Index 2
  - Position 1
  - Position 2
Face Area
  - Face Area

Differential Revision: https://developer.blender.org/D13343
2021-12-06 11:58:08 -06:00
ee4ed99866 Fix T93521: Single point NURBS crash in resample node
The resample node didn't handle the case of when a spline didn't have
any evaluated points. For poly and Bezier splines we should never hit
this case, but it is expected when the number of NURBS control points
is smaller than its order, so we have to handle the case here.

It's not that obvious what to do in this case, there are a few options:
 - Remove the bad splines from the result
 - Generate empty splines for those inputs
 - Skip resampling the bad splines, copy them to the result
 - Arbitrarily generate single point splines

I chose option three, just skipping the "bad" splines. Since the node
already has a selection input, this can be described by just extending
that. "Splines with no evaluated points are implicitly deselected."
The first option would probably be valid too though.

Differential Revision: https://developer.blender.org/D13434
2021-12-06 12:19:27 -05:00
Aaron Carlisle
0bd3cad04e Nodes: Add Shader Socket to new decleration API
This commit adds the shader socket type to the new socket builder api.

As a test, this commit also converts the Add Shader node to the new API

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13485
2021-12-06 11:59:52 -05:00
Aaron Carlisle
f72cc47d8e Shader Nodes: Unity Build
- Create a new `bf_nodes_shader` library
- Enable unity builds for  `bf_nodes_shader`, gives abount a 2.7x speed up for compile times

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D13484
2021-12-06 11:47:45 -05:00
0c703b856b Disable asset indexing in the Asset List
Asset indexing should be disabled, but this was overlooked in the
asset list (used for the pose library in the 3D View).
2021-12-06 17:42:16 +01:00
86992a96b8 Asset Indexer: use fixed-length string for ID code
Use fixed-length string to convert `char[2]` to `std::string`. Otherwise
`strlen()` is called, which is problematic as the `char[2]` is not
zero-terminated.
2021-12-06 17:42:16 +01:00
c2292b2cd6 Cleanup: remove unnecessary extern template implementations
This technique isn't really necessary anymore, because unity builds
avoid instantiating the same template too many times already.
2021-12-06 17:31:42 +01:00
7d1a10a9bb Fix T93314: Thumbnails not drawn with default scale
Decrease threshold for drawing thumbnails.

This was unintended change in daaa43232d that was overlooked.
2021-12-06 17:01:51 +01:00
a5e3899853 VSE: Fix strip with mask modifier not blending
Set `ibuf->planes` to `R_IMF_PLANES_RGBA` because mask modifier adds
transparent areas to image.
2021-12-06 17:01:51 +01:00
Aurelien Jarno
477631d9ec cmake: fix linking with WITH_X11_XF86VMODE and bfd
Fix typos in the variables of the Xxf86vm libray to fix link failure
with bfd. These variables are defined in platform_unix.cmake.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D12911
2021-12-06 16:46:23 +01:00
b9c6ef4e8f Fix T93707: Dragging the tweaked NLA strip causes crash
Earlier code assumed that the active strip was on the active track. This
commit detects when this assumption doesn't hold, and adds a more thorough
search of the active strip.
2021-12-06 15:50:21 +01:00
0e52af097f Fix T93611: Curve modifier crash in editmode in certain situations
Caused by {rB3b6ee8cee708}

Above commit was trying to get the vertexgroup from the mesh that is
passed into `deformVertsEM` (but that can be NULL).
When can it be NULL, when is is non-NULL?
`editbmesh_calc_modifiers` only passes in a non-NULL mesh to
`deformVertsEM` under certain conditions:
- a non-deform-only modifier is handled currently
- a non-deform-only modifier preceeds the current modifier
- a deform-only modifier preceeds the current modifier (and the current
one depends on normals)

So the passed-in mesh cannot be relied on, now get the vertex group from
the context object data (like it was before the culprit commit).

Related commit: rB8f22feefbc20

Maniphest Tasks: T93611

Differential Revision: https://developer.blender.org/D13487
2021-12-06 15:20:30 +01:00
989d510e3e Cleanup: remove some temp dev asserts in new link/append code.
No longer needed now that all code uses that new
BKE_blendfile_link_append module, and that instantiation code in
BLO_readfile has been removed.
2021-12-06 11:29:27 +01:00
9a69c456bd Fix T93388: dropping object on grid in orthogonal view misses the floor plane
`ED_view3d_win_to_3d_on_plane` does not use the `clip_start` and
`clip_end` values of the scene, so the `do_clip` option can be misleading
especially in the orthographic view where the `clip_start` is negative.

For now, don't use the `do_clip` option in orthographic view.
2021-12-05 23:40:43 -03:00
3d8dea9ff9 Fix T93732: Snap Cursor not working after changing Add Object settings
`g_data_intern.state_default.gzgrp_type` is a very specific member and
cannot be set to default.
2021-12-05 23:40:43 -03:00
Aaron Carlisle
3f7014ecc9 Shader Nodes: Declare nodes in their own namespace
Follow up on rB1df8abff257030ba79bc23dc321f35494f4d91c5

This puts all static functions in geometry node files into a new
namespace. This allows using unity build which can improve
compile times significantly

- The namespace name is derived from the file name.
  That makes it possible to write some tooling that checks the names later on.
  The filename extension (cc) is added to the namespace name as well.
  This also possibly simplifies tooling but also makes it more obvious that this namespace is specific to a file.
- In the register function of every node, I added a namespace alias namespace `file_ns = blender::nodes::node_shader_*_cc`;.
  This avoids some duplication of the file name and may also simplify tooling, because this line is easy to detect.
  The name `file_ns` stands for "file namespace" and also indicates that this namespace corresponds to the current file.

In the future some nodes will be split up to separate files and given their own namespace
This will allow function names to be simplified similar to rBfab39440e94

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13480
2021-12-05 17:47:33 -05:00
0a8a22fc04 Cleanup: Remove unused next and prev pointers in bNodeType 2021-12-05 17:15:21 -05:00
9a312ba192 Cleanup: Remove unnecesary node type draw callback
As a followup to 338c1060d5, apply the same change to the node
drawing callback. This helps to simplify code when the complexity
of a callback isn't necessary right now.
2021-12-05 17:12:25 -05:00
338c1060d5 Cleanup: Remove unnecessary node type callbacks for drawing
Currently there are a few callbacks on `bNodeType` that do the same
thing for every node type except reroutes and frame nodes. Having a
callback for basic things complicates code and makes it harder to
understand, and reroutes and frames are special cases in larger way.

Arguably frame nodes shouldn't even be drawn like regular nodes,
given that it adds a case of O(N^2) looping through all nodes.
"Unrolling" the callbacks makes it easier to see what's happening,
and therefore easier to optimize.

Differential Revision: https://developer.blender.org/D13463
2021-12-05 16:45:41 -05:00
0578921063 Cleanup: clang-tidy: modernize-redundant-void-arg
This change follows up on recent c --> c++ conversions
2021-12-05 16:38:00 -05:00
c20098e6ec Cleanup: Add missing include
Fixes compilation errors after rBd5efda72f501
Re sorted some includes.
2021-12-05 13:33:15 -05:00
Aaron Carlisle
d5efda72f5 Cleanup: Migrate all shader nodes to c++
This will be useful in the future to use the new socket builder API

Aditional changes:

- Declare variables where initialized
- Do not use relative includes

Differential Revision: https://developer.blender.org/D13465
2021-12-05 12:12:45 -05:00
b32f9bf801 Geometry Nodes: use array instead of map in GeometrySet
`GeometrySet` contains at most one component of each type.
Previously, a map was used to make sure that each component
type only exists once. The overhead of a map (especially with
inline storage) is rather large though. Since all component types
are known at compile time and the number of types is low,
a simple `std::array` works as well.

Some benefits of using `std::array` here:
* Looking up the component of a specific type is a bit faster.
* The size of `GeometrySet` becomes much smaller from 192 to 40 bytes.
* Debugging a `GeometrySet` in many tools becomes simpler because
  one can  easily see which components exists and which don't
2021-12-05 15:10:11 +01:00
d19443074a Fix (unreported): off-by-one error when setting curve handles
The problem is that `current_mask` can become `selection.size()`.
The loop could also be refactored to break out of it when the end
of the selection is reached. This can be done separately.
2021-12-05 14:49:30 +01:00
Aaron Carlisle
5ef5a9fc24 Compositor: Migrate most nodes to new socket builder API
This patch leaves a out a few nodes:

- Group Nodes
- Image input node
- File output node
- Switch View
- Cryptomatte

These nodes above are a bit more complicated and should be worked on individually.

Differential Revision: https://developer.blender.org/D13266
2021-12-03 20:26:38 -05:00
Christoph Lendenfeld
d5920744f4 Create generic modal functions from GRAPH_OT_decimate
This patch extracts the modal functions from GRAPH_OT_decimate
and makes them generic so they can be reused by future operators

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D9326
Ref: D9326
2021-12-03 22:24:41 +00:00
56ed4c14d3 Cleanup: Use LISTBASE_FOREACH macro 2021-12-03 16:33:14 -05:00
2d8606b360 Cleanup: Use references in node editor, other improvements
This helps to tell when a pointer is expected to be null, and avoid
overly verbose code when dereferencing. This commit also includes
a few other cleanups in this area:
 - Use const in a few places
 - Use `float2` instead of `float[2]`
 - Remove some unnecessary includes and old code
The change can be continued further in the future.
2021-12-03 16:25:17 -05:00
ca0dbf8c26 Cleanup: Remove unused code
This is very old and is unlikely to be useful in the near future.
2021-12-03 12:31:00 -05:00
d1f118d228 Cleanup: Const, use references, C++ types
Also remove some unnecessary includes
2021-12-03 11:43:10 -05:00
be3f3812dc Cleanup: Comments and ordering in node editor header 2021-12-03 11:31:25 -05:00
cb0fbe1fde Cleanup: Use typed enum for node resize direction 2021-12-03 11:05:59 -05:00
ab927f5ca7 ImBuf: Made Wrapping and Cropping optional in IMB_transform.
`IMB_transform` is used in VSE. It had a required crop parameter
for cropping the source buffer. This is not always needed.

In the image engine we want to use the use the `IMB_transform`
with wrap repeat. Both options are mutual exclusive and due
to performance reasons the wrap repeat is only available when
performing a nearest interpolation.
2021-12-03 13:48:00 +01:00
c4e041da23 Cleanup: move public doc-strings into headers for 'bmesh'
Some minor improvements to doc-strings too.

Ref T92709
2021-12-03 20:10:57 +11:00
Jesse Yurkovich
7c4fc5b58d Fix T93541: Use warning instead of error for exceeding layer limits
Instead of using RPT_ERROR, use RPT_WARNING which will not raise an
exception to Python. This broke some scripts (including FBX import)
which already check for a None return value.

Ref D13458

Reviewed By: campbellbarton
2021-12-03 17:05:18 +11:00
de5d36560f Fix T93574: Asset triangulating a mesh
Correct assert for edit-mesh normal calculation.
2021-12-03 16:55:34 +11:00
56ff954030 UI: Expand tree-view items (e.g. asset catalogs) on click to activate
This actually gives a quite nice behavior in my opinion, especially for
asset catalogs, where activating a catalog makes all assets inside it or
its (grand-)child catalogs visible, so showing the child catalogs then
adds useful information. Maybe this should become a feature for
asset catalogs only, to be evaluated once the tree-view API is used in
more cases. Only asset catalogs are affected by this change right now.

Part of T93582.
2021-12-02 19:49:48 +01:00
c0122cc888 Asset Browser: Don't expand top-level catalogs by default
The "All" item will be expanded of course, and the tree will also be
expanded so that the active item is visible. But feedback was that in
some setups, opening all the top-level catalogs is a bit too much. So
collapse them for a more compact default layout.

Part of T93582.
2021-12-02 19:49:48 +01:00
a159f67ccc Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-12-02 19:37:01 +01:00
f1cca30557 Blender 3.0 - version bump -> release 2021-12-02 19:35:47 +01:00
0988711575 Licenses: Attribution document for Blender 3.0
A few libraries were updated, a few were added, and a few were missing
from the previous license document.
2021-12-02 19:35:01 +01:00
fca6a9fe3f Asset Browser: Remove home icon for "All" item
Originally this wasn't really meant to stay there permanently, but
helped giving things a nicer alignment. Others seemed to like it at
first so it stayed, but after more feedback we decided to remove it
again. The alingment is better now with the previous commit.

Part of T93582.
2021-12-02 19:14:50 +01:00
e38532773b Asset Browser: Nest all catalogs under the "All" item
This makes the relation to the catalogs and the behavior more clear.

Part of T93582.
2021-12-02 19:14:50 +01:00
cef8f5ff50 Docs: add README for HIPEW library 2021-12-02 18:43:42 +01:00
1e98a0cee5 NanoSVG: Mention the version we use 2021-12-02 18:22:05 +01:00
431255e5e8 Docs: 3.0 release description for Linux appdata
Includes a typo fix for 2.93.
2021-12-02 18:02:19 +01:00
27b70428c1 Cleanup: Avoid using C++ keyword as variable name 2021-12-02 11:20:22 -05:00
e6a732daad Merge branch 'blender-v3.0-release' 2021-12-02 16:43:25 +01:00
7e60d8a713 Fix missing Blender logo in Windows store package
D9681 was not properly merged to all branches, leaving a path to a non-existent
icon file in the maniphest.
2021-12-02 16:35:24 +01:00
2fd657db5b Fix T93560: crash with image paint undo and cycles preview render
Cycles preview rendering could free the image buffers being used by drawing in
another thread due to a race condition. This race condition was unlikely before,
but now that preview renders are started right before we draw the image in the
image editor or load it as a texture in the 3D viewport, it's likely to happen.

As we are close to release this is too risky to fix properly, just avoid freeing
the cache for preview renders instead and accept increased memory usage in some
cases.
2021-12-02 16:34:16 +01:00
aec56e562a Fix (unreported): incorrect custom data layer created
Without this fix `CustomDataAttributes::create_by_move`
did not work on named attributes.
2021-12-02 15:32:19 +01:00
a1f0f2eacb Cleanup: Move public docs to BKE_spline.hh header 2021-12-02 09:24:21 -05:00
23ffcb242d Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-12-02 14:40:20 +01:00
61e92eeb3e Fix Action.asset_data["is_single_frame"] set incorrectly
The asset metadata custom property `["is_single_frame"]` was set
incorrectly. Since this is intended for forward compatibility, including
being covered by the asset metadata indexing, it's important to have it
set correctly from the first release of Blender that includes the asset
browser.

Differential Revision: https://developer.blender.org/D13452
2021-12-02 14:35:12 +01:00
1620dcd208 Fix: don't use BLI_strncpy_utf8 for copying file paths
File paths can be any encoding, so using some UTF-8-specific function is
not the right way to go.
2021-12-02 13:02:39 +01:00
c5ec3738d8 Blenloader: move ghost include path from INC to TEST_INC
The Ghost dependency was added to avoid a memory leak (rBc7a1e115b507),
but since that's only for the unit tests, it's better to add the path to
`TEST_INC`.
2021-12-02 12:58:45 +01:00
e130903060 BLI: avoid invoking tbb for small workloads
We often call `parallel_for` in places with very variable
sized workloads. When many elements are processed,
using multi-threading is great, but when processing
few elements (possibly many times) using `parallel_for`
can result in significant overhead.

I measured that this improves performance by >20% in
the refactored realize instances code I'm working on
separately. The change might also help with debugging
sometimes, because the stack trace is smaller and contains
fewer irrevelant symbols.
2021-12-02 12:56:47 +01:00
0f89d05848 Fix T93563: Crash subdividing with overlapping tri and quad
The first loop was left out when finding the split edge boundary.

Error from f2138686d9.
2021-12-02 22:53:44 +11:00
42a6b2fd06 Cleanup: move public doc-strings into headers for 'python' 2021-12-02 22:53:44 +11:00
1766549418 Fix T92308: OptiX denoising fails with high resolutions
The OptiX denoiser does have an upper limit as to how many pixels it can denoise at once, so
this changes the OptiX denoising process to use tiles for high resolution images.
The OptiX SDK does have an utility function for this purpose, so changes are minor, adjusting
the configured tile size and including enough overlap.

Maniphest Tasks: T92308

Differential Revision: https://developer.blender.org/D13436
2021-12-02 12:10:46 +01:00
7da979c070 Merge branch 'blender-v3.0-release' 2021-12-02 11:19:00 +01:00
67c490daaf Fix T93548: Appended (material) assets don't have a fake user
Since our design is to always keep data-blocks marked as assets on exit,
and our technical design for this is to do this via fake users, ensure
the fake user is set for an appended asset.

Reviewed by: Bastien Montagne

Differential Revision: https://developer.blender.org/D13443
2021-12-02 11:18:27 +01:00
68e3755209 Fix T93555: crash when muting nodes with multiple internal links
The crash happened because I was incorrectly and inconsistently assuming
that a socket is part of at most one internal link. However, this is not the case.
In geometry nodes, an input socket can be internally linked to multiple
output sockets. In the general case, an output could also be linked to multiple
input sockets, even though we don't have that in Blender yet.

Dalai gave green light to cherry pick this fix for 3.0.
2021-12-02 11:10:41 +01:00
9f290467ca Blendread: Remove all instantiation logic from BLO_library_link_ code.
Instantiation is now fully handled by BKE_blendfile_link_append module.

Note that this also allows removal of the `BLO_LIBLINK_NEEDS_ID_TAG_DOIT`
flag.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-12-02 11:10:34 +01:00
4fe8c62b56 Cleanup: Readfile: Remove deprecated BLO_library_link_copypaste.
Rewrite of ID paste code in rB3f08488244c0 made this function useless,
ID pasting is now handled by the BKE_blendfile_link_append module too.
2021-12-02 10:27:34 +01:00
198e571e87 Fix T93555: crash when muting nodes with multiple internal links
The crash happened because I was incorrectly and inconsistently assuming
that a socket is part of at most one internal link. However, this is not the case.
In geometry nodes, an input socket can be internally linked to multiple
output sockets. In the general case, an output could also be linked to multiple
input sockets, even though we don't have that in Blender yet.
2021-12-02 09:41:36 +01:00
f1b0b0ffb8 Cleanup: spelling in comments 2021-12-02 16:02:34 +11:00
8f69c91408 Fix T93410: Crash hiding a region from Python used by a popover
Close all active buttons when hiding a region as this can be called
from Python a popover is open from that region.

Failure to do this causes the popover to read from the freed button.

Also rename UI_screen_free_active_but to
UI_screen_free_active_but_highlight since it only frees highlighted
buttons.
2021-12-02 15:53:41 +11:00
0de1d2e84e Cleanup: FIx build with USD after recent refactor
rB218360a89217f4e8321319035bf4d9ff97fb2658 missed a couple renames in USD code paths.
2021-12-01 23:34:51 -05:00
Leon Leno
bb3d03973a UI: Fix scaling of HSV cursor when zooming
The small circle used to choose the hue/saturation and value in the
color widget was drawn with a fixed screen space size. Now scale the
circle used as cursor in the color widget based on the zoom. This
could have been part of a9642f8d61 but the implementation is
different.

Based on a fix provided by Erik Abrahamsson

Differential Revision: https://developer.blender.org/D13444
2021-12-01 22:22:53 -05:00
Nikhil Shringarpurey
26d2caee3b Fix T92268: Group input and output nodes have inconsistent padding
The group output node did not have the same size padding as the group
input, leading to the node looking different and actually being smaller.

Differential Revision: https://developer.blender.org/D13092
2021-12-01 22:04:44 -05:00
218360a892 Cleanup: Rename curve struct fields
These existing names were unhelpful at best, actively confusing at
worst. This patch renames them to be consistent with the terms
used to refer to the values in the UI.
 - `width` -> `offset`
 - `ext1` -> `extrude`
 - `ext2` -> `bevel_radius`

Differential Revision: https://developer.blender.org/D9627
2021-12-01 22:01:35 -05:00
ca9cdba2df Fix: Add tooltip translation marker to disabled hints
This was overlooked, as it seems there's no way for these strings to be
translated currently. Generally it's not that clear whether `N_` or
`TIP_` should be used in this case, but `TIP_` seems more consistent.
To avoid the cost of the translation lookup when the UI text isn't
necessary, we could allow the disabled hint argument to be optional.

Differential Revision: https://developer.blender.org/D13141
2021-12-01 21:55:04 -05:00
b869da0c10 Fix T84710: Instances with only mesh edges or vertices are invisible
Wire-only meshes have a special case in the overlay drawing to give
the wire shader a special color (which avoids the lines being dashed,
somehow). The fast path for duplis didn't have that special case.

Differential Revision: https://developer.blender.org/D13196
2021-12-01 21:47:57 -05:00
70a7685d04 UI: Add an option to display the node editor context path
Since we have the overlays popover, it makes sense to allow toggling the
context path like in the 3D viewport. This commit adds a property,
and turns it on by default in existing files.

Differential Revision: https://developer.blender.org/D13248
2021-12-01 21:45:41 -05:00
2b6c01d98c Fix: Updating geometry nodes test results fails
I ran into this when adding new geometry nodes tests.
The issue was caused by 7168a4fa5c.

Differential Revision: https://developer.blender.org/D13440
2021-12-01 21:22:00 -05:00
70a0d45b69 Merge branch 'blender-v3.0-release' 2021-12-01 21:17:48 -05:00
594656e7a3 Fix T93525: Crash with curve/text armature bone gizmo
The problem is that drw_batch_cache_generate_requested_delayed
is called on the object, which uses the original object data type to
choose which data type to get info for. So for curves and text it uses
the incorrect type (not the evaluated mesh like we hardcoded in the
armature overlay code).

To fix this I hardcoded the "delayed" generation to only use the
evaluated mesh. Luckily it wasn't use elsewhere besides this
armature overlay system. That seems like the simplest fix for
3.0. A proper solution should rewrite this whole area anyway.

Differential Revision: https://developer.blender.org/D13439
2021-12-01 21:16:18 -05:00
fed4fc9c42 Cleanup: Move node_shader_util.c to C++
This will allow using a function I've declared in a C++ header.
2021-12-01 15:08:42 -05:00
8ca8380699 Cleanup: compiler warning 2021-12-01 20:52:31 +01:00
Sebastian Herholz
cb334428b0 Cycles: fix bugs in point and spot light multiple importance sampling
* Spot lights are now handled as disks aligned with the direction of the
  spotlight instead of view aligned disks.

* Point light is now handled separately from the spot light, to fix a case
  where multiple lights are intersected in a row. Before the origin of the
  ray was the previously intersected light and not the origin of the initial
  ray traced from the last surface/volume interaction.

This makes both strategies in multiple importance sampling converge to the same
result. It changes the render results in some scenes, for example the junkshop
scene where there are large point lights overlapping scene geometry and each
other.

Differential Revision: https://developer.blender.org/D13233
2021-12-01 20:20:12 +01:00
9afd6e7b70 Cleanup: clarify material copying for hair and pointclouds
No functional change, just more clear this way it comes from src.
2021-12-01 19:48:48 +01:00
Yuki Hashimoto
7336af3259 Fix some shortcut keys not working on macOS with Japanese input
Differential Revision: https://developer.blender.org/D13414
2021-12-01 19:40:47 +01:00
128ebdb062 Fix: Remove incorrect asserts for empty attributes
While it is an edge case, it isn't incorrect for the attribute storage
to have a zero size, it will just return an empty span or nothing.
2021-12-01 12:44:02 -05:00
bc48da3235 Fix: Instances component does not copy attributes 2021-12-01 12:36:49 -05:00
be6e56b36b Cleanup: Fix errors in previous commit
After 1ef8ef4941 there were build warnings because of unused
arguments. Also missed to change code to iterate `strips` instead of
`seqbase` in 2 functions.
2021-12-01 18:13:09 +01:00
506d672524 Geometry Nodes: deduplicate join geometry code
The Realize Instances and Join Geometry node can share most of their code.
Until now, both nodes had their own implementations though. This patch
removes the implementation in the Join Geometry node in favor of the more
general Realize Instances implementation.

This removes an optimization for avoiding spline copies. This can be brought
back later. The realize instances code has to be rewritten to support attribute
instances anyway.

Differential Revision: https://developer.blender.org/D13417
2021-12-01 17:57:08 +01:00
Wannes Malfait
d54a08c8af Geometry Nodes: Dual Mesh Node
This node calculates the dual of the input mesh. This means that faces
get replaced with vertices and vertices with faces. In principle this
only makes sense when the mesh in manifold, but there is an option to
keep the (non-manifold) boundaries of the mesh intact.

Attributes are propagated:
 - Point domain goes to face domain and vice versa
 - Edge domain and Face corner domain gets mapped to itself
Because of the duality, when the mesh is manifold, the attributes get
mapped to themselves when applying the node twice.

Thanks to Leul Mulugeta (@Leul) for help with the
ascii diagrams in the code comments.

Note that this does not work well with some non-manifold geometry,
like an edge connected to more than 2 faces, or a vertex connected to
only two faces, while not being in the boundary. This is because there
is no good way to define the dual at some of those points. This type
of non-manifold vertices are just removed for this reason.

Differential Revision: https://developer.blender.org/D12949
2021-12-01 11:11:50 -05:00
1757840843 Geometry Nodes: Generalized Compare Node
Replace compare floats node with a generalized compare node. The node
allows for the comparison of float, int, string, color, and vector.

The datatypes support the following operators:
Float, Int: <, >, <=, >=, ==, !=
String: ==, !=
Color: ==, !=, lighter, darker
    (using rgb_to_grayscale value as the brightness value)

Vector Supports 5 comparison modes for: ==, !=, <, >, <=, >=
Average: The average of the components of the vectors are compared.
Dot Product: The dot product of the vectors are compared.
Direction: The angle between the vectors is compared to an angle
Element-wise: The individual components of the vectors are compared.
Length: The lengths of the vectors are compared.

Differential Revision: https://developer.blender.org/D13228
2021-12-01 09:36:25 -06:00
f8dd03d3dd Cleanup: Store instances id attribute with other attributes
Now that we can store any dynamic attribute on the instances component,
we don't need the special case for `id`, it can just be handled by the
generic attribute storage. Mostly this just allows removing a bunch
of redundant code.

I had to add a null check for `update_custom_data_pointers` because
the instances component doesn't have any pointers to inside of
custom data.

Differential Revision: https://developer.blender.org/D13430
2021-12-01 09:27:27 -05:00
Paul Golter
fd8418385c Add layer and pass index parameters to rna_Image_gl_load
This patch adds a layer_idx and pass_idx parameter to the rna_Image_gl_load function. It exposes both to the Python API as optional parameters.
This allows python scripters to specifiy which layer and pass they want to load in to an OpenGL texture. Right now image.gl_load() always takes the first layer and first pass.
This is limiting when working with multilayer openEXRs.

With this patch scripters can do something like this:

```
pass_idx = area.spaces.active.image_user.multilayer_pass
layer_idx = area.spaces.active.image_user.multilayer_layer
image.gl_load(frame=0, layer_idx=layer_idx, pass_idx=pass_idx)
```

As the parameters are optional and default to 0, it should not break existing code.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D13435
2021-12-01 14:58:49 +01:00
1ef8ef4941 Cleanup: Remove seq->tmp_flag DNA member
Commit f0d20198b2 used this field to flag rendered strips which were
queried by `SEQ_query_rendered_strips()`. Then operators iterate all
strips and checks state of `seq->tmp_flag`.

Use collection returned by `SEQ_query_rendered_strips` directly.
There should be no functional changes.

This commit adds functions `all_strips_from_context` and
`selected_strips_from_context` that provide collection of strips based
on context. Most operators can use this collection directly.
There is already `seq->tmp` DNA field, but is should not be used unless
absolutely necessary. Better option is to use human readable flag.
Best is to not use DNA fields for temporary storage in runtime.
2021-12-01 12:49:17 +01:00
d5d91b4ae4 Color adjustments for splash for Blender 3.x series
Tweaks by Andy Goralczyk.
2021-12-01 12:46:20 +01:00
02ab4ad991 Fix T92561: unstable particle distribution with Alembic files
When enabling or disabling a Mesh Sequence Cache modifier of an Object
with a hair particle system, the hair would switch positions. This is
caused because original coordinates in Blender are expected to be
normalized, and toggling the modifier would cause the usage of different
orco layers: one that is normalized, and the other which isn't.

This bug exposes a few related issues:
- if the Alembic file did not have orco data,
`MOD_deform_mesh_eval_get`, used by the particle system modifier, would
add an orco layer without normalization
- `MOD_deform_mesh_eval_get` would also ignore the presence of an orco
layer (e.g. one that could have been read from Alembic)
- if the Alembic file did have orco data, the data would be read
unnormalized

To fix those various issues, original coordinates are normalized when
read from Alembic and unnormalized when written to Alembic; and a new
utility function `BKE_mesh_orco_ensure` is added to add a normalized
orco layer if none exists on the mesh already, this function derives
from the code used in the particle system.

Reviewed By: brecht

Maniphest Tasks: T92561

Differential Revision: https://developer.blender.org/D13306
2021-12-01 12:44:32 +01:00
fd22404837 Cleanup: Use int8 type rather than char for buffer
Indicates that this is just a buffer with an element size of 8 bit, not
a displayable/printable string buffer.
2021-12-01 12:19:43 +01:00
51791004ea Fix errors in user preferences after 2.8 hack removal
How to reproduce it:
* Open User Preferences.
* Got to Add-ons tab.

Issue introduced on d723e331f1

Reported via chat by Pedro Alcaide (povmaniac).
2021-12-01 11:38:08 +01:00
9cec9b4d6e Fix(unreported): LineArt intersection mask logic error.
The stroke generation call mistakenly uses all enabled
types to check intersection mask, the correct behavior
is to use individual edge(chain) type.
2021-12-01 15:55:52 +08:00
24b84e4688 LineArt: Use consitent view vector direction.
Now do not invertes view vector in different stages of calculation.
2021-12-01 15:55:16 +08:00
5eeaf4cce6 LineArt: Use consitent view vector direction.
Now do not invertes view vector in different stages of calculation.
2021-12-01 15:53:30 +08:00
386b112f76 Geometry Nodes: Propagate attributes in Instances to Points node
This is part of T92926, and is very similar to 221b7b27fc, except
slightly similar, because it only transfers from one component, and
it doesn't handle multi-threading at the moment.
2021-11-30 23:30:35 -05:00
Aaron Carlisle
d723e331f1 Cleanup: Remove hack to hide pre 2.8 addons in the user preferences
Should be safe to do so now that 2.8+ has been out for 8 releases and over 2 years now.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D12984
2021-11-30 22:55:52 -05:00
1cb99f5808 Merge branch 'blender-v3.0-release' 2021-12-01 11:47:28 +11:00
b3d101ac29 Fix T93100: VSE RMB shift-select fails with "fallback tools"
When the select action was set to "Select Tool", shift-clicking
on sequence strips wasn't selecting the strip.

Regression in 2a2d873124

Thanks to @a.monti for the fix.
2021-12-01 11:43:19 +11:00
88e9e97ee9 Geometry Nodes: Add Point Count to Spline Length Node
- Integer Field input of the number of control points on each spline
  in the spline domain.

  - In the point domain, it is the number of points on the spline that
  contains the given control point.

Differential Revision: https://developer.blender.org/D13279
2021-11-30 15:25:43 -06:00
247f37f765 Fix missing subsurface IOR/Anisotropy socket after refactor in c2ab47e 2021-11-30 22:09:18 +01:00
221b7b27fc Geometry Nodes: propagate attributes in Instance on Points node
This is part of T92926.

Differential Revision: https://developer.blender.org/D13429
2021-11-30 18:37:44 +01:00
88b37b639e LibLink/Append: Some cleanup and addition to comments. 2021-11-30 17:37:00 +01:00
1b4734c57d Geometry Nodes: Curve Menu Organize
Put Spline Parameter in the correct position in the Curve menu.
2021-11-30 10:32:12 -06:00
3f08488244 Rewrite ID Paste code to use new BKE_blendfile_link_append module.
No behavioral changes are expected here.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-30 17:18:35 +01:00
b9f54dd48a LibLink/Append: Add a utils to link/append all ID of given types from a given library.
This will be used by the copy/paste code.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-30 17:18:26 +01:00
581fb2da10 LibLink/Append: tweak instantiation of collections in viewlayers.
When appended collections are instantiated in viewlayers, do not add to
viewlayers collections children of other instantiated collections.

This default behavior is required for proper copy/paste behavior. If
previous behavior needs to be brought back for regular append operation,
this can be decided and done, but think this default behavior also makes
sense in normal append case.

part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-30 17:13:28 +01:00
c822e03e2a Fix: Missing handling of dynamic instance attribute size
The attributes need to be reallocated when the size changes.

Differential Revision: https://developer.blender.org/D13390
2021-11-30 10:59:11 -05:00
2fbb52dd86 Merge branch 'blender-v3.0-release' 2021-11-30 15:41:29 +01:00
3788003cda Fix T93368: Dragging Blends Without Previews
Unfortunately the drop logic for file-path based drag & drop checks the
used icon for its logic. This is very bad and should be changed. But
doing this involves some changes that are better not done during bcon4,
so for now stick to it and update the icon check.

Reviewed by: Julian Eisel

Differential Revision: https://developer.blender.org/D13383?id=45314
2021-11-30 15:40:27 +01:00
74039388cd Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-30 15:36:48 +01:00
7863e03e89 Fix(unreported): LineArt intersection mask logic error.
The stroke generation call mistakenly uses all enabled
types to check intersection mask, the correct behavior
is to use individual edge(chain) type.
2021-11-30 22:24:42 +08:00
Bastien Montagne
de7f1e8e07 Fix T93353: Reload Library Override file loses Constraints, take II.
When adding `INSERT` operations over RNACollection items, rna diffing
code did not properly report the properties as not being equals.

This in turn triggered the 'purge unused exiting override properties'
mechanism, thus deleting the exitsting (valid) insert override property
operation.

NOTE: This should also be backported to 2.93, and probably 2.83.

Reviewed By: sybren, jbakker

Maniphest Tasks: T93353

Differential Revision: https://developer.blender.org/D13426
2021-11-30 15:19:44 +01:00
Germano Cavalcante
251c017534 Fix T93477: Viewport X-Ray is influencing snapping even in material mode
The default snap behavior to perform on tools and cursors is to the
final geometry and not edited geometry.

In snapping to edited geometry, there are some specific behaviors that
are not convenient in some cases. For example the general occlusion
test of X-Ray geometries during dragdrop.

This fix also resolves a regression for tools like measure and placement
that were also ignoring the snap to face in x-ray mode.

Differential Revision: https://developer.blender.org/D13410
2021-11-30 11:03:57 -03:00
0704570721 LibLink/Append: Port bpy.data.libraries.load to new BKE_blendfile_link_append module.
Note that this fully replaces the 'PyCapsule' storage of linked/appended items
in the python API code by the generic storage of items in the
`BlendfileLinkAppendContext` data.

Maniphest Tasks: T91414

Differential Revision: https://developer.blender.org/D13331
2021-11-30 15:02:53 +01:00
8cf0d15b60 Fix T93508: Shift+F1 to switch to asset browser randomly crashes 2021-11-30 14:35:29 +01:00
1cd9fcd98d Geometry Nodes: Rename Curve Parameter, Add Index on Spline
- Rename the Curve Parameter node to Spline Parameter.
  - Add "Index on Spline" to the node. This output is the index of
the current point on it's parent spline rather than the entrire curve.

Differential Revision: https://developer.blender.org/D13275
2021-11-30 07:21:14 -06:00
2f7bec04e8 Asset Browser: Fix incorrect user message
Text would display "No asset selected" when it actually inidicates that
there is no asset active (not selected). Changed it to "No active asset"
now.
2021-11-30 13:01:23 +01:00
3692c0521c Fix Asset Browser properties region toggle not showing open/closed state
The button is supposed to be blue (default theme) when the properties
region is open, to indicate that state.
2021-11-30 12:40:57 +01:00
b67dca9b76 Depsgraph: remove shading parameters component
This component served no purpose anymore. It was technical
dept from the early 2.80 days.

Differential Revision: https://developer.blender.org/D13422
2021-11-30 12:14:23 +01:00
4b971bb87c Asset Bundle Copy button: only report each external dependency once
The `ASSET_OT_bundle_install` operator only works when the blend file is
self-contained. It reports any external dependencies. Before this patch:

- every dependency was mentioned, even when it repeated the same
  filename over and over again, and
- multiple dependencies were all mentioned in the error popup,
  potentially filling the screen.

This is now resolved by:

- only reporting each external file once, and
- referring to the console when there are multiple external dependencies.

Reviewed by: severin, dfelinto

Differential Revision: https://developer.blender.org/D13413
2021-11-30 11:50:38 +01:00
Julian Eisel
2e53f8b4b1 Fix T92577: Cannot open shortcut folders on Windows
`file.select()` wasn't handling redirects as it should when it also
opens directories. This was only uncovered by a change in the keymap.

Reviewed By: Bastien Montagne, Harley Acheson

Differential Revision: https://developer.blender.org/D13388
2021-11-30 11:29:40 +01:00
e1cb2a226c Merge branch 'blender-v3.0-release' 2021-11-30 11:17:04 +01:00
d8edc2c634 VSE: Disable interactivity in combined view
Combined view of timeline and preview causes seemingly unpredictable
behavior after some operators have been allowed to run in preview
region.

Disable new features in this combined view, so behavior should be
consistent with previous versions.

ref: https://developer.blender.org/T92584

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D13419
2021-11-30 11:15:20 +01:00
6f460b76fe LibLink/Append: tweak asserts in main BKE link/append functions.
Now that those functions are much widely used, just return early in case
there is nothing to link/append,  instead of asserting over it.
2021-11-30 11:04:41 +01:00
bc1e3238c4 Merge remote-tracking branch 'origin/blender-v3.0-release'
This includes adjustment of rBc12d8a72cef5 to the new path traversal code
introduced in rBe5e8db73df86.
2021-11-30 10:56:14 +01:00
c12d8a72ce BPath traversing: allow skipping weak library references
Add flag to `BKE_bpath_traverse_id()` and friends to skip weak
references (see below). This makes a distinction between "this blend
file depends on that file" and "this blend file references that file,
but doesn't directly use its data". This distinction is for the Asset
Bundle install operator, which refuses to copy the blend file when it's
not self-contained.

Weak references are those that are not directly used by the blend file,
but are still present to allow path rewriting. For example, when an
Asset is loaded its originating blend file is saved in
`ID::library_weak_reference`; this reference is purely for deduplication
purposes, and not for actually loading any data.

Reviewed by: mont29, brecht

Differential Revision: https://developer.blender.org/D13412
2021-11-30 10:41:23 +01:00
d7f0de0e3a Fix T93442: Crash when proxy building is cancelled
If strip is removed while proxy is built, this causes crash when
building is finished. This happens because proxy anims are freed in
`SEQ_proxy_rebuild_finish()`.

Iterate over available strips and check if original strip still exists
by comparing `SessionUUID`.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13408
2021-11-30 10:08:22 +01:00
Jake
7168a4fa5c Tests: add edit-mesh operator tests
Added operator tests for hide, symmetry_snap, tris_convert_to_quads,
uvs_rotate, uvs_rotate, uv_texture_add, uv_texture_remove,
vert_connect_concave, vert_connect_nonplanar, vertex_color_add,
vertex_color_remove, vertices_smooth_laplacian, wireframe,
sculpt_vertex_color_add and sculpt_vertex_color_remove.

Ref D11798

Reviewed By: campbellbarton
2021-11-30 17:43:24 +11:00
500ec993f5 Revert "Fix: Const warning in editmesh_knife.c"
It's important the coordinates the knife is operating on are never
manipulated since it will cause problems which are difficult to
troubleshoot.

Instead, use a cast in the MEM_freeN(..) call.

This reverts commit 8600d4491f.
2021-11-30 16:30:08 +11:00
Matheus Santos
da279927b1 Text Editor: Line number highlight follow selection
Change the current behavior of line number highlighting to follow the
current selected line text->sell, not the current line text->curl.
2021-11-30 14:32:52 +11:00
ac447ba1a3 Cleanup: clang-format, trailing space 2021-11-30 10:15:17 +11:00
e2473d3baf Cleanup: remove blank lines in comment blocks 2021-11-30 10:15:17 +11:00
76471dbd5e Cleanup: capitalize NOTE tag 2021-11-30 10:15:17 +11:00
4e45265dc6 Cleanup: spelling in comments & strings 2021-11-30 10:15:17 +11:00
262ef26ea3 Cleanup: use colon after doxygen params, correct slash direction 2021-11-30 10:15:17 +11:00
35124acd19 Geometry Nodes: Domain Size Node
The Domain Size node has a single geometry input and a selection for
the component type. Based on the component chosen, outputs containing
single values for the related domains are shown.

Mesh:
  - Point Count
  - Edge Count
  - Face Count
  - Face Corner Count
Curve:
  - Point Count
  - Spline Count
Point Cloud:
  - Point Count
Instances:
  - Instance Count

Differential Revision: https://developer.blender.org/D13365
2021-11-29 13:04:25 -06:00
c2001ec275 Merge branch 'blender-v3.0-release' 2021-11-29 19:25:28 +01:00
e7ae9f493a Fix T93310: crash due to broken image paths
The crash was caused by allocating an uninitialized amount of memory.
This fix initializes a bunch of variables that could cause the error.

It should be possible to also fix this in the function that actually uses
the uninitialized memory, but that could cause unknown consequences
that are a bit too risky for 3.0. Just initializing some variables should
be safe though. For more details see D13369.

Differential Revision: https://developer.blender.org/D13369
2021-11-29 19:23:43 +01:00
4fac3be146 Fix Cycles OptiX doing a bit too much work for almost opaque curve shadows
Found in D13353, likely has no significant impact in performance.
2021-11-29 18:41:37 +01:00
2e6f914e37 Fix debug build error after recent Cycles kernel argument changes 2021-11-29 18:41:37 +01:00
0adb356f2e Merge branch 'blender-v3.0-release' 2021-11-29 17:09:53 +01:00
aa7051c8f2 Fix T93439: Armature widgets from hidden collections are invisible
The are few things in the dependency graph which lead to the issue:
- IDs are only built once.
- Object-data level (Armature, i,e,) builder dependent on the object
  visibility.

This caused issues when an armature is first built as not directly
visible (via driver, i.e.) and then was built as a directly visible.
This did not update visibility flag on the node for the custom shape
object.

The idea behind the fix is to go away form passing object visibility
flag to the geometry-level builders and instead rely on the common
visibility flush post-processing to make sure certain objects are
fully visible when needed.

This is the safest minimal part of the change for 3.0 release which
acts as an additional way to ensure visibility. This means that it
might not be a complete fix (if some configuration was overseen) but
it should not make currently working cases to not work.

The fix should also make modifiers used on rigify widgets to work.

The more complete fix will have `is_object_visible` argument removed
from the geometry-level builder functions.

Differential Revision: https://developer.blender.org/D13404
2021-11-29 16:59:50 +01:00
aff6227412 Merge branch 'blender-v3.0-release' 2021-11-29 16:59:09 +01:00
dae9917915 Fix T93384: Objects with Constraints to curves have wrong locations on file load
Regression since 3.93 caused by 752c6d668b.

Follow the code from 2.93 which was always leaving curve modifiers
evaluation with a valid and clean state of the bounding box.

This is also what was proposed and agreed on in the following
design task: T92206: Bounding Box: compute during depsgraph evaluation

Tested with files from T90808 and T93384.

For the 3.0 going with the safest and minimal change. The rest of
the bounding box un-entanglement is to happen outside of the stable
branch.

Thanks The patch is based on the code from Philipp Oeser and
investigation by Germano Cavalcante and Dr. Sybren A. Stüvel,
thanks!

Differential Revision: https://developer.blender.org/D13409
2021-11-29 16:45:31 +01:00
2206b6b9a0 Fix T92628: .blend thumbnail renders black with Cycles 3D viewport render
Don't use Cycles for rendering thumbnails, fall back to Solid shading.

Differential Revision: https://developer.blender.org/D13406
2021-11-29 16:27:55 +01:00
f613c4c095 Cycles: MetalRT support (kernel side)
This patch adds MetalRT support to Cycles kernel code. It is mostly additive in nature or confined to Metal-specific code, however there are a few areas where this interacts with other code:

- MetalRT closely follows the Optix implementation, and in some cases (notably handling of transforms) it makes sense to extend Optix special-casing to MetalRT. For these generalisations we now have `__KERNEL_GPU_RAYTRACING__` instead of `__KERNEL_OPTIX__`.
- MetalRT doesn't support primitive offsetting (as with `primitiveIndexOffset` in Optix), so we define and populate a new kernel texture, `__object_prim_offset`, containing per-object primitive / curve-segment offsets. This is referenced and applied in MetalRT intersection handlers.
- Two new BVH layout enum values have been added: `BVH_LAYOUT_METAL` and `BVH_LAYOUT_MULTI_METAL_EMBREE` for XPU mode). Some host-side enum case handling has been updated where it is trivial to do so.

Ref T92212

Reviewed By: brecht

Maniphest Tasks: T92212

Differential Revision: https://developer.blender.org/D13353
2021-11-29 15:20:26 +00:00
98a5c924fc Cycles: Metal readiness: Specify DeviceQueue::enqueue arg types
This patch adds new arg-type parameters to `DeviceQueue::enqueue` and its overrides. This is in preparation for the Metal backend which needs this information for correct argument encoding.

Ref T92212

Reviewed By: brecht

Maniphest Tasks: T92212

Differential Revision: https://developer.blender.org/D13357
2021-11-29 14:56:06 +00:00
Pratik Borhade
03c9563582 Fix T93431: Crash when empty is marked as asset
Make `ED_preview_id_is_supported(ID *)` NULL-safe. It's semantically
valid, as it's not possible to render a preview of a NULL ID.

The crash was introduced in 481f032f5c

Reviewed By: sybren, jbakker

Maniphest Tasks: T93431

Differential Revision: https://developer.blender.org/D13398
2021-11-29 15:25:03 +01:00
f9add2d63e Fix: Missing min value for set spline resolution node 2021-11-29 09:11:51 -05:00
Bastien Montagne
e5e8db73df Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.

Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
   topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
  callback that belongs in `lib_id.c` user code.

NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).

NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:22:38 +01:00
6ae34bb071 Fix drawing annotations on surface
Caused by {rBaa0ac0035a0d}.

Similar solution to {rBc0fdaf700a5}.
2021-11-29 09:43:33 -03:00
7c703b4699 Fix T93417: Strip outline not aligned with image
When using non-uniform aspect ratio, strip outline is not aligned
correctly.

Apply pixel aspect ratio to image quad and origin.
2021-11-29 12:44:42 +01:00
f1118ee51e Nodes: Support internal links for custom sockets
Currently, nodes with custom sockets do not get their internal links
populated. So operators like Delete And Reconnect don't work with such
nodes. This patch put custom sockets into consideration when computing
priorities for internal links such that sockets of the same idname get
connected. Additionally, the patch cleanup the function in the process
to avoid redundant code repetition.

Reviewed By: Jacques Lucke

Differential Revision: https://developer.blender.org/D13386
2021-11-29 13:01:53 +02:00
ab2a7aa0da Fix T93438: Auto linking do not work for custom sockets
Currently, custom sockets are no longer supported for automatic linking
when dropping a node on a link. This is because SOCK_CUSTOM is given a
negative priority and is ignored. To fix this, SOCK_CUSTOM is now given
the lowest priority and the rest of the sockets got their priority
incremented.

Reviewed By: Jacques Lucke

Differential Revision: https://developer.blender.org/D13403
2021-11-29 12:34:11 +02:00
cebe5f5bf4 Cleanup: Silenced clang-tidy warning. 2021-11-29 11:26:35 +01:00
0cbcddd91e Merge branch 'blender-v3.0-release' 2021-11-29 02:14:05 -08:00
b31250feba Fix T93456: Properly translate operator on splash screen
Use the translation API to lookup the string before formatting occurs.

Differential Revision: https://developer.blender.org/D13400
2021-11-29 02:04:32 -08:00
444971aa8e Cleanup: typos in comments. 2021-11-28 19:05:22 +01:00
f7f558e293 Cleanup: Deduplicate instances component in spreadsheet
Currently we have a separate `InstancesDataSource`, which does almost
exactly the same thing as `GeometryDataSource`, except that it hardcodes
a few more columns: "Name", "Rotation", and "Scale". We can easily
replace that with a couple of if statements in the geometry data source.

This also makes named attributes on instances display
in the spreadsheet.

Differential Revision: https://developer.blender.org/D13391
2021-11-27 17:09:35 -05:00
e121b5b66c Merge branch 'blender-v3.0-release' 2021-11-27 21:59:57 +01:00
Brecht Van Lommel
d2e6087335 Fix build error with TBB 2021 and booleans
Linux distributions are using newer TBB versions than official releases, and
TBB 2021 is an API breaking release.

In general we should avoid using TBB directly and go through the abstractions
in BLI_task.hh, though there is no abstraction for this.

For 3.0 the safe option is to just not cancel the task but instead early out
in the lambda function. Given the grain size of 2048 there should be no
significant performance difference.

Differential Revision: https://developer.blender.org/D13382
2021-11-27 19:08:06 +01:00
aa6c922d99 Geometry Nodes: Optimize Cube primitive vertex calculation
This patch gets rid of the O(N^3) complexity
of calculate_vertices. Execution time of the node is
reduced from 250ms to 140ms with 500^3 vertices.
In the future edge calculations could be done manually
and reduce the execution time even further.

Differential Revision: https://developer.blender.org/D13207
2021-11-27 19:06:07 +01:00
d2f4fb68f5 Geometry Nodes: Parallelize "Set Spline Type"-node
Parallelizes the loop that converts splines.
It gives around a 2x speedup on curves with over 1k splines.

Differential Revision: https://developer.blender.org/D13389
2021-11-27 18:17:58 +01:00
2531358297 Attempt to fix Windows new bpath tests failing, take IV.
Follow up to rBdcc500e5a265093bc9cc, rB92daff6ac2adb5bb,
rB61bd5882a20c6f3 and rB08264aaf82da8.

Sorry for the noise, this time should be good.
2021-11-26 22:39:34 +01:00
08264aaf82 Attempt to fix Windows new bpath tests failing, take III.
Follow up to rBdcc500e5a265093bc9cc, rB92daff6ac2adb5bb and rB61bd5882a20c6f3.
2021-11-26 22:07:37 +01:00
61bd5882a2 Attempt to fix Windows new bpath tests failing, take II.
Follow up to rBdcc500e5a265093bc9cc and rB92daff6ac2adb5bb.

Also shortening a bit the macros names...
2021-11-26 21:34:48 +01:00
a0bb6bb4d6 Fix T89564: Spline IK breaks when it is far away from the world origin
The isect_line_sphere algorithm became very imprecise when the line and
the sphere were reasonably far away from the world origin.

This would lead to no intersections being reported even if there was a
guaranteed intersection (line crossing from inside the sphere to the
outside).

To fix this we now use the secant root finding method to get an
intersection point. This is much more stable and robust it seems.
2021-11-26 18:24:58 +01:00
97465046c6 Geometry Nodes: add utility to set remaining outputs
Differential Revision: https://developer.blender.org/D13384
2021-11-26 18:01:59 +01:00
92daff6ac2 Attempt to fix Windows new bpath tests failing.
Follow up to rBdcc500e5a265093bc9cc.
2021-11-26 17:57:40 +01:00
2efc2221cc Fix T93402: Linking Collections instantiate extra sub-collections.
Linking is more relax than appending when it comes to instantiating
indirectly linked collections/objects.
2021-11-26 17:49:18 +01:00
0789f61373 Cleanup: remove warnings
This assert was producing warning in debug builds because
it was never hit under some circumstances.
2021-11-26 17:32:09 +01:00
602ecbdf9a Geometry Nodes: optimize Set Position node
This implements four optimizations in the Set Position node:
* Check whether the position input is the current position and ignore
  it if it is. This results in a speedup when only the Offset input is used.
* Use multi-threading when copying to computed values to the
  position attribute. All geometry types benefit from this.
* Use devirtualization for the offset and position input. This optimizes
  the common case that they are either single values or computed
  in the fly in a span.
* Write to `Mesh->mvert` directly instead of creating a temporary span.
  This makes setting mesh vertex positions even more efficient.

In my simple benchmark I'm using a White Noise node to offset the
position of 1,000,000 vertices. The speed is `20 ms -> 4.5 ms` in the
multi-threaded case and `32 ms -> 22 ms` in the single-threaded case.
2021-11-26 15:33:35 +01:00
eb7827e797 Cycles: Fix film convert address space mismatch on Metal
This patch fixes an address space mismatch in the film convert kernels on Metal. The `film_get_pass_pixel_...` functions take a `ccl_private` result pointer, but the film convert kernels pass a `ccl_global` memory pointer. Specialising the pass-fetch functions with templates results in compilation errors on Visual Studio, so instead this patch just adds an intermediate local on Metal.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13350
2021-11-26 13:58:48 +00:00
12a83db83c Fix T93290: Rotation without contraint after extrude has wrong axis
The default orientation of the mode was being indicated as overridden,
although the one of constraint was used.
2021-11-26 10:49:00 -03:00
f86331a033 Geometry Nodes: deduplicate virtual array implementations
For some underlying data (e.g. spans) we had two virtual array
implementations. One for the mutable and one for the immutable
case. Now that most code does not deal with the virtual array
implementations directly anymore (since rBrBd4c868da9f97a),
we can get away with sharing one implementation for both cases.
This means that we have to do a `const_cast` in a few places, but
this is an implementation detail that does not leak into "user code"
(only when explicitly casting a `VArrayImpl` to a `VMutableArrayImpl`,
which should happen nowhere).
2021-11-26 14:47:15 +01:00
ef88047a97 Fix T89081: Freestyle noise seed of zero crash
This leads to division by zero in Freestyle's NoiseShader which also
crashes blender.

Not sure if we really need a do_version patch for old files, as an
alternative we could also force a positive number in the NoiseShader.
This patch does not do either, just force a positive range in RNA from
now on.

Maniphest Tasks: T89081

Differential Revision: https://developer.blender.org/D13332
2021-11-26 14:40:07 +01:00
a773cd3850 Fix T93130: Frame Selected with selected paint mask does not work
This broke with {rB20fac2eca723} (which landed in 2.63), so long
standing bug.

Convention for paint modes is:
- when no paint mask is active, `Frame Selected` will focus the last
stroke
- when paint mask is active, `Frame Selected` will focus the selected
mask faces

To check the right vert coords we have to offset with `mp->loopstart`.

Maniphest Tasks: T93130

Differential Revision: https://developer.blender.org/D13247
2021-11-26 14:32:49 +01:00
35c3644e78 Fix T93117: Texture paint clone tool crash in certain situation
Caused by {rBaf162658e127}, so long standing bug.

When changing clone slots (report involved a quite complicated sequence
of selecting textures and undo -- but I think this could happen in more
situations) code checks for UV of new clone slot.
However, since above commit the slot and the clone slot were mixed up,
so in this case the responsible NULL check (for when no UV is assigned)
wasnt working.
Now correct this (NULL check the clone slot uv -- instead of the paint
slot UV).

note: not sure why low level CustomData functions actually dont do the
name NULL checks themselves (seems like callers are always responsible).

Maniphest Tasks: T93117

Differential Revision: https://developer.blender.org/D13378
2021-11-26 14:24:46 +01:00
63342861e7 Fix: error in previous commit
Forgot to actually slice the span in rB6b5e1cfacab4c4605ec2d7bfef360389afe849be.
2021-11-26 13:29:24 +01:00
b066d58216 CMake mini-rewrite: Sync code check with BKE_blender_version_is_alpha
Reproduce the logic we already do in C (BKE_blender_version_is_alpha)
and the CMake file.

Otherwise it can get out of sync if we add/rename the non-alpha release cycles.

No functional change.

Differential Revision: https://developer.blender.org/D13379
2021-11-26 13:05:37 +01:00
236be8e9f1 Fix T93380: Texture paint clone tool crash without clone image
This was crashing using the clone tool without a clone image assigned.

Caused by {rB9111ea78acf4}.
Since above commit, `BKE_image_acquire_ibuf` was using `ima->runtime`
without checking for NULL first.
Since callers are not required to check for this, just return early
here.

note: there is still a memory leak using the clone tool without a clone
image assigned (but this was also the case before said commit and needs
to be investigated separately).

Maniphest Tasks: T93380

Differential Revision: https://developer.blender.org/D13377
2021-11-26 11:46:26 +01:00
dcc500e5a2 BKE_bpath: Add minimal unittests.
This is far from a complete coverage, but should catch most of potential
issues when rewriting this code.
2021-11-26 11:08:14 +01:00
Simon Lenz
c6eaa9c552 MaskEditor: draw active layer on top
Instead of drawing the mask layers in the sequence of their occurence, draw the active mask *always* on top.

Implementation:
- move drawing loop for splines to separate static function
- draw active mask last

Example: lowest layer is active, yet still drawn on top.
{F12140355}

This is part of an effort to make mask editing more intuitive & easy to use: https://developer.blender.org/T93097

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13372
2021-11-26 11:08:05 +01:00
658fd8df0b Geometry Nodes: refactor multi-threading in field evaluation
Previously, there was a fixed grain size for all multi-functions. That was
not sufficient because some functions could benefit a lot from smaller
grain sizes.

This refactors adds a new `MultiFunction::call_auto` method which has the
same effect as just calling `MultiFunction::call` but additionally figures
out how to execute the specific multi-function efficiently. It determines
a good grain size and decides whether the mask indices should be shifted
or not.

Most multi-function evaluations benefit from this, but medium sized work
loads (1000 - 50000 elements) benefit from it the most. Especially when
expensive multi-functions (e.g. noise) is involved. This is because for
smaller work loads, threading is rarely used and for larger work loads
threading worked fine before already.

With this patch, multi-functions can specify execution hints, that allow
the caller to execute it most efficiently. These execution hints still
have to be added to more functions.

Some performance measurements of a field evaluation involving noise and
math nodes, ordered by the number of elements being evaluated:
```
1,000,000: 133 ms   -> 120 ms
  100,000:  30 ms   ->  18 ms
   10,000:  20 ms   ->   2.7 ms
    1,000:   4 ms   ->   0.5 ms
      100:   0.5 ms ->   0.4 ms
```
2021-11-26 11:06:16 +01:00
Martijn Versteegh
004172de38 Clarify a confusing comment.
Affect and effect are too confusing for non-native english speakers
(like me). Also BAKING_MASK_MARGIN doesn't exist anymore in the code.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13361
2021-11-26 10:57:17 +01:00
6b5e1cfaca Geometry Nodes: better devirtualization for sliced virtual arrays
Under some circumstances that can lead to more than a 2x
performance increase, because math nodes can better optimize
for the case when the slice is a single value or span.
2021-11-26 10:08:19 +01:00
2cda65a35a Geometry Nodes: avoid allocation when construct varray for single value
Previously, `GVArray::ForSingle` would always allocate a copy of the passed
in value. Now it only does so when the value is too large or not trivial.
2021-11-26 09:59:41 +01:00
8015433f81 Cleanup: Migrate image_gpu.cc to CC.
To prepare for future changes {T92613}.
2021-11-26 08:16:35 +01:00
e3cf7ebdb1 Cleanup: Silence clang-tidy warning. 2021-11-26 08:00:05 +01:00
a073e1e401 Cleanup: Silence clang-tidy warnings. 2021-11-26 07:59:38 +01:00
7b5a6f452a Merge branch 'blender-v3.0-release' 2021-11-25 18:33:19 +01:00
466b50dbc9 Cycles: expose direct light sampling option in Debug panel, tweak panel layout 2021-11-25 18:30:54 +01:00
2fb8c6805a Fix build error with experimental features after recent release cycle bump
Hair, pointcloud and simulation datablock types should be disabled in the
beta cycles already like other experimental features.
2021-11-25 18:24:46 +01:00
e3d3296327 Merge remote-tracking branch 'origin/blender-v3.0-release'
Merge conflict: Makes sure master is still alpha, while 3.0 is rc.
2021-11-25 18:00:33 +01:00
e6a41e1c80 Blender 3.0 bcon4 - change release cycle to release candidate
This is still a rolling release candidate with new builds every day
as a preparation to the final release.
2021-11-25 17:59:49 +01:00
b2bb3e4b72 Fix T90082: Autoscrolling after renaming in the File Browser broken
Caused by 6b0869039a

Above commit introduced selection after renaming. This includes calling
`file_select_deselect_all` [which resorts and refilters].

So now, to have the correct file for scrolling, get it again after
sorting by calling `file_params_find_renamed` again.

Differential Revision: https://developer.blender.org/D13368
2021-11-25 17:32:40 +01:00
4a3f99ad5a Merge branch 'blender-v3.0-release' 2021-11-25 17:26:53 +01:00
5a11c6e558 Fix missing margin below panels
A minor cosmetic fix. When the view was scrolled all the way to the
bottom, the lowest panel would end right on the view edge. The
scrollable view should get the same margin at the bottom as used at the
top.
2021-11-25 17:15:48 +01:00
5514ca58a4 Fix T92313: Heading of redo panel is not aligned properly
This corrects some alignments issues through new margins introduced in
93544b641b. Basic idea of this fix is to only add the new margins when
drawing a panel with background. These margins were added specifically
for the background boxes, so that makes sense.

Alternative fix to D13199.

This also fixes some margings added unintentionally in mentioned commit.
There is a little jump of the toolbar and the tabs in the Properties
when comparing the UI without this fix to 2.93:
{F12158085} {F12158039}
The jump is gone with this fix applied (compare to the 2.93 screenshot):
{F12158064}
While not a serious issue, this confirms that this fix actually tackles
the root of the issue.
2021-11-25 17:09:45 +01:00
94e8db1e86 Fix T92278: Small size of previews in the shading popover
Don't use the side padding for menu item contents when displaying
previews or icons in a row or grid layout. This can cause problems for
the preview drawing and doesn't make sense to draw there anyway.

This not only fixes the mentioned issue, but also too small heighlight
for the collection color tag in the Outliner context menu.

Alternative to and similar to D13125.
2021-11-25 15:55:04 +01:00
3652f5f758 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-25 15:22:40 +01:00
c91d196159 Fix T93274: Assigning asset catalog doesn't mark file as modified
Assigning a catalog to an asset via drag-and-drop in the asset browser
now creates an undo step. Not only does this allow undoing the action,
it also tags the blend file as modified.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D13370
2021-11-25 15:02:23 +01:00
9812a08848 Fix: Crash when muting the Group Output node
This fixes a crash when muting the "Group Output" node.
It should not be possible to mute it so this patch
sets the `no_muting`-variable on it.

Differential Revision: https://developer.blender.org/D13364
2021-11-25 15:01:38 +01:00
e216660382 Merge branch 'blender-v3.0-release'
Conflicts:
	source/blender/windowmanager/intern/wm_files_link.c
2021-11-25 15:00:06 +01:00
e253fb2143 Fix T93353: Reload Library used as source for liboverride loses Constraints.
Liboverride properties and operations list need to be fully up-to-date
before libraries are reloaded, otherwise re-applying those liboverrides
after linked data is reloaded may miss some changes.
2021-11-25 14:56:56 +01:00
3bf10e5d0a Fix T89996, T90063: bugs with multi-button reset and entering values in popups
This reverts the changes to fix T87448, where entering the same value in number
buttons causes an unnecessary update. This is not stable enough for 3.0 and so
is being reverted, better to have an unnecessary update than no update in other
cases.

This effectively reverts the changes from rBeb06ccc32462 and follow up fixes
rBe1a9ba94c599, rBbbb52a462ef9, rBec30cf0b742f, and rB071799d4fc44. The code is
disabled with a comment on how it could be implemented better.
2021-11-25 14:45:19 +01:00
2378f057a0 Merge branch 'blender-v3.0-release' 2021-11-25 14:21:05 +01:00
bc4c20d414 Fix T93360: 'Iteractive Light Track' do not work over empty background
Bug introduced in {rBaa0ac0035a0d}.

The invalid depth fallback was changed to `FLT_MAX` in order to match the
annotation and gpencil operations.

This broke the `Interactive Light Track` operator which invalidates the
operation if the depth value is `1.0f`.

The chosen solution was to change the value tested in the annotation and
gpencil operations.
2021-11-25 10:18:57 -03:00
ffddf9e5c9 Fix T93338: Curve Guide force field crash
Caused by {rBcf2baa585cc8}.

For Curve Guide force fields to work, the `Path Animation` option has to
be enabled. With it disabled, we are lacking the necessary
`anim_path_accum_length` data initialized [done by
`BKE_anim_path_calc_data`] which `BKE_where_on_path` relies on since
above commit.

Now just check for this before using it - and return early otherwise.
Prior to said commit, `BKE_where_on_path` would equally return early
with a similar message, so that is expected behavior here.

Maniphest Tasks: T93338

Differential Revision: https://developer.blender.org/D13371
2021-11-25 14:16:12 +01:00
447378753d BLI: remove special cases for is_span and is_single methods
Those were not implemented consistently and don't really help in practice.
2021-11-25 13:51:23 +01:00
845716e600 Fix T92609 Default Compositing tab shows red overlay when stereoscopy is turned on
This was caused by the drawing not being done on the right frammebuffer.
2021-11-25 13:40:04 +01:00
d6646f7a8a Fix T93367: wrong attribute propagation in Delete Geometry node
This only happened with non-point selections. It used an incorrect
index mapping for the attribute propagation.
2021-11-25 11:32:12 +01:00
1e2376f41f Merge branch 'blender-v3.0-release' 2021-11-25 10:36:30 +01:00
82808e18e6 Fix T93362: crash when capturing attribute after fillet curve node
The issue was that the attribute propagation in the Fillet Curve node seems
pretty broken. I couldn't really make sense of the old code. It changed the
size of the point attribute domains on splines to 1 for some reason which
led to a crash in the next node.

Differential Revision: https://developer.blender.org/D13362
2021-11-25 10:33:05 +01:00
5ffb9b6dc4 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-25 10:22:32 +01:00
Bastien Montagne
a0acb9bd0c Fix T91444: Edge Loop Preview fails with two Mirror Modifiers
The mirror modifiers merge option caused unnecessary re-ordering
to the vertex array with original vertices merging into their copies.

While this wasn't an error, it meant creating a 1:1 mapping from input
vertices to their final output wasn't reliable (when looping over
vertices first to last) as is done in
BKE_editmesh_vert_coords_when_deformed.

As merging in either direction is supported, keep the source meshes
vertices in-order since it allows the vertex coordinates to be extracted.

NOTE: Since this change introduce issues for some cases (e.g. bound
modifiers like SurfaceDeform), this change is only applied to newly
created modifiers, existing ones will still use the old incorrect merge
behavior.

Reviewed By: @brecht

Maniphest Tasks: T93321, T91444

Differential Revision: https://developer.blender.org/D13355
2021-11-25 10:21:49 +01:00
e6cd4761e7 Fix T93321: Modified Mirror modifier behavior break some other tools like bound SurfaceDeform.
Revert "Fix T91444: Edge Loop Preview fails with two Mirror Modifiers"

This reverts commit 1a7757b0bc.

Caused issue reported in T93321, boiling down to the fact that other
operations or modifiers (like the SurfaceDeform one) rely on the order
of the vertices in the mesh to remain consistent.

Changing this in a modifier would mean those operations need to be
reset/re-created (e.g. rebound for the SurfaceDeform case), which is not
doable in `do_version` code.
2021-11-25 10:21:49 +01:00
726bc3a46b Fix T93155: Approximate shadow catcher displayed wrong on CPU and GPU
Was happening during rendering, causing visual artifacts when doing
CPU+GPU rendering, and giving different in-progress results on different
devices.

The root of the issue comes to the fact that math used in the approximate
shadow catcher calculation might have resulted in negative alpha channel,
and negative values for display are handled differently on CPU and GPU.
Such difference in handling is caused by an approximate conversion used on
the CPU for the performance reasons.

This change makes it so no negative alpha is generated by the approximate
shadow catcher. Not sure if we need some explicit clamping somewhere to
deal with possible negative values coming from somewhere else.

The shadow catcher cornell box tests are to be updated for the new code,
but the new result seems to be more accurate.

Differential Revision: https://developer.blender.org/D13354
2021-11-25 10:17:52 +01:00
610e68590b Merge branch 'blender-v3.0-release' 2021-11-25 10:12:57 +01:00
ce5561b815 Fix Py API: wrong doc about type of Collection property.
Collection property only accepts PropertyGroup type, not ID ones.

Reported on IRC by @frameshift, thanks.
2021-11-25 10:12:35 +01:00
f12a6ff5cb Merge branch 'blender-v3.0-release' 2021-11-25 09:51:12 +01:00
40d28b40df Fix black Cycles result when cancelling tiled rendering with shadow catcher
Noticed when was looking into T93155. Steps to reproduce:

- Open the .blend file from the report
- Hit F12 to start rendering
- After some tiles were rendered hit Esc

The issue is caused by "sticky" cancel reported via Progress. This  means
that once user hit Esc all further requests for cancel state will return
truth, which was preventing OIDN denoiser from completing the denoising
task.

Now only allow stopping the denoiser when interactive rendering requests
a very fast stopping.

Aiming the fix for 3.0 branch.

Differential Revision: https://developer.blender.org/D13352
2021-11-25 09:50:33 +01:00
William Leeson
c49d2cbe92 Merge branch 'blender-v3.0-release' to bring in D13042:
Fix performance decrease with Scrambling Distance on
2021-11-25 09:41:03 +01:00
Alaska
b41c72b710 Fix performance decrease with Scrambling Distance on
With the current code in master, scrambling distance is enabled on non-hardware accelerated ray tracing devices see a measurable performance decrease when compared scrambling distance on vs off. From testing, this performance decrease comes from the large tile sizes scheduled in `tile.cpp`.

This patch attempts to address the performance decrease by using different algorithms to calculate the tile size for devices with hardware accelerated ray traversal and devices without. Large tile sizes for hardware accelerated devices and small tile sizes for others.

Most of this code is based on proposals from @brecht and @leesonw

Reviewed By: brecht, leesonw

Differential Revision: https://developer.blender.org/D13042
2021-11-25 09:32:26 +01:00
827c5b399e Merge branch 'blender-v3.0-release' 2021-11-25 00:04:32 +01:00
8f2db94627 Fix T93357: crash when opening search menu
This is the same fix as in rBde35a90f9f56d3ff3ac80c13bf1ae296853ba877
but for the blender-v3.0-release branch.
2021-11-25 00:03:41 +01:00
c26011efcb Fix T92962 Boolean output indices unstable.
A parallel loop to create the interesection meshes for each triangle
meant that with parallelism, the output order of the created meshes
could vary with each execution. Keep the parallelism for doing the CDTs
for interesection, but move the extraction of the new faces into a
serial loop afterwards, for repeatability.
2021-11-24 15:26:12 -05:00
6b1b3383c6 Merge branch 'blender-v3.0-release' 2021-11-24 21:10:24 +01:00
Leon Leno
a9642f8d61 UI: Improve scaling of widgets when zooming
This commit improves the scaling of some ui widgets when
zooming by making the radius of the rounded corners
dependent on the element's zoom level.

Needed to fix T92278 without padding issues, see D13125.

Reviewed By: Hans Goudey, Julian Eisel

Differential Revision: https://developer.blender.org/D12842
2021-11-24 21:06:32 +01:00
c155a5f9d7 Merge branch 'blender-v3.0-release' 2021-11-24 14:53:16 -03:00
752c6d668b Fix T90808: wrong BoundBox after undo curve selection
There are two functions that recalculate the boundbox of an object:
- One that considers the evaluated geometry
- Another that only considers the object's `data`.

Most of the time, the bound box is calculated on the final object
(with modifiers), so it doesn't seem right to just rely on `ob->data`
to recalculate the `ob->runtime.bb`.

Be sure to calculate the BoundBox based on the final geometry and
only use `ob->data` as a fallback

Differential Revision: https://developer.blender.org/D12282
2021-11-24 14:52:49 -03:00
bbadee6fc1 UI: Blend File Icons Thumbnail View
Changes icon used to indicate blend file when overlaid over larger
document icon when in thumbnail view. Only seen when file does not
have a preview.

Followup to {rB611e4ffaab43}

For more details and examples see D13342

Differential Revision: https://developer.blender.org/D13342

Reviewed by Julian Eisel
2021-11-24 09:52:27 -08:00
7a7ae4df43 UI: Blend File Icons Thumbnail View
Changes icon used to indicate blend file when overlaid over larger
document icon when in thumbnail view. Only seen when file does not
have a preview.

Followup to {rB611e4ffaab43}

For more details and examples see D13342

Differential Revision: https://developer.blender.org/D13342

Reviewed by Julian Eisel
2021-11-24 09:50:02 -08:00
338408772a Merge branch 'blender-v3.0-release' 2021-11-24 18:37:33 +01:00
71c39a9e2e Asset Browser: Activate a catalog when dragging
Without this it's easy to loose track of which catalog you are dragging.
Things feel generally quite jumpy/disconnected, activating the catalog
makes things feel far less like that.
I consider this an important usability fix, therefore I'm adding it to
the release branch.
2021-11-24 18:05:08 +01:00
cae3b581b0 Asset Browser: Fix catalog being renamed when dropping into parent
When dropping catalogs it is ensured that the name of the moved catalog
is unique within the new parent catalog. When dropping a catalog into
the parent, the catalog would not actually move to a different location,
but it would still be renamed. The unique name logic simply isn't smart
enough to ignore the catalog that is about to be moved.
Address this by disallowing dragging a catalog into its own parent. It's
already there.
2021-11-24 17:59:14 +01:00
499c24ce75 BLI: add slice method to index mask and generic span 2021-11-24 17:49:33 +01:00
cbe9a87d28 Geometry Nodes: use simpler types when devirtualizing virtual array
The compiler is more likely to optimize away the function call
overhead when the used type is simpler and not virtual.
2021-11-24 17:46:00 +01:00
01ab36ebc1 Asset Browser: Support dragging catalogs into top level
This was an oversight when I added catalog drag & drop support. I forgot
to add this for dragging catalogs into the top level by dragging into to
the "All" item as well. This made the drag & drop support rather broken
because it wouldn't work for a basic case.
2021-11-24 17:31:28 +01:00
e206a0ae96 Geometry Nodes: reduce thread switching in evaluator
When a node is executed, it usually schedules other nodes.
Right now, those newly scheduled nodes are added to a
task pool so that another thread can start working on them
immediatly.

However, that leads to the situation where sometimes each
node in a simple chain is executed by another thread. That
leads to additional threading overhead and reduced cache
efficiency (for caches that are not shared between cores).

Now, when a node is executed and schedules other nodes,
the first of those newly scheduled nodes will always be
executed on the same thread once the current node is done.
If it schedules more than one other node, those will be
added to the task pool as before.

The speedup achieved by this is hard to measure. I found it
to be a couple percent faster in some extreme cases, not
much to get excited about. It's nice though that the number
of tasks added to the task pool is commonly reduced by a
factor of 4 or 5.
2021-11-24 17:26:41 +01:00
4930cd5db6 Merge branch 'blender-v3.0-release' 2021-11-24 10:40:13 -05:00
a07089dcb1 Fix T92120 (partially): No bone custom shape with curve object meshes
This part of the drawing code assumes that the bone custom object
has only one evaluated geometry component, and it also uses the
object type to check which data to draw, with the functions like
`DRW_cache_object_surface_get` that just take an object input.
Those functions usually work on evaluated objects, which use the
instancing system to access a temporary object with `object.data`
replaced for data types that don't match the original object.

That assumption used to work, but now curve, point cloud, or volume
objects can have an evaluated mesh which is not accessed with the
same object for render engine drawing.

The "correct" solution for the way this code is structured would be to
loop through all of the geometry components and try to get GPU batches
from every one of them. However, that significantly increases complexity
in an area that should probably be refactored anyway. This patch treats
the mesh as a special case, and only draws the evaluated mesh.

The **best** solution in my opinion might be refactoring this area to
use the instancing system with some sort of viewport-only flag so
the custom shape instances aren't added in the render.

The solution is "partial" because the "Wireframe" option only works
for meshes from mesh objects, even after this fix, and because other
data besides meshes is not displayed at all.

Differential Revision: https://developer.blender.org/D13038
2021-11-24 10:39:33 -05:00
7a97e925fd Cycles: Add support for building with OptiX 7.4 SDK and use built-in catmull-rom curve type
Some enum names were changed/removed in OptiX 7.4, so some changes are necessary to
make things compile still.
In addition, OptiX 7.4 also adds built-in support for catmull-rom curves, so it is no longer
necessary to convert the catmull-rom data to cubic bsplines first, and has endcaps disabled
by default now, so can remove the special handling via any-hit programs that filtered them
out before.

Differential Revision: https://developer.blender.org/D13351
2021-11-24 16:33:04 +01:00
56b068a664 Fix inconsistent UI terminology for tiling option
Was meant to be Use instead of Using.
2021-11-24 15:54:53 +01:00
64d9291d26 Cleanup: formatting 2021-11-24 15:54:53 +01:00
Alessio Monti di Sopra
2cc56495f3 UI: Fix alignment for recently added/edited icons
The patch slightly modifies two recently added icons "FILE_BLEND" and
"CURRENT_FILE" to better align them to the pixel grid, and change the
design of "FILE_BACKUP" to avoid alignment and readability issues, as
well as avoiding the outline version of the Blender logo which violates
the official logo guidelines.

Differential revision: https://developer.blender.org/D13346
2021-11-24 15:51:57 +01:00
72acce43bc Animation: allow marking actions as cyclic for Cycle-Aware Keying.
When a manual frame range is set, allow marking an action as having
Cyclic Animation. This does not affect how the action is evaluated,
but the Cycle-Aware Keying option will automatically make any newly
added F-Curves cyclic. This allows using the option from the start
to build the cycle, rather than only for tweaking an existing loop.

The curves are made cyclic when they have only one key, either
after inserting the first key, or before adding the second one.
The latter case avoids the need to manually make the first added
curve cyclic after marking a newly added action cyclic.

Differential Revision: https://developer.blender.org/D11803
2021-11-24 15:58:32 +03:00
5d59b38605 Animation: allow manually setting the intended playback range for actions.
Some operations, e.g. adding a new action strip to NLA, require
knowing the active frame range of an action. However, currently it
can only be deduced by scanning the keyframes of the curves within
it. This is not ideal if e.g. curves are staggered for overlap.

As suggested by Nathan Vegdahl in comments to T54724, this patch adds
Action properties that allow manually specifying its active frame range.
The settings are exposed via a panel in the Dopesheet and Action Editor.
When enabled, the range is highlighted in the background using a striped
fill to distinguish it from the solid filled regular playback range.

When set, the frame range is used when adding or updating NLA tracks,
and by add-ons using `Action.frame_range`, e.g. FBX exporter.

Differential Revision: https://developer.blender.org/D11803
2021-11-24 15:58:32 +03:00
057cb7e5e7 Context: add accessors returning selected actions for animation editors.
Add a new 'selected_visible_actions' property to allow querying
actions that are selected in animation related editors for use in
UI and operators. The 'selected_editable_actions' variant excludes
linked actions (the only reason an action can be read-only).

In the Action and Shape Key editors there is only one action
that is specified by the field at the top of the editor.

In Dope Sheet it scans the channel rows and returns all actions
related to the selected items. This includes summary items for
actions and groups.

In Graph Editor, it lists actions associated with selected curves.

The new property is also used for Copy To Selected and Alt-Click.

Ref D11803
2021-11-24 15:58:32 +03:00
65f547c3fc Geometry Nodes: add utility to show debug messages in node editor
This is only meant to be used for development purposes for now,
not to show warnings to the user.

Differential Revision: https://developer.blender.org/D13348
2021-11-24 13:39:20 +01:00
9fc5a9c78f macOS: Fix build error due to std::optional<T>::value 2021-11-24 17:41:37 +05:30
7ea4342e73 Geometry Nodes: reduce number of scheduled nodes in evaluator
Previously, there were a couple of cases where nodes were scheduled when
that was not really necessary. This change doesn't seem to have a big impact
on performance, but simplifies the code a bit.
2021-11-24 12:57:36 +01:00
833eb90820 Cleanup: removed shadowed variable 2021-11-24 12:57:36 +01:00
simon
25478bdc9a Merge branch 'blender-v3.0-release' 2021-11-24 12:56:19 +01:00
5a50b46376 Fix T93352: Material previews lost render samples
There are few layers of things which lead to the situation
of more noisy material preview: the do-version of the
preview.blend did not happen (at least from the Python
side as we did not investigate the C side deep). This made
Cycles to use default integrator settings for the preview
file ever since the Cycles X was merged. Those settings are
adaptive sampling with max 4K samples, noise threshold 0.01.
Opening the file in Blender 3.0 for edit did run the versioning
code which effectively lowered the number of samples used for
rendering.

This change makes it so the preview file is configured with
the exact effective settings as seen by Cycles prior to the
file was re-saved (adaptive sampling with the parameters noted
above).

This fix does not chaneg the fact that the versioning code is
not used for preview.blend, it only solves the regression in
the quality of previews.

The fix is done and reviewed with collaboration with Dalai and Sergey.
2021-11-24 12:47:30 +01:00
f5e5a0987a Geometry Nodes: decouple Delete Geometry node from Mask modifier
This dependency was a bit ugly and the functions from the mask modifier
did a few things that we don't need in the Delete Geometry node:
* The mask modifier uses `CustomData_copy_data` which the node doesn't need.
* The mask modifier checks for `-2` in some values, but this special value is
  not used by the node.

Differential Revision: https://developer.blender.org/D13335
2021-11-24 12:00:35 +01:00
050b205a97 CMake: add WITH_UNITY_BUILD option to improve compile times
Unity builds are only used in the `bf_nodes_geometry` module for now.
This module has been prepared to support unity builds already.
Usually, there is a 2-4x speedup when building `bf_nodes_geometry`
compared to without unity builds (e.g. 145s to 55s).

For more information about how unity builds work and how they help
with compile times, see D13341.

Differential Revision: https://developer.blender.org/D13341
2021-11-24 11:40:26 +01:00
3850fdd5b9 Assets: Sanitize threaded preview creation with undo
Basically, this fixes disappearing previews when editing asset metadata
or performing undo/redo actions.

The preview generation in a background job will eventually modify ID
data, but the undo push was done prior to that. So obviously, an undo
then would mean the preview is lost.

This patch makes it so undo/redo will regenerate the preview, if the preview
rendering was invoked but not finished in the undone/redone state.

The preview flag PRV_UNFINISHED wasn't entirely what we needed. So I had to
change it to a slightly different flag, with different semantics.
2021-11-24 11:26:37 +01:00
98a5658239 Cleanup: Renamed DefaultDrawingMode ImageSpaceDrawingMode.
Explains more what it does, not how it is used.
2021-11-24 11:23:44 +01:00
cd818fd081 Assets: Sanitize threaded preview creation with undo
Basically, this fixes disappearing previews when editing asset metadata
or performing undo/redo actions.

The preview generation in a background job will eventually modify ID
data, but the undo push was done prior to that. So obviously, an undo
then would mean the preview is lost.

This patch makes it so undo/redo will regenerate the preview, if the preview
rendering was invoked but not finished in the undone/redone state.

The preview flag PRV_UNFINISHED wasn't entirely what we needed. So I had to
change it to a slightly different flag, with different semantics.
2021-11-24 11:20:35 +01:00
75b53542f2 ImageEngine: Remove unneeded check for tiled image.
Regular images are also tiled images, but with a default tile that leads
to the same result.
2021-11-24 11:02:05 +01:00
17770192fb Tests: exclude anonymous attributes from mesh comparison
The set of anonymous attributes on a geometry is not visible to the user.
2021-11-24 10:38:42 +01:00
e0763760e4 Cleanup: IDTypeInfo new asset_type_info member.
Two issues addressed here:

I) `asset_type_info` is sub-data, not a callback. Therefore, move it
before the callbacks in the `IDTypeInfo` struct.

II) More important, initialize this new attribute in *ALL* `IDTypeInfo`
instances. No member of this struct should ever be left implicitely
uninitilazed, ever.

Aftermath of rBa84f1c02d251.
2021-11-24 10:35:47 +01:00
f8dea3fe64 Fix T93345: missing null check for geometry nodes logger 2021-11-24 10:16:14 +01:00
2ddbf81c47 Cleanup: Add info about attributes init in Mesh IDTypeInfo after conversion to C++.
rB6002914f141f totally lost those info, in C++ we use comments by
convention.
2021-11-24 10:09:35 +01:00
f9db7675e0 Cleanup: use lowercase in private functions. 2021-11-24 10:06:17 +01:00
785503a7e4 Cleanup: use lowercase in private functions. 2021-11-24 10:05:45 +01:00
1a887b0088 Cleanup: use nullptr 2021-11-24 10:05:01 +01:00
4d46e8a5e0 Merge branch 'blender-v3.0-release' 2021-11-24 10:02:57 +01:00
4b259edb0a Cleanup: Silent compilation warning in draw_manager. 2021-11-24 10:02:30 +01:00
de35a90f9f Fix crash when opening search menu.
Asset install bundle poll didn't check the space it was running in and
assumed that it was always running in file browser.
2021-11-24 09:27:47 +01:00
ebe5a5eca8 AssetBrowser: Disable asset indexing.
Asset Indexing is disabled for now as it requires {D12990} to support
object snapping.
2021-11-24 08:32:29 +01:00
Jeroen Bakker
dbeab82a89 T91406: Asset Library Indexing
Asset library indexing would store indexes of asset files to speed up
asset library browsing.

* Indexes are read when they are up to date
** Index should exist
** Index last modify data should be later than the file it indexes
** Index version should match
* The index of a file containing no assets can be load without opening
   the index file. The size of the file should be below a 32 bytes.
* Indexes are stored on a persistent cache folder.
* Unused index files are automatically removed.

The structure of the index files contains all data needed for browsing assets:
```
{
  "version": <file version number>,
  "entries": [{
    "name": "<asset name>",
    "catalog_id": "<catalog_id>",
    "catalog_name": "<catalog_name>",
    "description": "<description>",
    "author": "<author>",
    "tags": ["<tag>"]
  }]
}
```

Reviewed By: sybren, Severin

Maniphest Tasks: T91406

Differential Revision: https://developer.blender.org/D12693
2021-11-24 08:21:40 +01:00
Jeroen Bakker
16fc0da0e7 Animation: Add test cases for ED_keyframes_keylist.
This patch adds test cases to detect edge cases when finding
keylist columns.

The patch originated during development of D12052 to make sure
the new implementation matches the old implementation. It would
be good to add these test cases to master so this part is covered
in a next change might influence the expected edges.

The patch covers `ED_keylist_find_next`, `ED_keylist_find_prev`
and `ED_keylist_find_exact` methods.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D12302
2021-11-24 08:02:50 +01:00
21f22759ea Merge branch 'blender-v3.0-release' 2021-11-23 17:17:36 -08:00
60c0b79256 Add tablet data to Wintab fallback cursor movement. 2021-11-23 17:10:30 -08:00
Christoph Lendenfeld
6b4405d757 Extract keyframe segment calculation
extracts the search for keyframe segments (consecutive selection of keys)
It will be reused by future graph editor operators

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D9360
Ref: D9360
2021-11-23 21:38:23 +00:00
d144983f8c Cleanup: unused variable 2021-11-23 18:15:59 -03:00
56f66602c7 Fix (unreported): Local preview icons not loading
Bug introduced in {rB9d7422b817d1}.

The solution is not an init thread for preview tasks that won't complete.
2021-11-23 18:11:54 -03:00
9159295c3c Clang Tidy: ignore some passes that changed or were added in version 13
I get hundreds of clang-tidy errors without ignoring those passes right now.
To not forget about the passes, I added them to T78535.
2021-11-23 19:45:05 +01:00
62a04f7aa6 Cleanup: clang tidy
The parameter name was inconsistent with the declaration.
2021-11-23 19:38:22 +01:00
38a3819171 Merge branch 'blender-v3.0-release' 2021-11-23 19:04:44 +01:00
3844e9dbe7 Fix (unreported): unlinked group input is not logged in geometry nodes
Differential Revision: https://developer.blender.org/D13340
2021-11-23 19:03:16 +01:00
ea93e5df6c Asset: Merge asset library/list refresh operators
In rBdcdbaf89bd11, I introduced a new operator
(`file.asset_library_refresh()`) to handle Asset Browser refreshing more
separate from File Browser refreshing. However, there already was
`asset.asset_list_refresh()`, which at this point only works for asset
view templates, but was intended to cover the Asset Browser case in
future too. This would happen once the Asset Browser uses the asset list
design of the asset view template.

So rather than having two operators for refreshing asset library data,
have one that just handles both cases, until they converge into one.
This avoids changes to the Python API in future (deprecating/changing
operators).

Differential Revision: https://developer.blender.org/D13239
2021-11-23 18:57:25 +01:00
60befc8f02 Clean-up: Fix BLI_rect.h collision with windows.h
windows.h `#defines rct1` as a number which is
problematic if we include `BLI_rect.h` after
`windows.h` .

by renaming `rct1/2` to `rct_a/b` we side step
the collision and straighten up the naming with
the functions directly above it.
2021-11-23 10:51:09 -07:00
62b50c612f Cleanup: Else after return, other simplifications
`std::stringstream` already returns a `std::string`, and there is no
particular reason to use short here instead of int.
2021-11-23 12:49:45 -05:00
9e5aae4215 Asset: Merge asset library/list refresh operators
In rBdcdbaf89bd11, I introduced a new operator
(`file.asset_library_refresh()`) to handle Asset Browser refreshing more
separate from File Browser refreshing. However, there already was
`asset.asset_list_refresh()`, which at this point only works for asset
view templates, but was intended to cover the Asset Browser case in
future too. This would happen once the Asset Browser uses the asset list
design of the asset view template.

So rather than having two operators for refreshing asset library data,
have one that just handles both cases, until they converge into one.
This avoids changes to the Python API in future (deprecating/changing
operators).

Differential Revision: https://developer.blender.org/D13239
2021-11-23 18:40:31 +01:00
c09e8a3590 Merge branch 'blender-v3.0-release' 2021-11-23 18:35:56 +01:00
792badcfef Fix broken handling of constraints reordering with library overrides
Alternative to D13291 (description partially copied from there).

New drag & drop reordering code would call constraints reordering
operator with the generic context, and not the one from the panel's
layout. missing the "constraint" member which is mandatory for poll
function to properly deal with override vs. local constraints.

For this to work in a decent way, there needs to be some panel-wide
context that we can restore when executing callbacks outside of the
normal draw context. So similar to uiLayoutSetContextPointer() to set
context on a layout level, this introduces
UI_panel_context_pointer_set() for panel level context (this calls the
former for the current panel root layout as well).

Differential Revision: https://developer.blender.org/D13308
2021-11-23 18:34:51 +01:00
c0a2b21744 Merge branch 'blender-v3.0-release' 2021-11-23 18:04:28 +01:00
fb4851fbbc Fix: The bounding box gizmo breaks if transform pivot is set to cursor
The bounding box transform code assumed that the pivot would always be
the sequence object transform center.

Rework the code so that this assumption is true even if the general
transform pivot is set to be the 2D cursor.
2021-11-23 18:03:36 +01:00
b40e930ac7 Merge branch 'blender-v3.0-release' 2021-11-23 17:52:30 +01:00
cf266ecaa6 Geometry Nodes: fix attribute propagation in Delete Geometry node
Previously, attribute propagation did not work correctly in when only
deleting edges and faces (but not points). Face and face corner attributes
were propagated wrongly or not at all respectively.

In order to keep the patch relatively small for the release branch,
it does not include some small optimizations. These can be done in 3.1:
* Use a `Span<int>` instead of `IndexMask` to avoid creating an
  unnecessary `Vector<int64_t>`.
* Only prepare index mappings when there are actually attributes to
  propagate.

Differential Revision: https://developer.blender.org/D13338
2021-11-23 17:48:09 +01:00
e4986f92f3 Geometry Nodes: Node execution time overlay
Adds a new overlay called "Timings" to the Geometry Node editor.
This shows the node execution time in milliseconds above the node.
For group nodes and frames, the total time for all nodes inside
(recursively) is shown. Group output node shows the node tree total.
The code is prepared for easily adding new rows of information
to the box above the node in the future.

Differential Revision: https://developer.blender.org/D13256
2021-11-23 17:37:31 +01:00
fab39440e9 Cleanup: Simplify geometry node function names
With this commit, we no longer use the prefixes for every node type
function like `geo_node_translate_instances_`. They just added more
places to change when adding a new node, for no real benefit.

Differential Revision: https://developer.blender.org/D13337
2021-11-23 10:55:51 -05:00
a9eb4e6f59 Merge branch 'blender-v3.0-release' 2021-11-23 16:41:53 +01:00
a6b7f32112 Fix T93297: incorrect eevee motion blur with geometry instances
This disables motion blur for geometry instances in eevee, which did
not work correctly anyway. See code comment for more details.

Differential Revision: https://developer.blender.org/D13334
2021-11-23 16:40:21 +01:00
db450c9320 Merge branch 'blender-v3.0-release' 2021-11-23 16:38:30 +01:00
70424195a8 Cycles: Fix possible access to non-initialized light sample in volume
Happened in barbershop file where number of bounces to the light was
reached.

Differential Revision: https://developer.blender.org/D13336
2021-11-23 16:38:15 +01:00
71c80bd939 Merge branch 'blender-v3.0-release' 2021-11-23 16:32:13 +01:00
2cbb9d7a76 Fix T93322: Freestyle Sinus Displacement Division by Zero Crash
This happens if the Wavelength is set to 0.0f.

Not sure if we really need a do_version patch for old files, as an
alternative we could also force a slight offset in the
SinusDisplacementShader. This patch does not do either, just force a
positive range from now on.

Maniphest Tasks: T93322

Differential Revision: https://developer.blender.org/D13329
2021-11-23 16:29:37 +01:00
b716a771b4 Merge branch 'blender-v3.0-release' 2021-11-23 15:46:28 +01:00
Sayak Biswas
3bb8d173e7 Fix T93109: Cycles HIP missing check for correct driver version
21.Q4 is required, older version should not show devices in the preferences.
This adds a check for the file version of amdhip64.dll file during hipew
initialization.

Differential Revision: https://developer.blender.org/D13324
2021-11-23 15:45:37 +01:00
fca8eb0185 Cleanup: Suppress clang-tidy warning. 2021-11-23 15:41:28 +01:00
2c2b79191f Merge branch 'blender-v3.0-release' 2021-11-23 15:41:09 +01:00
1a7c32a0ab Fix T93320: Freestyle LineStyleModifier blend 'Minimum' error
This was just a typo in {rBb408d8af31c9}
Must be 'MINIMUM' (instead of 'MININUM').

Maniphest Tasks: T93320

Differential Revision: https://developer.blender.org/D13328
2021-11-23 15:38:52 +01:00
4b13dcaf02 Merge branch 'blender-v3.0-release' 2021-11-23 15:35:09 +01:00
ceb25cbeba Fix compilation warnings when building without OpenImageDenoiser
Reported by Sybren, thanks!
2021-11-23 15:34:54 +01:00
8897e0aa8f Fix add-on Preferences using the .blend file icon, not the Blender logo
Intention of the icon is to mark add-ons that are official/bundled.
Doesn't make much sense to use the .blend file icon for that. It's
arguable if the Blender logo should be used for this, but the file icon
is definitely the wrong choice.
2021-11-23 15:30:28 +01:00
5efddc4347 Fix add-on Preferences using the .blend file icon, not the Blender logo
Intention of the icon is to mark add-ons that are official/bundled.
Doesn't make much sense to use the .blend file icon for that. It's
arguable if the Blender logo should be used for this, but the file icon
is definitely the wrong choice.
2021-11-23 15:30:05 +01:00
1df8abff25 Geometry Nodes: add namespace for every file
This puts all static functions in geometry node files into a new
namespace. This allows using unity build which can improve
compile times significantly (P2578).

* The name space name is derived from the file name. That makes
  it possible to write some tooling that checks the names later on.
  The file name extension (`cc`) is added to the namespace name as
  well. This also possibly simplifies tooling but also makes it more
  obvious that this namespace is specific to a file.
* In the register function of every node, I added a namespace alias
  `namespace file_ns = blender::nodes::node_geo_*_cc;`. This avoids
  some duplication of the file name and may also simplify tooling,
  because this line is easy to detect. The name `file_ns` stands for "file
  namespace" and also indicates that this namespace corresponds to
  the current file. In the beginning I used `node_ns` but `file_ns` is more
  generic which may make it more suitable when we want to use unity
  builds outside of the nodes modules in the future.
* Some node files contain code that is actually shared between
  different nodes. For now I left that code in the `blender::nodes`
  namespace and moved it to the top of the file (couldn't move it to
  the bottom in all cases, so I just moved it to the top everywhere).
  As a separate cleanup step, this shared code should actually be
  moved to a separate file.

Differential Revision: https://developer.blender.org/D13330
2021-11-23 14:56:01 +01:00
47276b8470 Geometry Nodes: reduce overhead when processing single values
Currently the geometry nodes evaluator always stores a field for every
type that supports it, even if it is just a single value. This results in a lot
of overhead when there are many sockets that just contain a single
value, which is often the case.

This introduces a new `ValueOrField<T>` type that is used by the geometry
nodes evaluator. Now a field will only be created when it is actually
necessary. See D13307 for more details. In extrem cases this can speed
up the evaluation 2-3x (those cases are probably never hit in practice
though, but it's good to get rid of unnecessary overhead nevertheless).

Differential Revision: https://developer.blender.org/D13307
2021-11-23 14:49:26 +01:00
0bedd5d14f Merge branch 'blender-v3.0-release' 2021-11-23 14:39:55 +01:00
436ce22194 Fix T93296: raycast node uses wrong domain for face corner attributes
This changes what domain is used by the raycast mode. This should fix the
behavior for face corner attributes (but may make it a bit slower for other
attributes). I think for 3.0 this is an acceptable trade off. For 3.1 we can do
what the comment suggests already.

Differential Revision: https://developer.blender.org/D13333
2021-11-23 14:38:02 +01:00
dab04bc053 Fix T93231: crash when overwriting vertex group with other domain
The problem was that we forgot to actually remove the vertex group when
it should be deleted. We only removed all the data that was attached to it.

Differential Revision: https://developer.blender.org/D13326
2021-11-23 14:38:02 +01:00
d7b7cbb047 Merge branch 'blender-v3.0-release' 2021-11-23 14:36:57 +01:00
0479a66313 Fix broken versionning after recent refactor of insertion in liboverrides.
rB33c5e7bcd5e5b79 doversion code was incorrectly dealing with 'insert in
first position' case from older blendfiles.

Specifically, a NULL anchor is valid (it means that the new item is the
first of the stored override data, and should be inserted at start of
the list).

Reported as part of T93321.
2021-11-23 14:36:40 +01:00
611e4ffaab Icons: Replace .blend file icons, add "Current File" icon
The Blender icon must not be used to refer to anything that is not
Blender itself. Using the Blender icon on its own to refer to .blend
files or the currently open file is a no-go, which was brought up by
Ton.

This does the following changes to the icon file:
* Add new "Current File" icon
* Change the .blend file icon to contain a file icon with the Blender
  logo, but not merely the Blender logo.
* Change the backup .blend file icon accordingly.

The new "Current File" icon is used in the Asset Browser, but
could/should be used in the Outliner as well. That needs more design
discussion though.
2021-11-23 14:32:35 +01:00
89b927a720 Cleanup: Silence compilation warning.
For now made DRW_notify_view_update_offscreen static.
2021-11-23 14:30:14 +01:00
fecdf9d44b Merge branch 'blender-v3.0-release'
Conflicts:
	source/blender/editors/transform/transform_generics.c
2021-11-23 10:17:24 -03:00
b7c98c87ac Cleanup: clang-tidy warnings
Silenciate warnings of usage of 'else' after 'return'
2021-11-23 10:15:00 -03:00
a6d1a2d3fc Merge branch 'blender-v3.0-release' 2021-11-23 14:08:53 +01:00
Christian Stolze
bba6fe83e2 Fix T89204: slow repeated rendering with GPUOffscreen.draw_view3d.
Reviewed By: fclem
Differential Revision: D13235
2021-11-23 14:08:38 +01:00
6ab3349bd4 Documentation: Remove deprecated glColor* from bgl module.
glColor isn't supported but still part of the documentation. This
patch removes the glColor from the documentation.

Ref {T93315}
2021-11-23 13:03:12 +01:00
cf299bee80 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-23 13:02:25 +01:00
3e65bb86f9 Cleanup: fix clang-tidy warnings
Fix clang-tidy warnings introduced by a recent commit on the release
branch.

No functional changes.
2021-11-23 13:02:00 +01:00
f392ce50c4 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-23 12:39:26 +01:00
cd2849c89b Asset Browser: add operator for installing asset bundles
Add an operator "Copy to Asset Library" for installing asset bundles
into already-existing asset libraries.

The operator is shown when:
- the "Current File" library is selected,
- the blend file name matches `*_bundle.blend`, and
- the file is not already located in an asset library.

The user can select a target asset library, then gets a "Save As"
dialogue box to select where in that library the file should be saved.
This allows for renaming, saving in a subdirectory, etc.

The Asset Catalogs from the asset bundle are merged into the target
asset library.

The operator will refuse to run when external files are referenced. This
is not done in its poll function, as it's quite an extensive operator
(it loops over all ID datablocks).

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D13312
2021-11-23 12:29:44 +01:00
605cdc4346 BKE LibLink/Append: Add mechanism for external code to loop over link/append context items.
Will be required for python's `bpy.data.libraries.load()` refactor.
2021-11-23 12:18:37 +01:00
0452a04f1a BKE link/append: Add optional blendfile handle to libraries.
This enables calling code to deal with the blendfile handle themselves,
BKE_blendfile_link then just borrows, uses this handle and does not
release it.

Needed e.g. for python's libcontext system to use new
BKE_blendfile_link_append code.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-23 12:17:16 +01:00
6c8f73b220 Cleanup: remove unnecessary "extern" 2021-11-23 12:05:50 +01:00
b9b98448a6 Cleanup: add missing pragma once 2021-11-23 12:00:11 +01:00
fbb4a7eb43 BKE link/append: Add optional blendfile handle to libraries.
This enables calling code to deal with the blendfile handle themselves,
BKE_blendfile_link then just borrows, uses this handle and does not
release it.

Needed e.g. for python's libcontext system to use new
BKE_blendfile_link_append code.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-23 10:38:51 +01:00
f657356062 Merge branch 'blender-v3.0-release' 2021-11-23 09:44:04 +01:00
b02ac2d8be Fix T93092: incomplete animation rendering of multi-layer exr composition
This was broken by rB0c3b215e7d5456878b155d13440864f49ad1f230.
The caching of loaded exr files needed some special treatment.

Differential Revision: https://developer.blender.org/D13313
2021-11-23 09:43:00 +01:00
84be741329 Fix T92654: missing padding in spreadsheet cells
This was probably broken by rB5c2330203e11e0d916960218b07d88d2193bf526.
For now just add the padding back in a spreadsheet specific way.

Differential Revision: https://developer.blender.org/D13315
2021-11-23 09:35:47 +01:00
6987060f70 Fix T93090: crash with data transfer modifier and geometry nodes
There was a missing normals layer that was requested by the data transfer
modifier from the target object. The normal layer was correctly added to
the target object. However, it never reached the data transfer modifier
because the mesh was copied in `BKE_object_get_evaluated_mesh`
(in the call to `get_mesh_for_write`) and the copy does not include the normals
layer.

The solution is to not use `get_mesh_for_write` here which was only used
because `BKE_object_get_evaluated_mesh` returns a non-const `Mesh *`.
Mid term, it should actually return a `const Mesh *` to avoid the confusion.

Differential Revision: https://developer.blender.org/D13319
2021-11-23 09:32:12 +01:00
28870a8f89 Cleanup: Use new CollectionRef::empty() method
Use the new CollectionRef::empty() method in all locations where
appropriate.

Differential Revision: https://developer.blender.org/D13276
2021-11-22 23:47:26 -08:00
59754ef0b2 Cleanup: silent clang-tidy warning NULL vs nullptr. 2021-11-23 08:39:26 +01:00
Peter Fog
34370d9fdf VSE: Add drag and drop handler for preview area
For some users, dropping assets into preview area may be more practical
due to space constraints or it may be just more intuitive.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D13311
2021-11-23 05:40:08 +01:00
Peter Fog
b42494cf6b VSE: Support drag and drop for datablocks
For using the Outliner and/or the Asset Browser as scene independent
tools to organize a/v source material is necessary for the users to be
able to drag and drop data blocks into the VSE. This was also an
unfulfilled design target for the Outliner Gsoc project.

Datablocks won't be used directly. Path to file will be passed to strip
add operator instead.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D13304
2021-11-23 05:39:10 +01:00
d1a4e043bd Merge branch 'blender-v3.0-release' 2021-11-23 00:57:15 +01:00
Sayak Biswas
f749506163 Fix T93244: Cycles HIP not working with multi GPU rendering
Use the correct device function (hipDeviceGet) for multi GPU setups, instead
of hipGetDevice which just returns the default device.

Differential Revision: https://developer.blender.org/D13323
2021-11-23 00:55:56 +01:00
8600d4491f Fix: Const warning in editmesh_knife.c
Fixes a warning caused by freeing a const pointer.
This commit removes the const modifier.

Differential Revision: https://developer.blender.org/D13321
2021-11-22 23:40:21 +01:00
456d5e14b8 Merge branch 'blender-v3.0-release' 2021-11-22 21:26:39 +01:00
481f032f5c Assets: Generate light preview when making light object an asset
We already supported previews for lights, just didn't actually use them
when making a light object an asset. They were only used when making the
light data itself an asset.
2021-11-22 21:14:11 +01:00
34615cd269 Fix grayed out preview generation button for light objects
Mistake in e7bea3fb6e.

We should only skip preview generation for objects that don't support
preview rendering, not completely forbid accessing preview data of such
IDs.
2021-11-22 21:12:36 +01:00
48c2b4012f Merge branch 'blender-v3.0-release' 2021-11-22 21:06:10 +01:00
29681f186e Fix T93283: Cycles render error with CUDA CPU + GPU after recent optimization
BVH2 triangle intersection was broken on the GPU since packed floats can't
be loaded directly into SSE. The better long term solution for performance
would be to build a BVH2 for GPU and Embree for CPU, similar to what we do
for OptiX.
2021-11-22 21:02:46 +01:00
e2b736aa40 Fix part of T93278: transparent glass option not working with environment pass 2021-11-22 20:58:09 +01:00
Takahiro Shizuki
73b1ad1920 IME: Fix Multi-Window Duplicated First Character
Fix problem with duplicated initial character when initiating or
switching to new windows. This is done by updating our copies of state
and modes from the new window when it receives WM_IME_SETCONTEXT
message. This problem and fix are only for the Windows platform.
2021-11-22 10:44:34 -08:00
bfff9ca5f1 Fix confusing new Cycles UI terminology
* Rename "Auto Tiles" to "Use Tiling", it's not really automatic and
  confusing with the old auto tile size add-on.
* Rename "Adaptive" scrambling distance to "Automatic", to avoid confusion
  with adaptive sampling.
2021-11-22 10:44:34 -08:00
Takahiro Shizuki
ee0277271c IME: Fix Multi-Window Duplicated First Character
Fix problem with duplicated initial character when initiating or
switching to new windows. This is done by updating our copies of state
and modes from the new window when it receives WM_IME_SETCONTEXT
message. This problem and fix are only for the Windows platform.
2021-11-22 10:41:11 -08:00
cc6bcb53b2 Geometry Nodes: Rename legacy node files
This will be useful to solve some issues with unity builds,
which compiles different files together to improve build times.
2021-11-22 13:16:54 -05:00
5ad4ca4e02 CurveEval: Add total_length() and total_control_point_size() methods
Add the following methods to the CurveEval class:
total_length() : returns the total length of the curve without needing to
                    allocate a new array
total_control_point_size() : returns the total number of control points without
                    needing to allocate a new array
2021-11-22 12:07:59 -06:00
8a84a61f6b Fix confusing new Cycles UI terminology
* Rename "Auto Tiles" to "Use Tiling", it's not really automatic and
  confusing with the old auto tile size add-on.
* Rename "Adaptive" scrambling distance to "Automatic", to avoid confusion
  with adaptive sampling.
2021-11-22 18:37:47 +01:00
0129178376 UI: Use a map for block name lookups
Use a map to speed up search for UI block names.
Time to redraw the node editor was decreased from
around 75-120ms to 40-70ms in a tree with many
Geometry Nodes.

Differential Revision: https://developer.blender.org/D13225
2021-11-22 18:23:54 +01:00
55c82d8380 Fix T84493 issue with selection after boolean.
According to Blender selection rules, selections should be flushed
to containing elements. Added an EDMB_select_flush() after edit
mode booleans or intersects are done. Hopefully this doesn't break
any scripts that might have been depending on the old (broken) behavior.
2021-11-22 11:47:46 -05:00
1706bf7780 Merge branch 'blender-v3.0-release' 2021-11-22 17:32:23 +01:00
336ca6796a Fix T90308: Cycles crash copying memory from device to host
Happens when device runs out of memory and Cycles is moving some
textures to the host memory.

The delayed memory free for OptiX BVH was moving data from one
device_memory to another, leaving the original device memory in
an invalid state. This was ruining the allocation map in the CUDA
device which is using pointer to the device_memory.

This change makes it so the memory pointer is stolen from BVH
into the delayed memory free list.

Additionally, forbid copying and moving instances of device_memory
and added sanity checks in the device implementation.

Differential Revision: https://developer.blender.org/D13316
2021-11-22 17:26:59 +01:00
25c83c217b Cleanup: Clang-format of the HIP device implementation 2021-11-22 17:26:52 +01:00
059da44fbc BKE Link/Append: Use BLO's LibraryLink_Params.
This allows to reduce signature of several functions, and make it eaiser
to integrate more higher-level usages later on.

This should be a non-behavioral-change commit.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-22 17:14:21 +01:00
d7cf7d4048 Link/Append: Move main linking code (from WM) to use new instantiation code in BKE.
This removes the last main usage of BLO's instantiation code.

Also required some limited refactoring of BKE_blendfile_link_append's
instantiation to make it more modular, and usable by both linking and
appending code paths.

NOTE: This should be a non-behavioral change commit.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.
2021-11-22 16:55:36 +01:00
fe274d91a1 Link/Append: Move most of core link/append code from WM to new BKE_blendflie_link_append module.
This will allow to expose all those advanced features of the WM
operators to other parts of the code, like the python library context
manager, copy/paste code, etc.

This is expected to be a strictly no-behavioral-change commit.

Part of T91414: Unify link/append between WM operators and BPY context
manager API, and cleanup usages of `BKE_library_make_local`.

Maniphest Tasks: T91414

Differential Revision: https://developer.blender.org/D13222
2021-11-22 16:52:17 +01:00
9c2a4d158c Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-22 16:47:50 +01:00
875f24352a Material Preview: Fix Sphere object (squared UV and poles)
A good sphere preview material has a 1:1 UV ratio (so we see squares as
least distorted as possible), as well as good poles.

Square UV:
The original sphere expected a 2:1 panorama to be mapped to it. This
patch changes that (I scaled Y by 0.5) so that square textures look ok.

Poles:
The original sphere had a low initial resolution, so no ammount of
subdivision would fix the poles.

The sphere has a subdivision modifier with 0 resolution. Later (3.1?) I
want to try to change the resolution on-the-fly based on whether the material
has a displacement map.

Old sphere (1.9K vertices):
{F11845752, size=500px}

New sphere (2.0K vertices):
{F11845710, size=500px}

Differential Revision: https://developer.blender.org/D13309
2021-11-22 16:46:49 +01:00
Jeroen Bakker
0624235900 Moviecache: Fix potential memory corruption.
`IMB_moviecache` is implemented as a singleton. When destructing the
singleton via `IMB_moviecache_destruct` it will not be created anymore
resulting inusage of unallocated memory and potentional memory
corruption.

When running blender this doesn't happen, but when creating images in
test cases the moviecache should be able to be recreated after it is
destroyed.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13287
2021-11-22 15:52:30 +01:00
be876b8db6 Painting: Performance curve masks.
This patch separates the static-part from the dynamic-part when
generate brush masks. This makes the generation of brush masks 2-5 times
faster depending on the size of the brush.

More improvements can be done, this was just low hanging fruit.
2021-11-22 15:36:03 +01:00
178947dec3 Merge branch 'blender-v3.0-release' 2021-11-22 09:34:51 -05:00
Henrik Dick
819b9bdfa1 Fix T92631: Fix negative thickness regression in complex solidify
This regression was introduced by D11832, but there was problems before
that as well. I seem to have missed it in review. See the differential
revision for a screenshot of the difference.

Differential Revision: https://developer.blender.org/D13216
2021-11-22 09:33:49 -05:00
77ddc6e350 Fix T93250: Crash in spreadsheet tree view after recent commit
It seems that update_from_old assumed there would be an old
tree view available in the old block. This works for the asset browser
because the tree is always drawn, but for the spreadsheet that depends
on having an active object, which isn't necessarily always true.

Differential Revision: https://developer.blender.org/D13301
2021-11-22 08:47:02 -05:00
7e8f9213e9 Merge branch 'blender-v3.0-release' 2021-11-22 13:49:37 +01:00
7b09213f2f Fix T93198: Frame Selected in greasepencil curve editing does not work
Was not taking into account curve points at all.

Maniphest Tasks: T93198

Differential Revision: https://developer.blender.org/D13281
2021-11-22 13:42:00 +01:00
9b6f3d2d0a Cleanup: Removed unused code in curve mask creation.
Generating curve mask for 2d texture painting had some hard-coded
parameters that eventually weren't used in the algorithm (hardness and
rotation of the brush). This patch removes these parameters.
2021-11-22 11:22:58 +01:00
9bbb5f5a6a Painting: migrated curve mask generation to CPP.
Curve mask generation is done during 2d texture painting. There are some
performance issues in this part of the code. Before addressing those we
move the code to CPP.
2021-11-22 10:46:33 +01:00
29f6ec56e6 Cleanup: Make parameter const (BKE_brush_curve_strength_clamped). 2021-11-22 10:46:33 +01:00
0b246ed813 Revert "Fix (unreported) broken handling of constraints reordering with liboverride."
This reverts commit 6eaa69c66c.

Committed by nistake, sorry for the noise.
2021-11-22 10:39:20 +01:00
31864a40ba Cleanup: use simple data member instead of callback
This really doesn't have to be a callback currently, since it is always
the same `CPPType` for a socket type.
2021-11-22 10:18:08 +01:00
c850189adf Cleanup: make naming more consistent 2021-11-22 09:48:36 +01:00
db20837c3a Merge branch 'blender-v3.0-release' 2021-11-22 09:32:59 +01:00
6c16bb2706 Fix broken NLA RNA code after own rBfa6a913ef19c.
Thanks to @scurest for noticing this mistake!
2021-11-22 09:31:59 +01:00
6eaa69c66c Fix (unreported) broken handling of constraints reordering with liboverride.
New drag&drop reordering code would call constraints reordering operator
with the generic context, and not the one from the panel's layout.
missing the "constraint" member which is mandatory for poll function to
properly deal with override vs. local constraints.

This commit fixes it by generating a temp bContextStore in the panel
re-ordering callback.

NOTE: this fix will have to be extended to modifiers (which happen to
work currently because they have an 'active' status), and gpencil
modifiers (which are also broken currently).

Differential Revision: https://developer.blender.org/D13291
2021-11-22 09:28:27 +01:00
fb470c256a Fix T93256: Instances to points node broken after recent commit
When 97533eede4 added the instance domain, it didn't change
the domain that instance attributes are read from in this node.
2021-11-21 11:37:35 -05:00
873f6148ad Functions: remove test for dynamic name
This was broken in rB6ee2abde82ef121cd6e927995053ac33afdbb438.
2021-11-21 13:08:23 +01:00
940e6525c7 Functions: fix compile error in tests 2021-11-21 13:06:05 +01:00
15011e0b70 Functions: use static string for parameter names
The idea behind this change is the same as in
rB6ee2abde82ef121cd6e927995053ac33afdbb438.

A `MultiFunction::debug_parameter_name` method could be
added separately when necessary.
2021-11-21 12:57:34 +01:00
6ee2abde82 Functions: use static names for multi-functions
Previously, the function names were stored in `std::string` and were often
created dynamically (especially when the function just output a constant).
This resulted in a lot of overhead.

Now the function name is just a `const char *` that should be statically
allocated. This is good enough for the majority of cases. If a multi-function
needs a more dynamic name, it can override the `MultiFunction::debug_name`
method.

In my test file with >400,000 simple math nodes, the execution time improves from
3s to 1s.
2021-11-21 12:48:07 +01:00
d455eadcd8 Cleanup: Move menu search template to C++
This allows the use of better/more readable data structures,
and will also make some refactors to the search button easier.
The build completed on the buildbot for all platforms.
2021-11-20 16:30:53 -05:00
b3ee9f44cf Merge branch 'blender-v3.0-release' 2021-11-20 18:00:46 +01:00
1b2ee3cf20 Fix T92090: Eevee crash with Intel HD 4000 and macOS 10.15.7
A recent security update to macOS 10.15.7 causes crashes when using Eevee and
various other 3D viewport features. It appears that glGenerateMipmap is
broken, causing a crash whenever its commands are flushed/submitted to the GPU.

Ideally this would be fixed in a driver update, however it's unlikely this will
happen. Earlier macOS versions have been receiving security updates for 2 years,
and that window has just passed for 10.15. Further, computers with these GPUs
can't upgrade to a newer macOS version.

As a workaround, disable mipmaps on these GPUs, by setting the mipmap max level
to 0 and not calling glGenerateMipmaps. Effects like depth of field also use
mipmaps, but fill in the mip levels by other means. In those cases we keep the
mipmap level.

Differential Revision: https://developer.blender.org/D13295
2021-11-20 17:50:05 +01:00
e949ac0bfc Cleanup: unset 'FILE_ENTRY_PREVIEW_LOADING' at the end
Although this function only runs on the main thread, it seems safer to
clear the flag only after setting the result.
2021-11-20 10:34:29 -03:00
59ffe1c5b1 Merge branch 'blender-v3.0-release' 2021-11-20 14:05:26 +01:00
Sayak Biswas
f2bb42a095 Fix T92984: Cycles HIP crash with smoke volumes
This fixes the the app crash happening when trying to render smoke as a dense
3D texture. The changes are related to matching up hipew with the actual HIP
headers.

Differential Revision: https://developer.blender.org/D13296
2021-11-20 14:02:38 +01:00
3d447b6335 Merge branch 'blender-v3.0-release' 2021-11-20 12:47:31 +01:00
b20997cb34 Fix T93194: greasepencil channel lists ignoring collection visibility
Same fix as rB0a3b4d4c64f1, but this time for greasepencil.

To repeat: dopesheet in greasepencil mode was ignoring the temporariy
visibility flag of collections. As a result, even though the dopesheet
was supposed to show animation data of visible greasepencils only was
still showing such data of greasepencils that were hidden by hiding
their collection.
2021-11-20 12:31:33 +01:00
3baaab15fc Cleanup: Else after return 2021-11-19 23:48:51 -05:00
411261fb32 Merge branch 'blender-v3.0-release' 2021-11-20 01:45:06 -03:00
092df87534 Fix error in rBfb0ea9
There is no need to multiply the "dash_width" by `UM.pixel size` since the "viewport_size" is already being divided by the DPI.

Ref {rBfb0ea9}
2021-11-20 01:44:35 -03:00
15ecd47b96 Geometry Nodes: Instance attributes in Transfer/Capture nodes
Updates the Transfer Attributes and Capture Attributes nodes
to support attributes from instances.

Differential Revision: https://developer.blender.org/D13292
2021-11-19 23:40:08 +01:00
01df48a983 Refactor: Port spreadsheet data set to UI tree view
This patch removes a bunch of specific code for drawing the spreadsheet
data set region, which was an overly specific solution for a generic UI.
Nowadays, the UI tree view API used for asset browser catalogs is a much
better way to implement this behavior.

To make this possible, the tree view API is extended in a few ways.
Collapsibility can now be turned off, and whether an item should
be active is moved to a separate virtual function.

The only visual change is that the items are now drawn in a box,
just like the asset catalog.

Differential Revision: https://developer.blender.org/D13198
2021-11-19 17:36:11 -05:00
a0780ad625 Fix: Exception in tree view code in new case
This isn't a problem in 3.0 or master, but I'm porting the spreadsheet
data set region to a tree view and ran into this. This line needs to
whether the function is empty before calling it.

Differential Revision: https://developer.blender.org/D13197
2021-11-19 17:28:08 -05:00
cfbc9df60e Cleanup: Use canonical variable name
All `ARegion` variables should be called `region` unless there is
a good reason not to, since that is the convention.
2021-11-19 16:10:37 -05:00
217d0a1524 Cleanup: Use vector instead of linked list 2021-11-19 15:57:31 -05:00
51a7961e09 Cleanup: Simplify node editor link dragging storage
Now that `node_intern.hh` is a C++ header, we can use C++ types
there. This patch replaces the linked list of dragged links with a
vector. Also, the list of drag operator custom data, `nldrag`, doesn't
seem to need to be a list at all, so I just made it a unique pointer.

Differential Revision: https://developer.blender.org/D13252
2021-11-19 15:36:32 -05:00
c3fed4d463 Merge branch 'blender-v3.0-release' 2021-11-19 16:57:33 -03:00
fb0ea94c63 Fix T85855: F-curves too thin on Mac
Use the `GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR` shader instead of `GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR`.
This is just a partial solution as "protected" fcurves still use the dashed shader.

Differential Revision: https://developer.blender.org/D13290
2021-11-19 16:57:05 -03:00
50ad0e15fe Merge branch 'blender-v3.0-release' 2021-11-19 19:24:55 +01:00
00e4d665f4 Fix T91838 Crash when toggling edit mode on object with geometry node modifier, but only if the instanced objects material has a normal map assigned.
This is only a workaround to avoid the crash. The underlying issue is left
unfixed.

New report for tracking the underlying issue is T93223.
2021-11-19 19:24:22 +01:00
fabd088067 Update splash for Blender 3.x development series
CC-BY Blender Studio https://studio.blender.org

Update the splash artwork for the daily builds (`master`) to
celebrate the beginning of a new major series in Blender.

The badges of the Development Fund membership levels have been removed for
a simpler design, and the font matches the one used elsewhere in blender.org
2021-11-19 18:39:14 +01:00
1222c45544 Fix: Use the instances domain in instance transform nodes
Instance attributes exist on the instance domain after rB97533eede44421,
so these fields should be evaluated on that domain.
2021-11-19 12:26:48 -05:00
ba8dd0f24f Spreadsheet: Support instances component viewer node columns
After rB97533eede444217b, instances have their own attribute domain,
but the spreadsheet code worked under the assumption that the component
used the point domain. Old files have to re-select the instances data
source to make it properly active
2021-11-19 12:21:54 -05:00
06a2e2b28c Merge branch 'blender-v3.0-release' 2021-11-19 18:05:17 +01:00
ef687bd7c2 Merge branch 'blender-v3.0-release' 2021-11-19 12:00:35 -05:00
97533eede4 Geometry Nodes: Support custom instance attributes
Adds an attribute provider for instance attributes.
A new domain `ATTR_DOMAIN_INSTANCE` is implemented.
Instance attributes are not yet realized correctly.

Differential Revision: D13149
2021-11-19 17:53:48 +01:00
1b686c60b5 Fix T93046: Cycles world volume rendering very slow in OptiX with some scenes
With very long ray distance, OptiX ends up traversing many BVH nodes due to
a feature that improves precision. However this causes very slow rendering.

We now avoid generating such long rays by rejecting the few samples that have
long ray distances and very low probability of being generated. This should not
meaningfully affect render results.

Thanks to Sergey and Patrick for the investigation.
2021-11-19 17:42:22 +01:00
0f1a200a67 Fix T92682: EEVEE motion blur crash with curve objects
After rBb9febb54a492, the evaluated mesh from a curve is now presented
to render engines as a separate mesh object, but some code still assumed
that a curve object itself could have an evaluated mesh. However, this is
still true for surface objects and metaballs, which don't
use geometry sets yet.

Differential Revision: https://developer.blender.org/D13272
2021-11-19 11:36:29 -05:00
9e3a913b35 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-19 16:39:28 +01:00
1a1ddcb5e2 Asset Browser: don't display linked-in asset datablocks
Datablocks marked as asset, linked from another file, were shown in the
"Current File" asset library. This is now resolved.
2021-11-19 16:29:25 +01:00
ec71054a9b Merge branch 'blender-v3.0-release'
Conflicts:
	source/blender/blenkernel/BKE_blender_version.h
	source/blender/blenloader/intern/versioning_300.c
2021-11-19 16:10:28 +01:00
06ead314b6 Asset Preferences: disallow single file as asset library
Asset libraries should be directories on disk. By manually entering a
file path it was possible to have a single blend file as asset library,
but that was not a designed-for situation, and it doesn't play well
with the asset catalog system.
2021-11-19 16:08:55 +01:00
330290d2a8 Cleanup: typos in comments 2021-11-19 15:55:47 +01:00
33c5e7bcd5 LibOverrides: Refactor how diffing of RNA collections is handled.
Original implementation was a quick prototype which should have never
landed as-is in master. It had very limiting constraints and did not
allow for any real further development.

This commit fixes the internal implementation to make more sensible,
maintainable and evolutive.

NOTE: This commit introduces another forward-incompatibility in the
Blender file format: Files saved after this commit won't open properly
in older versions of blender regarding local inserted constraints or
modifiers into overrides of linked data.

NOTE: Technical details: The 'anchor' item name/index is now stored in
`subitem_reference_` members, and the actual 'source' item name/index is
stored in `subitem_local_` members of the override property operation
data.
Previously, only the `subitem_local_` members were used, storing the
anchor item name/index, and assuming the 'source' item was always the
next in the list.

Milestone I of T82160.

Maniphest Tasks: T82160

Differential Revision: https://developer.blender.org/D13282
2021-11-19 15:41:53 +01:00
d6ea881a74 BLI_listbase: Add utils to search from string or index.
If a valid matching string is found, return that item, otherwise
fallback to the item matching the given index, if any.

This will be useful in RNA override code, and potentially other
areas where data in lists can be referenced by their names or indices.
2021-11-19 15:41:36 +01:00
d7aaa145c6 Merge branch 'blender-v3.0-release' 2021-11-19 15:30:54 +01:00
04ec36f677 Fix T87912: use session id instead of name to identify dropped object
The old code did not work when there were multiple ids with
the same name (which can happen when ids are linked in).
The solution is to use the session ids instead. Those are different
even when two ids have the same name.

Differential Revision: https://developer.blender.org/D11116
2021-11-19 15:28:44 +01:00
0852805ed7 Merge branch 'blender-v3.0-release' 2021-11-19 15:58:37 +02:00
a20e703d1a Fix T93184: Link color not used for custom sockets
D13044 allowed the link color overlay to be used with custom sockets.
This no longer works due to a condition that checks if the socket is
standard or not, which was in place to avoid bad indexing of the
std_node_socket_colors array. Since that array is no longer used, this
condition needs to be removed.

Differential Revision: https://developer.blender.org/D13274

Reviewed By: Hans Goudey
2021-11-19 15:55:58 +02:00
06691d1b21 Tests: disable Cycles volume test when WITH_MOD_FLUID is off 2021-11-19 13:21:48 +01:00
1b94c53aa6 Cleanup: fix typos in comments and docs
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D10447
2021-11-19 13:02:16 +01:00
7d5ef64bfb Cleanup: fix typos in comments and docs
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D13264
2021-11-19 12:46:49 +01:00
fa6a913ef1 LibOverride: Add read-only flags accessors for 'local override' status.
Constraints, modifiers and NLA tracks can now report from RNA whether
they are defined as comming from the override's reference linked data,
or are local to the override.
2021-11-19 12:09:28 +01:00
83e245023c Fix (unreported) wrong behavior of constraints in liboverrides.
All constraints were 'made local', including the ones comming from the
reference linked object.
2021-11-19 12:09:28 +01:00
eb071c9ff4 Merge branch 'blender-v3.0-release' 2021-11-19 10:16:30 +01:00
de3fda29c7 Fix T93054: crash when deleting a missed linked file
This is a bit similar to rBb7260ca4c9f4b7618c9c214f1270e31d6ed9886b.
Sometimes a group node may not reference a node group
because it was linked and can't be found.
2021-11-19 10:15:58 +01:00
48e64a5fb5 Merge branch 'blender-v3.0-release' 2021-11-19 10:09:29 +01:00
4ea6b4ba84 Fix crash in VSE versioning code from recent commit
Caused by {rB4d09a692e22a}.
Greenlit by @sergey in chat.
2021-11-19 10:05:18 +01:00
992634427e Nodes: add bf_nodes_geometry library
Separating geometry nodes into a new library will make it
easier to improve compile times with features like unity
builds and precompiled headers.

Differential Revision: https://developer.blender.org/D13261
2021-11-19 09:09:14 +01:00
b8dc845e57 Merge branch 'blender-v3.0-release' 2021-11-19 06:22:47 +01:00
4d09a692e2 Fix T92847: Meta-strip corrupt
Offsets for meta strip were invalid. No steps to reproduce the issue are
available, but it is quite possible that there are files with incorrect
state after issues with meta strips were fixed.

Ensure correct offsets for meta strips in versioning code.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13257
2021-11-19 06:12:09 +01:00
5ed3a5d023 Cleanup: Add an empty() method to RNA's CollectionRef class
The existing RNA CollectionRef class only offers a length() operation
which is sometimes used for checking if the collection is empty. This is
inefficient for certain collection types which do not have a native
length member; the entire list is iterated to find the count.

This patch creates an explicit empty() method to be used in such cases
for better semantics. Additionally, many collection types will behave
more efficiently when using the new method instead of checking length.

Making use of the new method will follow separately.

Differential Revision: https://developer.blender.org/D12314
2021-11-18 14:32:56 -08:00
3f288e9414 Node Editor: Change minimum zoom
Now with Geometry Nodes in Blender,
trees can become much bigger than before.
This changes the minimum zoom value in the node editor.

Differential Revision: https://developer.blender.org/D13254
2021-11-18 21:24:55 +01:00
b2d37c35d0 Node Editor: Skip socket drawing on low zoom
Socket drawing can be heavy with many nodes.
This patch skips drawing them on scale < 0.2
when they are barely visible anyway.

Differential Revision: https://developer.blender.org/D13255
2021-11-18 21:21:10 +01:00
167ee8f2c7 Merge branch 'blender-v3.0-release' 2021-11-18 19:37:48 +01:00
fd2a155d06 Fix T91797: Cycles volume rendering artifact with overlapping volumes
With the new volume rendering code this was no longer accurate, we always
need to use a new dimension for the next volume segment.
2021-11-18 19:27:37 +01:00
f190f2d267 Revert fixes 2021-11-18 14:19:59 -03:00
0c33411bdd Revert "Revert "Revert "Revert "Allow navigating while transforming""""
This reverts commit 717a971035.
2021-11-18 14:15:08 -03:00
ea42c1a22e Revert "Revert "Revert "Revert "Adjust snap source drawing when adding multiple snap points""""
This reverts commit b8bf40ed4b.
2021-11-18 14:14:57 -03:00
f61a73093b Revert "Revert "Revert "Revert "Transform: interactive mode for editing a 'Snap Source'""""
This reverts commit 701f2dfd5b.
2021-11-18 14:14:51 -03:00
ada6742601 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-18 17:58:26 +01:00
701f2dfd5b Revert "Revert "Revert "Transform: interactive mode for editing a 'Snap Source'"""
This reverts commit 25fa6c74b9.
2021-11-18 13:55:24 -03:00
b8bf40ed4b Revert "Revert "Revert "Adjust snap source drawing when adding multiple snap points"""
This reverts commit c7f9a782aa.
2021-11-18 13:55:21 -03:00
717a971035 Revert "Revert "Revert "Allow navigating while transforming"""
This reverts commit 2a9cfdac7e.
2021-11-18 13:55:17 -03:00
Germano Cavalcante
2a9cfdac7e Revert "Revert "Allow navigating while transforming""
This reverts commit 5e6fdaa07f.
2021-11-18 13:52:39 -03:00
c7f9a782aa Revert "Revert "Adjust snap source drawing when adding multiple snap points""
This reverts commit 77df32548b.
2021-11-18 13:52:30 -03:00
Germano Cavalcante
25fa6c74b9 Revert "Revert "Transform: interactive mode for editing a 'Snap Source'""
This reverts commit 805181bffa.
2021-11-18 13:52:18 -03:00
7c4e4d605c Pose Library: clarify apply/blend operator names
The old names had "{verb} Pose Library Pose"; they are now named
"{verb} Pose Asset", which is shorter & clearer.
2021-11-18 17:52:17 +01:00
3531021d1b Cleanup: Simplify declarations in C++ header
Using `struct` everywhere is unnecessary in C++, and the typedefs
are also unnecessary.
2021-11-18 11:46:44 -05:00
12fc395436 Fix T93152: Cycles baking multiple selected object to active not working 2021-11-18 17:43:27 +01:00
Germano Cavalcante
805181bffa Revert "Transform: interactive mode for editing a 'Snap Source'"
This reverts commit f19bd637e2.
2021-11-18 13:42:45 -03:00
77df32548b Revert "Adjust snap source drawing when adding multiple snap points"
This reverts commit cb3ba68ec4.
2021-11-18 13:42:36 -03:00
Germano Cavalcante
5e6fdaa07f Revert "Allow navigating while transforming"
This reverts commit 1d1855e95f.
2021-11-18 13:42:31 -03:00
Germano Cavalcante
1d1855e95f Allow navigating while transforming
This feature has been desired for some time:
- https://rightclickselect.com/p/ui/Tqbbbc/allow-navigating-while-transforming (See comments);
- D1583;
- T37427;

In short, blocking navigation during transform limits the user to move the object only to visible areas within the screen and hinders the allocation of objects within closed meshes.

The node editor is also impaired because some nodes are far between them and the connectors are too small.

The only disadvantage of this patch (as I see it) is the conflict with the existing key map:
MIDDLEMOUSE:
- enable axis constrain in 3D view;

WHEELDOWNMOUSE, WHEELUPMOUSE, PAGEUPKEY, PAGEDOWNKEY:
- change the threshold of the proportional edit;

So the patch solution was to change these keymaps:
- MIDDLEMOUSE to Alt+MIDDLEMOUSE;
- WHEELDOWNMOUSE, WHEELUPMOUSE, PAGEUPKEY, PAGEDOWNKEY to Alt+(corresponding key);

When you use this new keymap for the first time in the proportional edit, it may seem strange due to the custom of using it (both in View2D and View3D).
But quickly the user gets used to it.

Alternatively we can add an option to the user preferences ([] Allow navigating while transforming). (I'm not much fan of this option).

The patch was done on branch2.8. But maybe it's a good idea to apply it to 2.79

Differential Revision: https://developer.blender.org/D2624
2021-11-18 13:14:18 -03:00
cb3ba68ec4 Adjust snap source drawing when adding multiple snap points 2021-11-18 13:14:18 -03:00
Germano Cavalcante
f19bd637e2 Transform: interactive mode for editing a 'Snap Source'
This patch implements part of what was stated in {T66484}, with respect to `Base Point`.

## Introduction

The snapping feature of the transform tools has a variety of applications:
- Organization of nodes.
- Positioning of frames in precise time units.
- Retopology with snap to face
- Creation of armatures with bone positioning through the snap to volume
- Precise positioning of 3D or 2D objects in the surrounding geometry (CAD modeling)

The goal of this document is to make it more powerful for precision modeling and still supporting the old use cases without extra complexity.
The main topic addressed here is the introduction of a **interactive mode for setting a snap source** (See terminology).

## Terminology

* **Snap Source**: 3d coordinate * we want to snap from. (Currently defined by the `Snap With` options: `Closest`, `Center`, `Median` and `Active`).
* **Snap Target**: 3d coordinate*  we want to snap to. (Vertices, Edges, Faces, Grid...)

## Interactive Mode for Editing a Snap Source

Currently the fixed snap point can only be obtained through the `Snap With` options. So it's a little tricky for the user to define a snap source point having so much geometry on an object.
Because of this, the user needs to resort to impractical solutions to get a point in the geometry.
See example of an impractical use:
{F11714181, layout=left, width=960, alt="The user used the cursor (which can be snapped) to choose the snap origin point."}
The user used the cursor (which can be snapped) to choose the snap source point.

While it is possible to work around this current limitation, it is important to reduce the number of steps and allow the user to set a snap source point through an optional interactive mode during a transformation.

The proposed solution is to be able to move the current snap source point through a modal modifier activated with a key (eg. B).
The snap source point can thus "snap" to the elements in the scene (vertex, mid-edge, Lamp, …) during this mode.
{F9122814, layout=left, width=960, alt="Base Point Snap, example of transform operation via the shortcut (not the tool). After pressing g and the snap base change shortcut (e.g., shift + ctrl) the user set the base point. The base point is then visible until the end of the operation. The z axis constrains the final position."}

## Implementation Details

- The feature will only be available in 3D View.
- The feature will only be available for `Move`, `Rotate` and `Scale` transform modes.
- The snap source editing will be enabled with a single click on the modifier key (B).
- Having a snap point indicated, the new snap origin point will be confirmed with the same buttons that confirms the transformation (but the transformation will not be concluded).
- The snap source editing can be canceled with the same key that activated it (B).
- If the transformation is done with "release_confirm" (common for gizmos), the new feature cannot be enabled.
- During the transformation, when enabling the feature, if the snap option is turned off in the scene, the snap will be forced on throughout the rest of the transformation (unless interactive mode is canceled).
- During a transformation, if no snap target is set for an element in the scene (Vertex, Grid...), the snap targets to geometry Vertex, Edge, Face, Center of Edge and Perpendicular of Edge will be set automatically.
- Snap cannot be turned off during the snap source editing.
- Constraint or similar modification features will not be available during the snap source editing.
- Text input will not be available during the snap source editing.
- When adding multiple snap points (A) the new prone snap source point will be indicated with an "X" drawing.
{F11817267}

Maniphest Tasks: T66484

Differential Revision: https://developer.blender.org/D9415
2021-11-18 13:14:18 -03:00
f0be276514 Fix T93082: Cycles baking not handling transparency correctly
For baking, replace transparent BSDF with holdout for baking. This ensure no
objects behind are baked, and that the baked image has alpha.
2021-11-18 17:13:16 +01:00
ed91e759d1 Fix Cryptomatte accurate option showing for Cycles, only needed for Eevee 2021-11-18 17:13:16 +01:00
67b4eecac9 Cleanup: Use const arguments 2021-11-18 11:03:18 -05:00
Nikhil Shringarpurey
dd31b8bd50 UI: Use full word "Start" instead of "Sta"
Differential Revision: https://developer.blender.org/D13098
2021-11-18 10:45:10 -05:00
5816eb4c56 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-18 16:36:11 +01:00
8d1357ea6b Pose Library: add conversion button to old poselib UI
Add the "Convert Old Pose Library" operator to the old pose library (in
the Armature properties editor). This makes it more discoverable; before
it only was available in the Action editor.
2021-11-18 16:35:56 +01:00
beb9e332ca Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-18 16:21:17 +01:00
31afa1bb9a Asset tags: include partial tag matches
When filtering the asset browser, also include results that have partial
tag matches. So searching for "xite" will include results tagged with
"excited".

This brings the tag filtering in line with other search boxes in
Blender. Later we might want to provide users with more options for
prefix-only ("excite" would match "excited", but "xited" would not) or
only exact matches.
2021-11-18 16:21:00 +01:00
0624acf088 Fix T92442: undo removal of Eevee cryptomatte accurate mode option
The Cycles accurate mode was removed, but the Eevee option for this has
a different meaning and should not have been removed. The Eevee accurate
makes cryptomatte accumulate for every sample, which Cycles has always
done regardless of any option.
2021-11-18 15:59:08 +01:00
b926f54f3c Fix: error when materializing curve point attribute
Differential Revision: https://developer.blender.org/D13271
2021-11-18 15:28:04 +01:00
d1f944c186 Cycles: declare constants at program scope on Metal
MSL requires that constant address space literals be declared at program
scope. This patch moves the `blackbody_table_r/g/b` and `cie_colour_match`
constants into separate files so they can be declared at the appropriate scope.

Ref T92212

Differential Revision: https://developer.blender.org/D13241
2021-11-18 14:38:05 +01:00
d19e35873f Cycles: several small fixes and additions for MSL
This patch contains many small leftover fixes and additions that are
required for Metal-enablement:

- Address space fixes and a few other small compile fixes
- Addition of missing functionality to the Metal adapter headers
- Addition of various scattered `__KERNEL_METAL__` blocks (e.g. for
  atomic support & maths functions)

Ref T92212

Differential Revision: https://developer.blender.org/D13263
2021-11-18 14:38:02 +01:00
c0d52db783 Merge branch 'blender-v3.0-release' 2021-11-18 14:33:43 +01:00
f71813204c Cycles: Don't tile if image area fits into tile area
Previously the check was done based on dimension of image and if any
of dimensions were larger than tile size tiling was used.

This change makes it so that if image does not exceed number of pixels
in the tile no tile will be used. Allows to render widescreen images
without tiling.

Differential Revision: https://developer.blender.org/D13206
2021-11-18 14:27:45 +01:00
3ad2bf1327 Cycles: Fix command line render overshooting time limit
The calculation based on preserving device occupancy was conflicting
with the fact that time limit needs to render less samples at the last
round of render work.

For example, rendering BMW27 for 30sec on i9-11900k was actually
rendering for almost a minute. Now the render time limit is respected
much more close.

Differential Revision: https://developer.blender.org/D13269
2021-11-18 14:27:45 +01:00
bd2e3bb7bd Fix T93045: Cycles HIP not rendering OpenVDB volumes
Build HIP kernels with NanoVDB, and patch NanoVDB to work with HIP.

This is a header only library so no rebuild is needed. The changes are being
submitted upstream to openvdb, so this patch should be temporary.

Thanks Thomas for help testing this.
2021-11-18 13:24:56 +01:00
2b63a76041 Merge branch 'blender-v3.0-release' 2021-11-18 11:53:46 +01:00
e5774282b9 Fix asset preview not showing up for current file data-blocks
For data-blocks from the current file, the image-buffer for dragging
wasn't set at all. This wasn't intentional, dragging things in the Asset
Browser should just always show the preview.
2021-11-18 11:47:21 +01:00
William Leeson
e1a3b697ec Merge branch 'blender-v3.0-release' to pick up D13262. 2021-11-18 09:41:11 +01:00
William Leeson
8c0370ef7b Fix T93102: Principled hair shader stack was built incorrectly
stack_assign_if was used in the middle of creating the shader value blocks.
Which caused stack variables to be inserted in the middle of the shader value data.
This resulted in the shader node data no being in sequential order. This was also
the case for the wave texture wave node.

Reviewed By: brecht

Maniphest Tasks: T93102

Differential Revision: https://developer.blender.org/D13262
2021-11-18 09:31:29 +01:00
Félix
9cf3d841a8 VSE: Add meta.separate() Python API function
This function can be used to "dissolve" meta strip anywhere in strip
hierarchy. This has same effect as `meta_separate` operator.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/T91005
2021-11-18 03:55:48 +01:00
f1f7a8b018 Merge branch 'blender-v3.0-release' 2021-11-18 03:03:13 +01:00
a182b05f07 Fix T90390: VSE Jump operator don't work during playback
Tag dependency graph `ID_RECALC_AUDIO_SEEK` update.
2021-11-18 02:59:50 +01:00
032ab0270d Merge branch 'blender-v3.0-release' 2021-11-18 02:23:17 +01:00
Andrea Beconcini
daaa43232d Fix T92445: Thumbnail height without overlay text
This patch changes the thumbnails' height used for image and movie
strips by choosing the proper size according to the VSE's text overlay
settings: i.e. thumbnails use the whole strip's height when no overlay
text is displayed; otherwise, some space is left for the overlay.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D13043
2021-11-18 02:14:11 +01:00
ceec400975 Merge branch 'blender-v3.0-release' 2021-11-18 01:40:37 +01:00
d8fd575af9 Fix T93154: Crash adding multiple movie strips
Some when adding multiple movies at once and only some of them have
audio track, this causes crash on NULL dereference. Issue was introduced
in bdbc7e12a0 to align sound and video properly.

Check if sound is present in movie file. If it's not, don't try to align
sound with video.
2021-11-18 01:32:06 +01:00
d6b5251572 Merge branch 'blender-v3.0-release' 2021-11-18 01:13:22 +01:00
b071083496 Fix T93166: Division by zero when drawing thumbnails
Caused by incorrect step calculation fo too short strips. For these,
step should be equal to strip length not 0.
2021-11-18 01:11:51 +01:00
fa7a6d67a8 Fix Cycles CUDA/HIP compiler error after recent changes 2021-11-17 19:56:18 +01:00
Sebastian Herholz
d9bc8f189c Cycles: add build option to enable a debugging feature for MIS
This patch adds a CMake option "WITH_CYCLES_DEBUG" which builds cycles with
a feature that allows debugging/selecting the direct-light sampling strategy.
The same option may later be used to add other debugging features that could
affect performance in release builds.

The three options are:
* Forward path tracing (e.g., via BSDF or phase function)
* Next-event estimation
* Multiple importance sampling combination of the previous two methods

Such a feature is useful for debugging light different sampling, evaluation,
and pdf methods (e.g., for light sources and BSDFs).

Differential Revision: https://developer.blender.org/D13152
2021-11-17 18:03:56 +01:00
063ad8635e Cycles: reduce triangle memory usage with packed_float3
Depends on D13243

Differential Revision: https://developer.blender.org/D13244
2021-11-17 17:29:41 +01:00
9937d5379c Cycles: add packed_float3 type for storage
Introduce a packed_float3 type for smaller storage that is exactly 3
floats, instead of 4. For computation float3 is still used since it can
use SIMD instructions.

Ref T92212

Differential Revision: https://developer.blender.org/D13243
2021-11-17 17:29:41 +01:00
89d5714d8f Build: match GCC and Clang float conversion warnings in Cycles 2021-11-17 17:29:41 +01:00
ea7efa5569 Merge branch 'blender-v3.0-release' 2021-11-17 15:41:32 +01:00
00a9617f92 Fix: wrong assert in geometry nodes evaluator
It only makes sense to check if all required outputs have been computed
if the node was executed at all.
2021-11-17 15:40:53 +01:00
c3422c48ad Cleanup: remove dummy multi function 2021-11-17 12:33:18 +01:00
e5f05bc7a6 Cleanup: Painting - reduce reallocation of same memory.
Curve mask is freed/allocated every time, but could still reuse the
previous allocated buffer when the diameter of the brush doesn't change.
2021-11-17 12:30:42 +01:00
f5dde382af Cleanup: use same function for updating internal links for all nodes
Previously, node types had a callback that creates internal links. Pretty
much all nodes used the same callback though. The exceptions are the
reroute node (which probably shouldn't be mutable anyway) and some
input/output nodes that are not mutable.

Removing the callback helps with D13246, because it makes it easier
to reason about which internal links are created and when they change.
In the future, the internal links should be part of the node declaration.
2021-11-17 11:52:54 +01:00
83a4d51997 Cleanup: Remove unused show_samples() device code in Cycles. 2021-11-17 11:16:48 +01:00
c2ab47e729 Cleanup: change node socket availability in a single place
This cleans up part of the code that still set the flag manually. Also, this
change helps with D13246 because it makes it easier to tag the node
tree as changed when the availability of a socket changed.
2021-11-17 11:11:28 +01:00
51b8e34fb7 LineArt: Improve certain edge cases in occlusion
This patch includes:
View vector fix for ortho back face.
Point on segment logic correction.
Better handling of boundary cases.

See review page for detailed description.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D13143
2021-11-17 14:31:12 +08:00
473be239c3 LineArt: Improve certain edge cases in occlusion
This patch includes:
View vector fix for ortho back face.
Point on segment logic correction.
Better handling of boundary cases.

See review page for detailed description.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D13143
2021-11-17 14:30:08 +08:00
e3c974b7e4 Merge branch 'blender-v3.0-release' 2021-11-17 05:43:34 +01:00
6e6123b40f Fix T93080: Crash on scrubbing with snapping
Sequencer wasn't initialized, snapping crashed on NULL dereference.
Add Null check.
2021-11-17 05:40:25 +01:00
ecad33f214 UI: Use ampersand instad of 'and' in labels
- When and is used in labels use ampsand
- When used in description use 'and'
2021-11-16 21:38:03 -05:00
61bffa565e Fix T90412: Inconsistency in mask strip color
This seems to be oversight in 271231f58e where strip color was
defined only for light theme.
2021-11-17 03:27:13 +01:00
f72dc00569 Merge branch 'blender-v3.0-release' 2021-11-17 03:12:19 +01:00
9bdf3fa5f0 Fix T91724: Strip height is too limited
This change was introduced in 997b5fe45d, to not display pixelated
thumbnails. However when VSE timeline height is made smaller, this
limits strip height.

Change limit, so one strip can occupy full height of VSE timeline
2021-11-17 02:45:53 +01:00
4c988eb3e1 Fix error with makefiles compilation
Use 'template' keyword to treat 'is' as a dependent template name
2021-11-16 20:46:33 -03:00
luzpaz
dea26253a0 cleanup: fix typos in comments and docs
Followup to https://developer.blender.org/D10288

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D10346
2021-11-16 18:45:10 -05:00
8290edefad Cleanup: Use bool instead of int 2021-11-16 17:20:31 -06:00
2f39b45e8c Merge branch 'blender-v3.0-release' 2021-11-16 17:50:24 -05:00
f829b86039 Cleanup: Correct copy paste error in comment
Mistake from rB2743d746ea4f38c098512f6dd6fc33d5a62429d3
2021-11-16 17:49:51 -05:00
93f26d652e Merge branch 'blender-v3.0-release' 2021-11-16 23:21:13 +01:00
fbf4fe6963 Fix missing Cycles implicit float/double conversion error with Clang
Since these are errors with GCC and Visual Studio.
2021-11-16 23:18:25 +01:00
1e4d1eb398 Fix another Linux build error with double and float comparison 2021-11-16 23:12:50 +01:00
59da22c309 Merge branch 'blender-v3.0-release' 2021-11-16 22:40:08 +01:00
b496c1c721 Cleanup: compiler warnings 2021-11-16 22:29:50 +01:00
3189171a94 Fix build error with strict double to float conversion 2021-11-16 22:25:24 +01:00
cf83719761 Geometry Nodes: Small improvements to object info node
This commit contains a few mostly-related changes to this node:
 -  Add a warning when retrieving the geometry from the modifier object.
 - Only create the output geometry when it is necessary.
 - Decompose transform matrices in a more friendly way.
 - Use default return callbacks like other newer nodes.

Differential Revision: https://developer.blender.org/D13232
2021-11-16 15:09:00 -06:00
c9fb08e075 Merge branch 'blender-v3.0-release' 2021-11-16 14:55:13 -06:00
f30e1fd2f0 Fix T93085: Incorrect geometry nodes modifier warning
It's valid for a node group connected to the modifier not to
have a geometry input, but I didn't consider that case
with the last change I made here, f3bdabbe24.

Differential Revision: https://developer.blender.org/D13231
2021-11-16 14:51:03 -06:00
25d30e6c99 Fix T92857: Deadlock in geometry nodes curve multi-threading
The spline code, especially Bezier splines, often make use of lazily
evaluation and caching. In order to do that, they use mutex locks.
When multi-threading, this can lead to problems. Further detail
can be found in rBfcc844f8fbd0d1.

To fix the deadlock, isolate the task before multi-threading
when holding a lock.

Differential Revision: https://developer.blender.org/D13229
2021-11-16 14:49:58 -06:00
cfd0e96e47 Fix T93125: Cycles wrong remaining render time with high number of samples
Avoid integer overflow.
2021-11-16 20:49:32 +01:00
7293c1b357 Fix T93106: Cycles SSS not working with normals pointing inside 2021-11-16 19:44:45 +01:00
Germano Cavalcante
9d7422b817 File Browser: Improve usage of threads in the creation of thumbnails
Due to asynchronous process, the preview for a given image may be
generated several times.

This regenerates many thumbs unnecessarily.

The solution is to add the `FILE_ENTRY_PREVIEW_LOADING` flag for file
entries that are still in the thread queue.

So this flag is checked not to redraw the thumb when it is still being
created on a different thread.

Differential Revision: https://developer.blender.org/D11150
2021-11-16 14:10:24 -03:00
917218269e Merge branch 'blender-v3.0-release' 2021-11-16 13:59:28 -03:00
1572c4d3d3 Fix T93011: Individual origins being used when pivot point is override
There should be a special `t->around` for this case, but for now let's
just avoid having the individual origins overlap.
2021-11-16 13:56:11 -03:00
bd37553850 Cleanup: better delimit member initialization
The initialization of `t->around` and `t->view` was scattered and with
duplicate code
2021-11-16 13:55:30 -03:00
0335df9384 Transform: better contextualize the status bar
`Remove Last Snap Point` should only be displayed when there is a Snap Point to be removed.
2021-11-16 13:39:10 -03:00
ba6427adfa Merge branch 'blender-v3.0-release' 2021-11-16 17:25:48 +01:00
b3529ecf0e Fix CUDA error when using tiny border in viewport
Need to clamp scaled render buffers window to be above zero
when applying resolution divider.
2021-11-16 17:25:18 +01:00
72ee62e0da Fix crash on freeing hair system
Fix a crash when a hair system's `ParticleSettings` ID datablock was
linked from another file but couldn't be found. This results in default
settings, with `type = PART_EMITTER`, where the particle data still has
a non-NULL `hair` pointer. Previously, copies of such a particle system
would NOT copy hair data for non-hair particle systems, hence the
pointer of the copy pointed to the original data, which got freed (at
least) twice upon closing the blend file.

This is now fixed by always copying the hair data, regardless of the
particle system type.

Reviewed by: mont29

Differential Revision: https://developer.blender.org/D13245
2021-11-16 17:18:01 +01:00
bee7a56687 Cleanup: document that MEM_dupallocN is NULL-safe
Add comment explaining `MEM_dupallocN` is NULL-safe, in that it returns
NULL when it receives a NULL pointer. This is currently true for both
implementations of the function (`MEM_lockfree_dupallocN` and
`MEM_guarded_dupallocN`), and will be expected of other implementations
as well.

No functional changes.
2021-11-16 17:11:45 +01:00
07af45eec5 Asset Browser: hide catalog debug info behind debug option
Add a new "experimental" debug option `show_asset_debug_info`, and use
that to determine the visibility of the active asset's catalog UUID and
simple name. Previously this was only determined by the "Developer
Extras" option, which meant it was visible in too many situations. It's
not really a "developer extra", and really just a debugging tool, so the
new option is more in line with its purpose.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D13242
2021-11-16 16:49:27 +01:00
Michael Jones
64003fa4b0 Cycles: Adapt volumetric lambda functions to work on MSL
This patch adapts the existing volumetric read/write lambda functions for Metal. Lambda expressions are not supported on MSL, so two new macros `VOLUME_READ_LAMBDA` and `VOLUME_WRITE_LAMBDA` have been defined with a default implementation which, on Metal, is overridden to use inline function objects.

This patch also removes the last remaining mention of the now-unused `ccl_addr_space`.

Ref T92212

Reviewed By: leesonw

Maniphest Tasks: T92212

Differential Revision: https://developer.blender.org/D13234
2021-11-16 13:42:23 +00:00
85ac9b8584 Merge branch 'blender-v3.0-release' 2021-11-16 14:39:51 +01:00
ce0d817bb7 UI: Fix hard to read text for drag disabled hints
In 499dbb626a, the background color of drag tooltips were changed so
text becomes more readable. But multiple people were touching the same
code, so the disabled hint tooltips didn't get the same tweak. They
would benefit from them even more, since the red text is even harder to
read on the transparent background than the regular, white text.
2021-11-16 14:37:20 +01:00
12a986c9b5 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-16 13:10:35 +01:00
c7a1e115b5 Tests: fix memory leak of GHOST system paths
Dispose of GHOST system paths when tearing down `BlendfileLoadingBaseTest`
and some other test cases. This prevents a memory leak.

A better solution would be to rework Blender's initialisation & teardown
structure, but that's outside the scope of this fix.

No functional changes to Blender.
2021-11-16 13:07:11 +01:00
faa8aa3bb9 Asset Browser: Forbid dragging catalogs into themselves
While there is nothing technically that would cause issues when moving a
catalog into itself (it just changes the path of the catalog, and the
missing parent catalogs will be created), it seems broken to the user.
So disable this in the drag & drop code for asset catalogs.
2021-11-16 13:01:57 +01:00
052c22199d Asset Browser: use one more refresh operator
Refreshing the assets requires `file_OT_asset_library_refresh` in the
asset browser, and `asset_OT_list_refresh` for the asset view. Both
are now done from `ASSET_OT_open_containing_blend_file`.
2021-11-16 12:35:39 +01:00
7da714f387 Merge branch 'blender-v3.0-release' 2021-11-16 10:57:26 +01:00
Diptangshu Dey
da14a482f2 Fix T90866: Python operator templates are not accessible from menus
Python Operator templates made accessible from respective menus
(required to also use F3 search for quick access)
Also fixed Modal Draw Operator id_name (had duplicate name from other template)

Maniphest Tasks: T90866

Differential Revision: https://developer.blender.org/D13182
2021-11-16 10:45:23 +01:00
d4c868da9f Geometry Nodes: refactor virtual array system
Goals of this refactor:
* Simplify creating virtual arrays.
* Simplify passing virtual arrays around.
* Simplify converting between typed and generic virtual arrays.
* Reduce memory allocations.

As a quick reminder, a virtual arrays is a data structure that behaves like an
array (i.e. it can be accessed using an index). However, it may not actually
be stored as array internally. The two most important implementations
of virtual arrays are those that correspond to an actual plain array and those
that have the same value for every index. However, many more
implementations exist for various reasons (interfacing with legacy attributes,
unified iterator over all points in multiple splines, ...).

With this refactor the core types (`VArray`, `GVArray`, `VMutableArray` and
`GVMutableArray`) can be used like "normal values". They typically live
on the stack. Before, they were usually inside a `std::unique_ptr`. This makes
passing them around much easier. Creation of new virtual arrays is also
much simpler now due to some constructors. Memory allocations are
reduced by making use of small object optimization inside the core types.

Previously, `VArray` was a class with virtual methods that had to be overridden
to change the behavior of a the virtual array. Now,`VArray` has a fixed size
and has no virtual methods. Instead it contains a `VArrayImpl` that is
similar to the old `VArray`. `VArrayImpl` should rarely ever be used directly,
unless a new virtual array implementation is added.

To support the small object optimization for many `VArrayImpl` classes,
a new `blender::Any` type is added. It is similar to `std::any` with two
additional features. It has an adjustable inline buffer size and alignment.
The inline buffer size of `std::any` can't be relied on and is usually too
small for our use case here. Furthermore, `blender::Any` can store
additional user-defined type information without increasing the
stack size.

Differential Revision: https://developer.blender.org/D12986
2021-11-16 10:16:30 +01:00
6d35972b06 Merge branch 'blender-v3.0-release' 2021-11-16 09:58:47 +01:00
7d985d6b69 Fix T93066: Alembic export ignores Mantaflow particles
`ABCPointsWriter::is_supported` already checked for valid particle
system types (liquid, spray, foam, bubbles, ...).

`AbstractHierarchyIterator::make_writers_particle_systems` did not
create a writer for these though, so now bring these in line and also
create writers for these.
2021-11-16 09:41:09 +01:00
57ed435def Cleanup: Use C++ matrix identity constructor 2021-11-15 23:24:16 -06:00
7e42ae7c1a Cleanup: Typo in comments 2021-11-15 22:08:28 +01:00
165cacc6f0 VSE: Use alpha over as default blend mode
With transform tools, it is expected to see backgroud image when overlay
is transformed.

Alpha over caused performance to be not optimal when used with opaque
media. This should be addressed with D12914 at least partially. There
may be some corner cases not addressed.

Differential Revision: https://developer.blender.org/D12952
2021-11-15 21:07:25 +01:00
62da6ffe08 VSE: Use early out for aplha over blending
When scaling down image, users expect to see background, which doesn't
currently happen in VSE. This is because strips use cross blend mode by
default, because alpha over is much slower. Reason is, because any area
of image can be transparent, and therefore it can't have early out
implemented in a way that cross blend mode can.

Flag images rendered by codecs that don't support transparency as fully
opaque and implement a form of early out for alpha over blend mode.

When rendering image stack, 2-input effects are ignored on the
"way down". Alpha over needs rendered overlay image to decide whether it
will use only overlay or background too. Therefore overlay can be
rendered safely before it is used. Image flags can be checked and it can
be freed if needed. Freeing doesn't cause any performance degradation,
because image is always stored in cache.

This feature does not improve blend mode performance. In summary, it
only allowes for having alpha over blend mode on background images
without suffering from lower performance.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D12914
2021-11-15 21:03:43 +01:00
46f5f60c13 Merge branch 'blender-v3.0-release' 2021-11-15 20:33:34 +01:00
a040d2a93a Fix T90592: Incorrect scrollbar range with backdrop
`v2d->tot` rect was set for backdrop drawing. Set range before drawing
scrollbars.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D13099
2021-11-15 20:28:11 +01:00
7e148c45c8 Fix T90415: Missing cache invalidation
Some RNA properties and operators did not invalidate cache or did it
incorrectly.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13101
2021-11-15 20:23:57 +01:00
d3c45e1c39 Fix T91405: Block artefacts in WEBM video
Issue was caused by incorrect FFmpeg asynchronous decoding API. In most
cases, decoder returns 1 frame each time it is fed by 1 packet. Here
decoder wanted to return more frames, but our code always expected only
one.

Before sending new packets to decoder, check if there are frames to
receive. If there are, process them, otherwise continue decoding as
usual.

Reviewed By: zeddb, sergey

Differential Revision: https://developer.blender.org/D13079
2021-11-15 20:20:33 +01:00
ef8240e64c Fix T91992: Incorrect clip strip image size
When proxy size lower than 100% is used, clip strips are rendered with
incorrect image size.

This is because if proxies aren't enabled in movieclip, it automatically
falls back on rendering original media. Sequencer doesn't have knowledge
about this and since 9c99292a16 it assumes that image is proxy,
because it explicitly requested this size.

Check movieclip flag to see if proxies are enabled.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D13080
2021-11-15 20:07:46 +01:00
10a6a540af Cleanup: remove unnecessary functions
Those functions were more useful when `FieldInferencingInterface`
was still declared further down in `node.cc`.
2021-11-15 18:04:03 +01:00
8976b72843 Merge branch 'blender-v3.0-release' 2021-11-15 09:10:19 -06:00
62da41d63d Fix: Incorrect socket identifier versioning
There were two issues:
 - The third math node socket does not exist in old enough files.
 - The comment incorrectly referred to the vector math node.

Differential Revision: https://developer.blender.org/D13219
2021-11-15 08:52:58 -06:00
c3472cb11c Fix T93074: Gpencil cutter not using flat caps in middle cuts
When cut an stroke using the option Flat Caps, the falt was not done if the cut was done in the middle of the stroke.

Now the flat is applied to the segments created and also some cleanup of the code done.
2021-11-15 12:17:11 +01:00
Jeroen Bakker
a5c59fb90e Fix T89260: Eevee crashes with custom node sockets.
Cause of this issue is that Custom Node Sockets info type was
initialized as SOCK_FLOAT when registering. Areas within the core that
would ignore custom socket types by checking its type would use the
socket as being a float type.

When custom node sockets have a property called default_value blender
tries to store it as an internal default value what failed in debug
builds.

This patch will set the socket type to SOCK_CUSTOM when registering a
custom socket type and allow, but skip storage of custom default values.
In this case the default values should already be stored as custom
properies.

Reviewed By: campbellbarton, JacquesLucke

Maniphest Tasks: T89260

Differential Revision: https://developer.blender.org/D13174
2021-11-15 08:13:22 +01:00
c2c65cc4bf Merge branch 'blender-v3.0-release' 2021-11-15 02:39:33 +01:00
622e6f05f1 Fix T92750: sculpt vertex colors missing in object mode
The layers were not aliased properly for usage in the shaders.

Regression caused by rB03013d19d167.
2021-11-15 02:38:52 +01:00
7e82c840b7 Fix text editor auto-close with quotes
Back-spacing a quote from the beginning of a line
would delete the quote in-front instead of doing nothing.
2021-11-14 11:26:06 +11:00
2549384baa Cleanup: minor tweaks to auto-close
Spelling and failure to reuse variable missed in review.
2021-11-14 11:11:20 +11:00
73047c69ea BLF: Use Floats for Font Point Sizes
Allow the use of floating-point values for font point sizes, which
allows greater precision and flexibility for text output.

See D8960 for more information, details, and justification.

Differential Revision: https://developer.blender.org/D8960

Reviewed by Campbell Barton
2021-11-13 09:39:18 -08:00
e8a8bb67fc Cleanup: Correct order of guard and lock in moviecache_valfree
Fix own mistake in rB7061d1e39fe

In my attempt to quickly address T92838, along with the original bug, I
made a nonsensical choice to use the limiter lock to guard the check
against the cache item itself. While harmless, it is not necessary and
semantically wrong / potentially confusing to future readers of the code.

Differential Revision: https://developer.blender.org/D13122
2021-11-12 20:47:26 -08:00
ab9ec193c3 Fix splash screen showing on startup with files loaded by scripts
Suppressing the splash was only done when passing in an argument from
the command line.

Remove G.file_loaded, as it is misleading, only set once on startup,
replace with G.relbase_valid which is used everywhere else to check
if the file path should be used.
2021-11-13 14:05:27 +11:00
Matheus Santos
c4ea5cb1a3 Text Editor: Auto close relevant characters
Support the ability to close relevant characters like '(', '[' and '{'.

It will also delete the pair character if they're empty.

Ref D13119

Reviewed By: campbellbarton
2021-11-13 13:56:31 +11:00
1143bf281a Cleanup: spelling in comments, comment block formatting 2021-11-13 13:07:13 +11:00
acc800d24d Cleanup: clang-format 2021-11-13 12:47:18 +11:00
dc378bf1a4 Merge branch 'blender-v3.0-release' 2021-11-12 21:57:44 -03:00
0a6f428be7 Fix snapping not performing on selected bones or splines
This is an old issue but never reported as it is only visible in the measure tool snapping.
2021-11-12 21:56:42 -03:00
60b8eb30bb Merge branch 'blender-v3.0-release' 2021-11-12 21:36:35 -03:00
eed48a7322 Cleanup: reference some snap parameters in the snap context itself
This decreases the number of parameters in functions and makes important variables available in more places.
2021-11-12 21:34:19 -03:00
738f4fbc5e Revert "Fix T92636: Vector math node link disconnects when loading old file"
This reverts commit 6b4ca78108.

A simpler fix was used for 3.0, but rBd845ba481c6d2ef already contained
a more complete solution to the problem of inconsistent socket ids.
2021-11-12 17:14:27 -06:00
ebb4aba325 Merge branch 'blender-v3.0-release' 2021-11-12 17:12:39 -06:00
6b4ca78108 Fix T92636: Vector math node link disconnects when loading old file
Previously, unique identifiers for sockets were created automatically,
sometimes using .001 and sometimes _001. Now they are created
manually with the second format, but some files were saved with .001
format. I think this was only an issue in the vector math node.

rBd845ba481c6d fixed this problem in 3.1, but in a more general way.
After I merge this patch to 3.1, I will revert it, since the versioning
added in that commit will make this redundant.

Differential Revision: https://developer.blender.org/D13209
2021-11-12 17:07:38 -06:00
ec432ae998 Merge branch 'blender-v3.0-release' 2021-11-12 14:06:26 -06:00
8d3a771574 Fix: Node Class Type for Select by Handle Type
Change the node class type for Node Select by Handle Type to
NODE_CLASS_INPUT
2021-11-12 14:05:40 -06:00
55c69373e8 Cleanup: split 'initSnappingMode' into more specific functions
This helps to reuse small regions of a function's code elsewhere.

The logic had to be reorganized, theoretically it should behave the same way.
2021-11-12 16:30:01 -03:00
8b13cf5667 Cleanup: move 'imm_drawcircball' to 'gpu_immediate_util.c' 2021-11-12 16:30:01 -03:00
5941c39fbf Cleanup: fix some comments in the transform code 2021-11-12 16:30:01 -03:00
30f9034182 Cleanup: use 't->tsnap.mode' in transform code
This also prevents different snap modes from being used at the same time in the code.
2021-11-12 16:30:01 -03:00
e5a7dd8ab6 Cleanup: unify snap modes to geometry in a single flag
This combination was being repeated in some places.
2021-11-12 16:30:01 -03:00
5b787c24fb Merge branch 'blender-v3.0-release' 2021-11-12 13:26:26 -06:00
888b879f5f Fix: Incorrect transfer attribute error message with curves
The node does support curves, but only in index mode (see T88630)
So add a specific error message for the nearest mode, and let the
node support curves in the declaration.

Differential Revision: https://developer.blender.org/D13205
2021-11-12 13:25:22 -06:00
1b55b911f2 Merge branch 'blender-v3.0-release' 2021-11-12 20:04:05 +01:00
71131b4969 Tests: disable audio system for performance tests 2021-11-12 20:03:46 +01:00
b4d9b8b7f8 Fix T91893, T92455: wrong transmission pass with hair and multiscatter glass
We need to increase GPU memory usage a bit. Unfortunately we can't get away
with writing either reflection or transmission passes because these BSDFs may
scatter in either direction but still must be in a fixed reflection or
transmission category to match up with the color passes.
2021-11-12 20:03:46 +01:00
ef0b8d6306 Fix T92002: no Cycles combined baking support for filter settings 2021-11-12 20:03:46 +01:00
d845ba481c Fix T91826: Inconsistent node socket name identifier separator
Previously both `.` and `_` were used as separators when finding
a unique name for a socket. This removes the use of `.`, since `_`
was more common. It also does versioning for all of a file's node
trees to make sure that they all use the `_` convention.

Differential Revision: https://developer.blender.org/D13181
2021-11-12 12:22:43 -06:00
cbca71a7cf Cleanup: Move remaning node editor files to C++
Differential Revision: https://developer.blender.org/D13200
2021-11-12 12:12:27 -06:00
809ae823b7 Merge branch 'blender-v3.0-release' 2021-11-12 19:00:23 +01:00
9d0d4b8601 Fix T93029: OptiX denoising artifacts at high sample counts in specific scenes
Partially reverts commit rB440a3475b8f5410e5c41bfbed5ce82771b41356f because
"optixDenoiserComputeIntensity" does not currently support input images that are not packed (the
"pixelStrideInBytes" field is not zero). As a result the intensity calculation would take into account
data from other passes in the image, some of which was scaled by the number of samples still and
therefore produce widely incorrect results that then caused artifacts in the denoised image.

Maniphest Tasks: T93029
2021-11-12 18:59:50 +01:00
8a8bf99717 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-12 18:23:44 +01:00
2b394e1108 UI: (Performance) Avoid drawing buttons out of view
The UI was always drawing all buttons in a layout, no matter if they
were scrolled out of view (as in, outside of the visible part of the
region) or not. This means it's doing quite some work that can be
avoided.
UI drawing generally isn't a big bottleneck in Blender, so I don't
expect huge speedups from this. But while playing back animation, we do
redraw a fair bit of the UI, so in cases where there are many buttons
out of view, it may bring a little FPS boost. E.g. say in complex node
trees (the node editor is redrawn on animation playback in case there
are animated values that need updated UI feedback). This also mitigates
the issue in T92922 significantly.

Differential Revision: https://developer.blender.org/T92922

Reviewed by: Brecht Van Lommel
2021-11-12 18:21:12 +01:00
Yevgeny Makarov
a89529d8db UI: Do not shade alpha when blending colors
UI_GetThemeColorBlendShade4fv incorrectly changing alpha by the amount
of the shading offset.

See D9944 for more details.

Differential Revision: https://developer.blender.org/D9944

Reviewed by Hans Goudey
2021-11-12 08:55:20 -08:00
9f5290e3bc Fix T93007: Cycles not updating for animated Object properties like color 2021-11-12 08:55:20 -08:00
c671b5eee4 Fix Cycles ray visibility panel missing for volume objects 2021-11-12 08:55:20 -08:00
Yevgeny Makarov
896d3f1ce5 UI: Do not shade alpha when blending colors
UI_GetThemeColorBlendShade4fv incorrectly changing alpha by the amount
of the shading offset.

See D9944 for more details.

Differential Revision: https://developer.blender.org/D9944

Reviewed by Hans Goudey
2021-11-12 08:51:31 -08:00
76105eb752 Fix T93007: Cycles not updating for animated Object properties like color 2021-11-12 17:09:21 +01:00
d48523cb4d Fix Cycles ray visibility panel missing for volume objects 2021-11-12 16:18:07 +01:00
ddf66cd060 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-12 14:36:55 +01:00
b4cfe80547 Assets: Store Action sub-type in asset metadata
Blender 3.0 will only support single-frame Actions in the pose library.
The goal of this patch is to lay the groundwork for making it possible
for the Asset Browser to reject/hide "animation snippet" Action assets.

Determining whether an Action has one or more frames (i.e. whether it
has a single pose or animation) requires inspecting the Action itself,
and thus loading the data-block itself. This would make it impossible to
quickly determine from the asset browser.

To solve this, the Action is inspected before saving, and a
`"is_single_frame"` boolean (well, 0/1 integer) IDProperty is added.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D13202
2021-11-12 14:36:22 +01:00
c7a88cf91a Merge branch 'blender-v3.0-release' 2021-11-13 00:31:03 +11:00
5f7d5c0809 Gizmo: adjust when gizmo protection flags are displayed
Restore behavior reverted in
0ea60cf6b8 but only for location
as it makes sense to use protection flags in global mode in that case.
2021-11-13 00:28:13 +11:00
a470e3c9d1 Merge branch 'blender-v3.0-release' 2021-11-13 00:20:07 +11:00
0ea60cf6b8 Fix gizmo protection flag use in object mode
Channel protection flags were only used in global mode,
this doesn't make any sense, especially for rotation and scale.

Follow pose-bones, only using protection flags for
local & gimbal orientation.
2021-11-13 00:19:36 +11:00
3fe735d371 Geometry Nodes: Add Outer Points Selection to Star
Adds a boolean field output containing a selection of the
points of the star that are controlled by the outer radius
of the star.

Differential Revision: https://developer.blender.org/D13097
2021-11-12 06:44:41 -06:00
a47359ff36 Merge branch 'blender-v3.0-release' 2021-11-12 11:52:49 +01:00
de8a46c6ad Fix T93008: Cycles: Huge memory spike when saving tile to disk
The root of the problem lies in bug in OIIO which we can work around
from our side (which does not affect pack memory usage).

Thanks Brecht for finding the root cause!

Differential Revision: https://developer.blender.org/D13186
2021-11-12 11:20:01 +01:00
26502f3d89 Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-11-12 10:52:12 +01:00
2b633f12ad Fix crash in asset browser when switching from file browser
When the file browser is in asset browser mode, it sets the callback
`filelist->prepare_filter_fn` to an asset browser specific function. This
function will segfault if there is no current asset library. Switching back
from asset browser to file browser would not reset that callback to
`NULL`, causing it to be called and crash Blender. This is now fixed.
2021-11-12 10:51:09 +01:00
86ca206db8 Cleanup/document BKE_blender_copybuffer.
* Rename the 'copy' functions to make it clear they belong to the same
  'group' and are to be used together.
* Fix `flag` parameter of `BKE_copybuffer_paste` being a short instead
  of an int.
* Improve documentation.
2021-11-12 10:20:49 +01:00
William Leeson
456876208b Fix T92601: Disable profiling when the profiler is deemed not active.
Adds a method to profiler that can be used to check if it is active.
This is used to determine if stop_profiling and start_profiling
should be called.

| patch | Juans Scene UI 256 samples | Juans Scene bg 256 samples | junkshop UI | junkshop bg |
| No patch | 6:16.59 | 4:05.37 | 2:08.48 | 1:59.7 |
| D13187   | 4:12.15 | 3:57.36 | 2:07.25 | 1:58.16 |
| D13185   | 4.11.18 |3:54.74 | 2:07.44 | 1:58.03 |
| D13190   | 4:12.39 | 3:55.42 | 2:07.62 | 1:58.68 |

UI - means rendered from within Blender
bg - means rendered from the command line using ##blender -b scene.blend -f 1##

Reviewed By: sergey, brecht

Maniphest Tasks: T92601

Differential Revision: https://developer.blender.org/D13190
2021-11-12 10:16:01 +01:00
William Leeson
32c7687859 Fix T92601: Disable profiling when the profiler is deemed not active.
Adds a method to profiler that can be used to check if it is active.
This is used to determine if stop_profiling and start_profiling
should be called.

| patch | Juans Scene UI 256 samples | Juans Scene bg 256 samples | junkshop UI | junkshop bg |
| No patch | 6:16.59 | 4:05.37 | 2:08.48 | 1:59.7 |
| D13187   | 4:12.15 | 3:57.36 | 2:07.25 | 1:58.16 |
| D13185   | 4.11.18 |3:54.74 | 2:07.44 | 1:58.03 |
| D13190   | 4:12.39 | 3:55.42 | 2:07.62 | 1:58.68 |

UI - means rendered from within Blender
bg - means rendered from the command line using ##blender -b scene.blend -f 1##

Reviewed By: sergey, brecht

Maniphest Tasks: T92601

Differential Revision: https://developer.blender.org/D13190
2021-11-12 10:01:48 +01:00
a87253942d Cleanup: Remove GHOST_isUpsideDownContext.
GHOST API only has a header definition. No implementation or usage.
2021-11-12 09:38:25 +01:00
ae74ad191c Merge branch 'blender-v3.0-release' 2021-11-12 18:35:22 +11:00
aa1c44a113 Merge branch 'blender-v3.0-release' 2021-11-12 18:35:19 +11:00
5c0d4753cf Merge branch 'blender-v3.0-release' 2021-11-12 18:35:16 +11:00
02333544d1 Merge branch 'blender-v3.0-release' 2021-11-12 18:35:13 +11:00
1061f5a1ba Cleanup: remove redundant loop-index access
Use a counter for loop indices as they're being iterated in order.
2021-11-12 18:33:05 +11:00
1a7757b0bc Fix T91444: Edge Loop Preview fails with two Mirror Modifiers
The mirror modifiers merge option caused unnecessary re-ordering
to the vertex array with original vertices merging into their copies.

While this wasn't an error, it meant creating a 1:1 mapping from input
vertices to their final output wasn't reliable (when looping over
vertices first to last) as is done in
BKE_editmesh_vert_coords_when_deformed.

As merging in either direction is supported, keep the source meshes
vertices in-order since it allows the vertex coordinates to be extracted.
2021-11-12 18:27:47 +11:00
f133c6b094 Fix crash saving blend files in background mode
Reading the windows pixels was attempted in background mode.
2021-11-12 18:05:27 +11:00
d612d92630 Cleanup: use term sequence_strip instead of vse_strip 2021-11-12 17:38:58 +11:00
1e1c870001 Cleanup: Improve comment 2021-11-11 21:57:40 -06:00
0533f2851e Geometry Nodes: change selection output order in Cylinder node
This new order is a bit more intuitive.
2021-11-11 19:53:02 +01:00
d6e682a7b0 Merge branch 'blender-v3.0-release' 2021-11-11 19:50:24 +01:00
bd734cc441 Fix: Attribute Transfer node does not work with a single index
Differential Revision: https://developer.blender.org/D13194
2021-11-11 19:49:20 +01:00
e61da8e4fb Merge branch 'blender-v3.0-release' 2021-11-11 11:47:43 -06:00
f3bdabbe24 Fix: Incorrect modifier warning with non-geometry input first
The code assumed that any geometry input that wasn't the first input
was a second geometry input. Fix by separating the warning for the
first input and for the number of geometry inputs.
2021-11-11 11:47:19 -06:00
50f32025ac Merge branch 'blender-v3.0-release' 2021-11-11 18:27:31 +01:00
393879f30c Fix: wrong field inferencing with unavailable sockets 2021-11-11 18:26:40 +01:00
3d9c8397fc Fix T93005: Cycles shadow catcher not inherited by instances 2021-11-11 18:12:05 +01:00
c9c7658926 Geometry Nodes: Add Offset to Handle Position Node
Adds a vector offset field to the "Curve Handle Position Node".
This vector is added to the incoming position (which is the
implicit handle position if not connected) which will set the
position of the handle. Default is (0,0,0)

Differential Revision: https://developer.blender.org/D13035
2021-11-11 10:58:23 -06:00
3ca41b7312 Merge branch 'blender-v3.0-release' 2021-11-11 10:16:35 -06:00
Peter Sergay
4bc08b79aa UI: Updated Blender Light theme for Spreadsheet
This patch adds list colors to the light theme for the spreadsheet,
which are needed for the data set region. Addresses T92492.

Differential Revision: https://developer.blender.org/D13090
2021-11-11 10:10:28 -06:00
25e7365d0d Cleanup CUDA / HIP comments
Remove outdated CUDA comments for bindless textures and cleanup some HIP comments that still mentioned CUDA.

Differential Revision: https://developer.blender.org/D13189
2021-11-11 16:37:29 +01:00
52c617802f Merge branch 'blender-v3.0-release' 2021-11-11 09:27:42 -06:00
Martijn Versteegh
7aa39b40f4 Fix: Prevent use of uninitialized memory when creating Bezier spline
When Constructing bezier splines from dna, the positions of the
left/right handles were set directly in the internal vectors, by
requesting a reference to them. The problem is that
BezierSpline::handle_positions_left() calls ensure_auto_handles()
before returning the reference. That function does some calculations on
uninitialized memory if the positions array is not yet filled.

Differential Revision: https://developer.blender.org/D13107
2021-11-11 09:25:10 -06:00
ce395c84a3 Merge branch 'blender-v3.0-release' 2021-11-11 15:29:35 +01:00
d26d3cfe19 Fix T92868: Cycles catcher with transparency crashes
The issue was caused by splitting happening twice.

Fixed by checking for split flag which is assigned to the both states
during split.

The tricky part was to write catcher data at the moment of split: the
transparency and shadow catcher sample count is to be accumulated at
that point. Now it is happening in the `intersect_closest` kernel.
The downside is that render buffer is to be passed to the kernel, but
the benefit is that extra split bounce check is not needed now.

Had to move the passes write to shadow catcher header, since include
of `film/passes.h` causes all the fun of requirement to have BSDF
data structures available.

Differential Revision: https://developer.blender.org/D13177
2021-11-11 15:21:35 +01:00
06a74e7816 LibLink/Append tests: Add basic testing of bpy.data.libraries.load code. 2021-11-11 14:54:26 +01:00
9f31b9b7d3 Merge branch 'blender-v3.0-release' 2021-11-11 14:33:28 +01:00
9be6880d02 Fix (unreported) bad handling of reports in libraries.load code.
rB60fee69682ac39 only partially fixed the issue, `BlendFileReadReport
bf_reports` was now properly stored in `BPy_Library` `self` for the
lifetime of the context, but its `reports` member was still referencing
local variable to `bpy_lib_enter` function.
2021-11-11 14:29:14 +01:00
4a98faf9f1 Merge branch 'blender-v3.0-release' 2021-11-11 21:34:05 +11:00
8c240f50b2 Merge branch 'blender-v3.0-release' 2021-11-11 21:34:02 +11:00
b7e2408ea4 Fix T92867: Gimbal rotation broken when used for multiple objects
Support gimbal orientation for objects & bones.
2021-11-11 21:33:09 +11:00
bb64155c63 Cleanup: split gimbal_axis into pose and object
Allow access to a single bones gimbal matrix.
2021-11-11 21:14:08 +11:00
Andrii
c63e735f6b Cycles: Add sample offset option
This patch exposes the sampling offset option to Blender. It is located in the "Sampling > Advanced" panel.
For example, this can be useful to parallelize rendering and distribute different chunks of samples for each computer to render.

---

I also had to add this option to `RenderWork` and `RenderScheduler` classes so that the sample count in the status string can be calculated correctly.

Reviewed By: leesonw

Differential Revision: https://developer.blender.org/D13086
2021-11-11 09:39:25 +01:00
b8d53b703a Merge branch 'blender-v3.0-release' 2021-11-11 15:00:23 +11:00
9787b46f09 Merge branch 'blender-v3.0-release' 2021-11-11 15:00:20 +11:00
03f0be35d6 Merge branch 'blender-v3.0-release' 2021-11-11 15:00:17 +11:00
d753ebd40a Cleanup: spelling in comments 2021-11-11 14:59:30 +11:00
ddf0bacaa9 Cleanup: typo in function name 2021-11-11 14:58:55 +11:00
3929db265f Fix T92954: Loop Cut Tool preview line visible during operation
Apply a local-workaround instead of adding support for this use-case
since pre-selection isn't the intended purpose of gizmos.

This also resolves a glitch where poly-build and loop cut would
briefly show loop-cut or poly-build pre-selection after transforming.

See gizmo_preselect_poll_for_draw note for more details.
2021-11-11 14:58:55 +11:00
e1bd4bbb66 UI: Introduce View pie in more editors
#### Motivation

The View pie menu is a convenient way to access operators such as `Frame Selected` and `Frame All` which are usually mapped to `PERIOD` or `HOME` keys on the right side of most keyboard, making it hard hard to reach with the left hand.

The motivation for this patch comes from working with a 75% keyboard (no numpad). Most laptops face a similar problem.

#### Implementation

The View pie menu has been added to the following editors and sub-modes where applicable:

* Node Editor
* Video Sequencer
* Dopesheet
* Graph
* NLA
* Image
* Clip
* Outliner

More options could definitely be added to this menu for convenience, as long as it maintains the common options in the same place (Frame Selected on the left, Frame All on the right).

For positioning I went with the following layout:
{F11791186, size=full}

I've added `Zoom 1:1`to the Image Editor and the VSE Preview since there is no way to reset the zoom on keyboards without numpad (unless Emulate Numpad is turned on).

The Outliner uses `Show Active` and `Show Hierarchy` which are the closest ones to the equivalent in other editors. Should `Show Active` be renamed to `Frame Selected`?

The shortcut assigned is the same as the 3D Viewport (`ACCENT_GRAVE`).

#### Screenshots

Node Editor
{F11778387, size=full}

Dopesheet
{F11778400, size=full}

Graph
{F11778403, size=full}

Image Editor (Paint and View)
{F11791113, size=full}

Image Editor (Mask)
{F11791114, size=full}

UV Editor
{F11791119, size=full}

Clip Editor (Tracking)
{F11791137, size=full}

Clip Editor (Mask)
{F11791140, size=full}

Clip Editor (Graph)
{F11791151, size=full}
View operators are not yet implemented in Clip Editor Dopesheet mode (left a note about this in the menu poll).

Reviewed By: #user_interface, campbellbarton

Differential Revision: https://developer.blender.org/D13169
2021-11-11 01:18:50 +01:00
f1a8644121 Cleanup: Move interface_region_search.c to C++
This will be helpful for solving a bug with search during animation
playback, T89313. I tested this on all platforms on the buildbot.
2021-11-10 15:49:49 -06:00
1ec7075ff2 Merge branch 'blender-v3.0-release' 2021-11-10 15:44:13 -06:00
22ffd69a91 Fix T89313: Attribute search crash with animation playback
rBc473b2ce8bdbf8fa42 improved the situation somewhat, but
attribute search still crashes during animation playback, because
the UI search data references stale memory. The proper solution
is to allow the search to own data rather than just referencing it,
but I would prefer not to do that for 3.0. In the meantime, just
disable attribute search when animation is playing.

Differential Revision: https://developer.blender.org/D13179
2021-11-10 15:43:18 -06:00
9ca8bf0b29 Merge branch 'blender-v3.0-release' 2021-11-10 22:28:03 +01:00
040630bb9a Fix wrong device check in HIP kernel compile.
Also cleanup some related code, that was falsely copied from CUDA.

Differential Revision: https://developer.blender.org/D13180
2021-11-10 22:24:53 +01:00
3fa86f4b28 Merge branch 'blender-v3.0-release' 2021-11-10 20:19:09 +01:00
7689f501e2 Cycles: enable HIP device and binaries on Windows
We've now done testing to confirm this works with RDNA and RDNA2 AMD GPUs
on Windows. The AMD driver needed for this will soon be released publicly.
2021-11-10 20:16:44 +01:00
Thomas Dinges
e507a789b3 Cycles: disable graphics interop for HIP devices
This is due to a driver bug, so disable it for now until it gets resolved
in a future driver release.

Ref T92972

Differential Revision: https://developer.blender.org/D13167
2021-11-10 20:16:44 +01:00
6b0008129e Fix T92972: Cycles HIP wrong render display after a recent refactor
It's unclear why this fails. Maybe the size of half4 is not the expected
8 bytes and adjacent pixels are overwritten. Or there is some bug in the
HIP compiler writing a struct into global memory, which we probably don't
do elsewhere in the kernel.

Thanks to Thomas, William and Jeroen for helping investigate this.
2021-11-10 20:03:07 +01:00
c8e93da0a7 Fix Cycles assert in denoising fallback to OIDN 2021-11-10 19:56:30 +01:00
42d2c96d4c Wrapped related global vars into struct. 2021-10-04 14:45:30 +02:00
941fdefdb3 Move index from DrawEngineType to DRWRegisteredDrawEngine. 2021-10-04 14:36:47 +02:00
a0df3c4d51 Fix incorrect merge: missing function DRW_view_get_active. 2021-10-04 11:21:38 +02:00
4984cba10d DRW: Fix implicit convertion warning on MSVC 2021-09-29 18:05:49 +02:00
59a0099b9f Merge branch 'master' into draw-viewport-data 2021-09-29 17:25:16 +02:00
f8cfd7e288 Merge branch 'master' into draw-viewport-data
# Conflicts:
#	source/blender/draw/DRW_engine.h
#	source/blender/draw/intern/draw_manager.c
#	source/blender/draw/intern/draw_manager.h
2021-09-29 11:31:39 +02:00
dc0c074ac4 Cleanup: Remove compiler warning and fix some comments 2021-09-29 11:24:25 +02:00
0053d2fc81 DRW: Move buffer & temp textures & framebuffer management to DrawManager
This is a necessary step for EEVEE's new arch. This moves more data
to the draw manager. This makes it easier to have the render or draw
engines manage their own data.

This makes more sense and cleans-up what the GPUViewport holds

Also rewrites the Texture pool manager to be in C++.

This also move the DefaultFramebuffer/TextureList and the engine related
data to a new `DRWViewData` struct. This struct manages the per view
(as in stereo view) engine data.

There is a bit of cleanup in the way the draw manager is setup.
We now use a temporary DRWData instead of creating a dummy viewport.

Differential Revision: https://developer.blender.org/D11966
2021-07-19 19:47:55 +02:00
e6d94b83ba DRW: Fix memory leak of GPUTextures
The textures needs to be released by iterating. Not by using the
free callback.
2021-06-05 15:36:47 +02:00
81632de706 DRW: Move mempool datas to a DRW managed struct.
Same idea as previous commit. This cleans-up the interface and put all
viewport related data inside the `DRWData` struct.

The draw manager is responsible for freeing it. That is the main point
of this all. In the future, we can have custom freeing method for each
engine.

This also move the DefaultFramebuffer/TextureList and the engine related
data to a new `DRWViewData` struct. This struct manages the per view
(as in stereo view) engine data.

There is a bit of cleanup in the way the draw manager is setup.
We now use a temporary DRWData instead of creating a dummy viewport.
2021-03-25 01:03:10 +01:00
f7cb19956f DRW: Move GPUViewport texture pool to DRW module
This makes more sense and cleans-up what the GPUViewport holds.

Also rewrite it to be in C++.
2021-03-22 23:53:42 +01:00
3498 changed files with 144973 additions and 100202 deletions

View File

@@ -12,6 +12,8 @@ Checks: >
-readability-avoid-const-params-in-decls,
-readability-simplify-boolean-expr,
-readability-make-member-function-const,
-readability-suspicious-call-argument,
-readability-redundant-member-init,
-readability-misleading-indentation,
@@ -25,6 +27,8 @@ Checks: >
-bugprone-branch-clone,
-bugprone-macro-parentheses,
-bugprone-reserved-identifier,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-sizeof-expression,
-bugprone-integer-division,
@@ -40,7 +44,8 @@ Checks: >
-modernize-pass-by-value,
# Cannot be enabled yet, because using raw string literals in tests breaks
# the windows compiler currently.
-modernize-raw-string-literal
-modernize-raw-string-literal,
-modernize-return-braced-init-list
CheckOptions:
- key: modernize-use-default-member-init.UseAssignment

View File

@@ -187,6 +187,13 @@ mark_as_advanced(CPACK_OVERRIDE_PACKAGENAME)
mark_as_advanced(BUILDINFO_OVERRIDE_DATE)
mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
option(WITH_UNITY_BUILD "Enable unity build for modules that support it to improve compile times" ON)
mark_as_advanced(WITH_UNITY_BUILD)
else()
set(WITH_UNITY_BUILD OFF)
endif()
option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
option(WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON)
option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON)
@@ -266,11 +273,13 @@ endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_FREETYPE "Use the freetype library provided by the operating system" OFF)
else()
# not an option for other OS's
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
set(WITH_SYSTEM_FREETYPE OFF)
endif()
@@ -411,6 +420,7 @@ option(WITH_CYCLES "Enable Cycles Render Engine" ON)
option(WITH_CYCLES_OSL "Build Cycles with OpenShadingLanguage support" ON)
option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF)
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
@@ -425,26 +435,40 @@ mark_as_advanced(WITH_CYCLES_DEBUG_NAN)
mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
# NVIDIA CUDA & OptiX
option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles NVIDIA CUDA compute support" ON)
option(WITH_CYCLES_DEVICE_OPTIX "Enable Cycles NVIDIA OptiX support" ON)
mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)
if(NOT APPLE)
option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles NVIDIA CUDA compute support" ON)
option(WITH_CYCLES_DEVICE_OPTIX "Enable Cycles NVIDIA OptiX support" ON)
mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles NVIDIA CUDA binaries" OFF)
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for")
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)" ON)
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
mark_as_advanced(WITH_CUDA_DYNLOAD)
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles NVIDIA CUDA binaries" OFF)
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for")
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)" ON)
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
mark_as_advanced(WITH_CUDA_DYNLOAD)
endif()
# AMD HIP
option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" OFF)
option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
set(CYCLES_HIP_BINARIES_ARCH gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 CACHE STRING "AMD HIP architectures to build binaries for")
mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
if(NOT APPLE)
if(WIN32)
option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" ON)
else()
option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" OFF)
endif()
option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
set(CYCLES_HIP_BINARIES_ARCH gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 CACHE STRING "AMD HIP architectures to build binaries for")
mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
endif()
# Apple Metal
if(APPLE)
option(WITH_CYCLES_DEVICE_METAL "Enable Cycles Apple Metal compute support" ON)
endif()
# Draw Manager
option(WITH_DRAW_DEBUG "Add extra debug capabilities to Draw Manager" OFF)
@@ -489,11 +513,10 @@ if(WIN32)
endif()
# This should be turned off when Blender enter beta/rc/release
if("${BLENDER_VERSION_CYCLE}" STREQUAL "release" OR
"${BLENDER_VERSION_CYCLE}" STREQUAL "rc")
set(WITH_EXPERIMENTAL_FEATURES OFF)
else()
if("${BLENDER_VERSION_CYCLE}" STREQUAL "alpha")
set(WITH_EXPERIMENTAL_FEATURES ON)
else()
set(WITH_EXPERIMENTAL_FEATURES OFF)
endif()
# Unit testsing
@@ -515,12 +538,14 @@ option(WITH_OPENGL "When off limits visibility of the opengl header
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
option(WITH_GPU_SHADER_BUILDER "Shader builder is a developer option enabling linting on GLSL during compilation" OFF)
mark_as_advanced(
WITH_OPENGL
WITH_GLEW_ES
WITH_GL_EGL
WITH_GL_PROFILE_ES20
WITH_GPU_SHADER_BUILDER
)
if(WIN32)
@@ -538,12 +563,18 @@ if(WIN32)
set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
endif()
# Compiler toolchain
if(CMAKE_COMPILER_IS_GNUCC)
option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON)
mark_as_advanced(WITH_LINKER_GOLD)
option(WITH_LINKER_LLD "Use ld.lld linker which is usually faster than ld.gold" OFF)
mark_as_advanced(WITH_LINKER_LLD)
# Compiler tool-chain.
if(UNIX AND NOT APPLE)
if(CMAKE_COMPILER_IS_GNUCC)
option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON)
mark_as_advanced(WITH_LINKER_GOLD)
option(WITH_LINKER_LLD "Use ld.lld linker which is usually faster than ld.gold" OFF)
mark_as_advanced(WITH_LINKER_LLD)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
option(WITH_LINKER_MOLD "Use ld.mold linker which is usually faster than ld.gold & ld.lld." OFF)
mark_as_advanced(WITH_LINKER_MOLD)
endif()
endif()
option(WITH_COMPILER_ASAN "Build and link against address sanitizer (only for Debug & RelWithDebInfo targets)." OFF)
@@ -679,9 +710,12 @@ if(UNIX AND NOT APPLE)
endif()
# Installation process.
option(POSTINSTALL_SCRIPT "Run given CMake script after installation process" OFF)
set(POSTINSTALL_SCRIPT "" CACHE FILEPATH "Run given CMake script after installation process")
mark_as_advanced(POSTINSTALL_SCRIPT)
set(POSTCONFIGURE_SCRIPT "" CACHE FILEPATH "Run given CMake script as the last step of CMake configuration")
mark_as_advanced(POSTCONFIGURE_SCRIPT)
# end option(...)
@@ -835,7 +869,7 @@ if(WITH_AUDASPACE)
endif()
# Auto-enable CUDA dynload if toolkit is not found.
if(NOT WITH_CUDA_DYNLOAD)
if(WITH_CYCLES AND WITH_CYCLES_DEVICE_CUDA AND NOT WITH_CUDA_DYNLOAD)
find_package(CUDA)
if(NOT CUDA_FOUND)
message(STATUS "CUDA toolkit not found, using dynamic runtime loading of libraries (WITH_CUDA_DYNLOAD) instead")
@@ -1065,7 +1099,7 @@ if(MSVC)
add_definitions(-D__LITTLE_ENDIAN__)
# OSX-Note: as we do cross-compiling with specific set architecture,
# endianess-detection and auto-setting is counterproductive
# endianness-detection and auto-setting is counterproductive
# so we just set endianness according CMAKE_OSX_ARCHITECTURES
elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64 OR CMAKE_OSX_ARCHITECTURES MATCHES arm64)
@@ -1755,7 +1789,7 @@ endif()
set(CMAKE_CXX_STANDARD 17)
# If C++17 is not available, downgrading to an earlier standard is NOT OK.
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Do not enable compiler specific language extentions.
# Do not enable compiler specific language extensions.
set(CMAKE_CXX_EXTENSIONS OFF)
# Make MSVC properly report the value of the __cplusplus preprocessor macro
@@ -2045,3 +2079,8 @@ endif()
if(0)
print_all_vars()
endif()
# Should be the last step of configuration.
if(POSTCONFIGURE_SCRIPT)
include(${POSTCONFIGURE_SCRIPT})
endif()

View File

@@ -51,7 +51,7 @@ Other Convenience Targets
* config: Run cmake configuration tool to set build options.
* deps: Build library dependencies (intended only for platform maintainers).
The existance of locally build dependancies overrides the pre-built dependencies from subversion.
The existance of locally build dependencies overrides the pre-built dependencies from subversion.
These must be manually removed from '../lib/' to go back to using the pre-compiled libraries.
Project Files

View File

@@ -63,6 +63,7 @@ include(cmake/jpeg.cmake)
include(cmake/blosc.cmake)
include(cmake/pthreads.cmake)
include(cmake/openexr.cmake)
include(cmake/brotli.cmake)
include(cmake/freetype.cmake)
include(cmake/freeglut.cmake)
include(cmake/glew.cmake)

View File

@@ -25,8 +25,13 @@ else()
endif()
if(WIN32)
set(BOOST_TOOLSET toolset=msvc-14.1)
set(BOOST_COMPILER_STRING -vc141)
if(MSVC_VERSION GREATER_EQUAL 1920) # 2019
set(BOOST_TOOLSET toolset=msvc-14.2)
set(BOOST_COMPILER_STRING -vc142)
else() # 2017
set(BOOST_TOOLSET toolset=msvc-14.1)
set(BOOST_COMPILER_STRING -vc141)
endif()
set(BOOST_CONFIGURE_COMMAND bootstrap.bat)
set(BOOST_BUILD_COMMAND b2)

View File

@@ -0,0 +1,38 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
set(BROTLI_EXTRA_ARGS
)
ExternalProject_Add(external_brotli
URL file://${PACKAGE_DIR}/${BROTLI_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${BROTLI_HASH_TYPE}=${BROTLI_HASH}
PREFIX ${BUILD_DIR}/brotli
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/brotli ${DEFAULT_CMAKE_FLAGS} ${BROTLI_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/brotli
)
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_brotli after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/brotli/include ${HARVEST_TARGET}/brotli/include
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/brotli/lib/brotlidec-static${LIBEXT} ${HARVEST_TARGET}/brotli/lib/brotlidec-static${LIBEXT}
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/brotli/lib/brotlicommon-static${LIBEXT} ${HARVEST_TARGET}/brotli/lib/brotlicommon-static${LIBEXT}
DEPENDEES install
)
endif()

View File

@@ -94,3 +94,4 @@ download_source(POTRACE)
download_source(HARU)
download_source(ZSTD)
download_source(FLEX)
download_source(BROTLI)

View File

@@ -23,9 +23,12 @@ set(FREETYPE_EXTRA_ARGS
-DWITH_HarfBuzz=OFF
-DFT_WITH_HARFBUZZ=OFF
-DFT_WITH_BZIP2=OFF
-DFT_WITH_BROTLI=ON
-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE
-DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE)
-DPC_BROTLIDEC_INCLUDEDIR=${LIBDIR}/brotli/include
-DPC_BROTLIDEC_LIBDIR=${LIBDIR}/brotli/lib
)
ExternalProject_Add(external_freetype
URL file://${PACKAGE_DIR}/${FREETYPE_FILE}
@@ -36,6 +39,11 @@ ExternalProject_Add(external_freetype
INSTALL_DIR ${LIBDIR}/freetype
)
add_dependencies(
external_freetype
external_brotli
)
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_freetype after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freetype ${HARVEST_TARGET}/freetype

View File

@@ -38,13 +38,6 @@ elseif(UNIX AND NOT APPLE)
)
endif()
if(BLENDER_PLATFORM_ARM)
set(GMP_OPTIONS
${GMP_OPTIONS}
--disable-assembly
)
endif()
ExternalProject_Add(external_gmp
URL file://${PACKAGE_DIR}/${GMP_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}

View File

@@ -17,7 +17,7 @@
# ***** END GPL LICENSE BLOCK *****
########################################################################
# Copy all generated files to the proper strucure as blender prefers
# Copy all generated files to the proper structure as blender prefers
########################################################################
if(NOT DEFINED HARVEST_TARGET)
@@ -79,6 +79,8 @@ endfunction()
harvest(alembic/include alembic/include "*.h")
harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a)
harvest(alembic/bin alembic/bin "*")
harvest(brotli/include brotli/include "*.h")
harvest(brotli/lib brotli/lib "*.a")
harvest(boost/include boost/include "*")
harvest(boost/lib boost/lib "*.a")
harvest(ffmpeg/include ffmpeg/include "*.h")

View File

@@ -42,6 +42,7 @@ ExternalProject_Add(nanovdb
URL_HASH ${NANOVDB_HASH_TYPE}=${NANOVDB_HASH}
PREFIX ${BUILD_DIR}/nanovdb
SOURCE_SUBDIR nanovdb
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/nanovdb/src/nanovdb < ${PATCH_DIR}/nanovdb.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/nanovdb ${DEFAULT_CMAKE_FLAGS} ${NANOVDB_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/nanovdb
)

View File

@@ -39,7 +39,7 @@ endif()
set(DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/downloads" CACHE STRING "Path for downloaded files")
# This path must be hard-coded like this, so that the GNUmakefile knows where it is and can pass it to make_source_archive.py:
set(PACKAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/packages")
option(PACKAGE_USE_UPSTREAM_SOURCES "Use soures upstream to download the package sources, when OFF the blender mirror will be used" ON)
option(PACKAGE_USE_UPSTREAM_SOURCES "Use sources upstream to download the package sources, when OFF the blender mirror will be used" ON)
file(TO_CMAKE_PATH ${DOWNLOAD_DIR} DOWNLOAD_DIR)
file(TO_CMAKE_PATH ${PACKAGE_DIR} PACKAGE_DIR)

View File

@@ -24,7 +24,7 @@ if(MSVC)
add_custom_command(
OUTPUT ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe
COMMAND echo packaging python
COMMAND echo this should ouput at ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe
COMMAND echo this should output at ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTARGET}/libs
COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib
COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python.exe ${PYTARGET}/bin/python.exe
@@ -43,7 +43,7 @@ if(MSVC)
add_custom_command(
OUTPUT ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe
COMMAND echo packaging python
COMMAND echo this should ouput at ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe
COMMAND echo this should output at ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTARGET}/libs
COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib
COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python${PYTHON_POSTFIX}.exe ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe

View File

@@ -83,9 +83,9 @@ else()
set(OPENEXR_VERSION_POSTFIX)
endif()
set(FREETYPE_VERSION 2.10.2)
set(FREETYPE_VERSION 2.11.0)
set(FREETYPE_URI http://prdownloads.sourceforge.net/freetype/freetype-${FREETYPE_VERSION}.tar.gz)
set(FREETYPE_HASH b1cb620e4c875cd4d1bfa04945400945)
set(FREETYPE_HASH cf09172322f6b50cf8f568bf8fe14bde)
set(FREETYPE_HASH_TYPE MD5)
set(FREETYPE_FILE freetype-${FREETYPE_VERSION}.tar.gz)
@@ -474,9 +474,9 @@ set(ISPC_HASH 2e3abedbc0ea9aaec17d6562c632454d)
set(ISPC_HASH_TYPE MD5)
set(ISPC_FILE ispc-${ISPC_VERSION}.tar.gz)
set(GMP_VERSION 6.2.0)
set(GMP_VERSION 6.2.1)
set(GMP_URI https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz)
set(GMP_HASH a325e3f09e6d91e62101e59f9bda3ec1)
set(GMP_HASH 0b82665c4a92fd2ade7440c13fcaa42b)
set(GMP_HASH_TYPE MD5)
set(GMP_FILE gmp-${GMP_VERSION}.tar.xz)
@@ -500,3 +500,9 @@ set(ZSTD_FILE zstd-${ZSTD_VERSION}.tar.gz)
set(SSE2NEON_GIT https://github.com/DLTcollab/sse2neon.git)
set(SSE2NEON_GIT_HASH fe5ff00bb8d19b327714a3c290f3e2ce81ba3525)
set(BROTLI_VERSION v1.0.9)
set(BROTLI_URI https://github.com/google/brotli/archive/refs/tags/${BROTLI_VERSION}.tar.gz)
set(BROTLI_HASH f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46)
set(BROTLI_HASH_TYPE SHA256)
set(BROTLI_FILE brotli-${BROTLI_VERSION}.tar.gz)

View File

@@ -492,7 +492,7 @@ OIIO_SKIP=false
LLVM_VERSION="12.0.0"
LLVM_VERSION_SHORT="12.0"
LLVM_VERSION_MIN="11.0"
LLVM_VERSION_MEX="13.0"
LLVM_VERSION_MEX="14.0"
LLVM_VERSION_FOUND=""
LLVM_FORCE_BUILD=false
LLVM_FORCE_REBUILD=false
@@ -1826,7 +1826,7 @@ compile_OCIO() {
# Force linking against static libs
#rm -f $_inst/lib/*.so*
# Additional depencencies
# Additional dependencies
#cp ext/dist/lib/libtinyxml.a $_inst/lib
#cp ext/dist/lib/libyaml-cpp.a $_inst/lib
@@ -2083,9 +2083,9 @@ compile_OIIO() {
cmake_d="$cmake_d -D OPENEXR_VERSION=$OPENEXR_VERSION"
if [ "$_with_built_openexr" = true ]; then
cmake_d="$cmake_d -D ILMBASE_HOME=$INST/openexr"
cmake_d="$cmake_d -D OPENEXR_HOME=$INST/openexr"
INFO "ILMBASE_HOME=$INST/openexr"
cmake_d="$cmake_d -D ILMBASE_ROOT=$INST/openexr"
cmake_d="$cmake_d -D OPENEXR_ROOT=$INST/openexr"
INFO "Ilmbase_ROOT=$INST/openexr"
fi
# ptex is only needed when nicholas bishop is ready
@@ -2374,9 +2374,9 @@ compile_OSL() {
#~ cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
if [ "$_with_built_openexr" = true ]; then
INFO "ILMBASE_HOME=$INST/openexr"
cmake_d="$cmake_d -D OPENEXR_ROOT_DIR=$INST/openexr"
cmake_d="$cmake_d -D ILMBASE_ROOT_DIR=$INST/openexr"
cmake_d="$cmake_d -D ILMBASE_ROOT=$INST/openexr"
cmake_d="$cmake_d -D OPENEXR_ROOT=$INST/openexr"
INFO "Ilmbase_ROOT=$INST/openexr"
# XXX Temp workaround... sigh, ILMBase really messed the things up by defining their custom names ON by default :(
fi
@@ -3620,8 +3620,8 @@ compile_FFmpeg() {
fi
./configure --cc="gcc -Wl,--as-needed" \
--extra-ldflags="-pthread -static-libgcc" \
--prefix=$_inst --enable-static \
--extra-ldflags="-pthread" \
--prefix=$_inst --enable-shared \
--disable-ffplay --disable-doc \
--enable-gray \
--enable-avfilter --disable-vdpau \
@@ -5721,76 +5721,6 @@ install_OTHER() {
# ----------------------------------------------------------------------------
# Printing User Info
print_info_ffmpeglink_DEB() {
dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
}
print_info_ffmpeglink_RPM() {
rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
}
print_info_ffmpeglink_ARCH() {
pacman -Ql $_packages | grep -e ".*\/lib[^\/]\+\.so$" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
}
print_info_ffmpeglink() {
# This func must only print a ';'-separated list of libs...
if [ -z "$DISTRO" ]; then
ERROR "Failed to detect distribution type"
exit 1
fi
# Create list of packages from which to get libs names...
_packages=""
if [ "$THEORA_USE" = true ]; then
_packages="$_packages $THEORA_DEV"
fi
if [ "$VORBIS_USE" = true ]; then
_packages="$_packages $VORBIS_DEV"
fi
if [ "$OGG_USE" = true ]; then
_packages="$_packages $OGG_DEV"
fi
if [ "$XVID_USE" = true ]; then
_packages="$_packages $XVID_DEV"
fi
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi
if [ "$MP3LAME_USE" = true ]; then
_packages="$_packages $MP3LAME_DEV"
fi
if [ "$X264_USE" = true ]; then
_packages="$_packages $X264_DEV"
fi
if [ "$OPENJPEG_USE" = true ]; then
_packages="$_packages $OPENJPEG_DEV"
fi
if [ "$DISTRO" = "DEB" ]; then
print_info_ffmpeglink_DEB
elif [ "$DISTRO" = "RPM" ]; then
print_info_ffmpeglink_RPM
elif [ "$DISTRO" = "ARCH" ]; then
print_info_ffmpeglink_ARCH
# XXX TODO!
else
PRINT "<Could not determine additional link libraries needed for ffmpeg, replace this by valid list of libs...>"
fi
}
print_info() {
PRINT ""
PRINT ""
@@ -5801,7 +5731,7 @@ print_info() {
PRINT "If you're using CMake add this to your configuration flags:"
_buildargs="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB*"
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CLANG* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *BLOSC* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD*"
_buildargs="$_buildargs -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR*"
@@ -6002,12 +5932,10 @@ print_info() {
if [ "$FFMPEG_SKIP" = false ]; then
_1="-D WITH_CODEC_FFMPEG=ON"
_2="-D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;`print_info_ffmpeglink`'"
PRINT " $_1"
PRINT " $_2"
_buildargs="$_buildargs $_1 $_2"
_buildargs="$_buildargs $_1"
if [ -d $INST/ffmpeg ]; then
_1="-D FFMPEG=$INST/ffmpeg"
_1="-D FFMPEG_ROOT_DIR=$INST/ffmpeg"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi

View File

@@ -0,0 +1,374 @@
Index: nanovdb/nanovdb/NanoVDB.h
===================================================================
--- a/nanovdb/nanovdb/NanoVDB.h (revision 62751)
+++ b/nanovdb/nanovdb/NanoVDB.h (working copy)
@@ -152,8 +152,8 @@
#endif // __CUDACC_RTC__
-#ifdef __CUDACC__
-// Only define __hostdev__ when using NVIDIA CUDA compiler
+#if defined(__CUDACC__) || defined(__HIP__)
+// Only define __hostdev__ when using NVIDIA CUDA or HIP compiler
#define __hostdev__ __host__ __device__
#else
#define __hostdev__
@@ -461,7 +461,7 @@
/// Maximum floating-point values
template<typename T>
struct Maximum;
-#ifdef __CUDA_ARCH__
+#if defined(__CUDA_ARCH__) || defined(__HIP__)
template<>
struct Maximum<int>
{
@@ -1006,10 +1006,10 @@
using Vec3i = Vec3<int>;
/// @brief Return a single precision floating-point vector of this coordinate
-Vec3f Coord::asVec3s() const { return Vec3f(float(mVec[0]), float(mVec[1]), float(mVec[2])); }
+inline __hostdev__ Vec3f Coord::asVec3s() const { return Vec3f(float(mVec[0]), float(mVec[1]), float(mVec[2])); }
/// @brief Return a double precision floating-point vector of this coordinate
-Vec3d Coord::asVec3d() const { return Vec3d(double(mVec[0]), double(mVec[1]), double(mVec[2])); }
+inline __hostdev__ Vec3d Coord::asVec3d() const { return Vec3d(double(mVec[0]), double(mVec[1]), double(mVec[2])); }
// ----------------------------> Vec4 <--------------------------------------
@@ -1820,7 +1820,7 @@
}; // Map
template<typename Mat4T>
-void Map::set(const Mat4T& mat, const Mat4T& invMat, double taper)
+__hostdev__ void Map::set(const Mat4T& mat, const Mat4T& invMat, double taper)
{
float * mf = mMatF, *vf = mVecF;
float* mif = mInvMatF;
@@ -2170,7 +2170,7 @@
}; // Class Grid
template<typename TreeT>
-int Grid<TreeT>::findBlindDataForSemantic(GridBlindDataSemantic semantic) const
+__hostdev__ int Grid<TreeT>::findBlindDataForSemantic(GridBlindDataSemantic semantic) const
{
for (uint32_t i = 0, n = blindDataCount(); i < n; ++i)
if (blindMetaData(i).mSemantic == semantic)
@@ -2328,7 +2328,7 @@
}; // Tree class
template<typename RootT>
-void Tree<RootT>::extrema(ValueType& min, ValueType& max) const
+__hostdev__ void Tree<RootT>::extrema(ValueType& min, ValueType& max) const
{
min = this->root().valueMin();
max = this->root().valueMax();
@@ -2336,7 +2336,7 @@
template<typename RootT>
template<typename NodeT>
-const NodeT* Tree<RootT>::getNode(uint32_t i) const
+__hostdev__ const NodeT* Tree<RootT>::getNode(uint32_t i) const
{
static_assert(is_same<TreeNodeT<NodeT::LEVEL>, NodeT>::value, "Tree::getNode: unvalid node type");
NANOVDB_ASSERT(i < DataType::mCount[NodeT::LEVEL]);
@@ -2345,7 +2345,7 @@
template<typename RootT>
template<int LEVEL>
-const typename TreeNode<Tree<RootT>, LEVEL>::type* Tree<RootT>::getNode(uint32_t i) const
+__hostdev__ const typename TreeNode<Tree<RootT>, LEVEL>::type* Tree<RootT>::getNode(uint32_t i) const
{
NANOVDB_ASSERT(i < DataType::mCount[LEVEL]);
return reinterpret_cast<const TreeNodeT<LEVEL>*>(reinterpret_cast<const uint8_t*>(this) + DataType::mBytes[LEVEL]) + i;
@@ -2353,7 +2353,7 @@
template<typename RootT>
template<typename NodeT>
-NodeT* Tree<RootT>::getNode(uint32_t i)
+__hostdev__ NodeT* Tree<RootT>::getNode(uint32_t i)
{
static_assert(is_same<TreeNodeT<NodeT::LEVEL>, NodeT>::value, "Tree::getNode: invalid node type");
NANOVDB_ASSERT(i < DataType::mCount[NodeT::LEVEL]);
@@ -2362,7 +2362,7 @@
template<typename RootT>
template<int LEVEL>
-typename TreeNode<Tree<RootT>, LEVEL>::type* Tree<RootT>::getNode(uint32_t i)
+__hostdev__ typename TreeNode<Tree<RootT>, LEVEL>::type* Tree<RootT>::getNode(uint32_t i)
{
NANOVDB_ASSERT(i < DataType::mCount[LEVEL]);
return reinterpret_cast<TreeNodeT<LEVEL>*>(reinterpret_cast<uint8_t*>(this) + DataType::mBytes[LEVEL]) + i;
@@ -2370,7 +2370,7 @@
template<typename RootT>
template<typename NodeT>
-uint32_t Tree<RootT>::getNodeID(const NodeT& node) const
+__hostdev__ uint32_t Tree<RootT>::getNodeID(const NodeT& node) const
{
static_assert(is_same<TreeNodeT<NodeT::LEVEL>, NodeT>::value, "Tree::getNodeID: invalid node type");
const NodeT* first = reinterpret_cast<const NodeT*>(reinterpret_cast<const uint8_t*>(this) + DataType::mBytes[NodeT::LEVEL]);
@@ -2380,7 +2380,7 @@
template<typename RootT>
template<typename NodeT>
-uint32_t Tree<RootT>::getLinearOffset(const NodeT& node) const
+__hostdev__ uint32_t Tree<RootT>::getLinearOffset(const NodeT& node) const
{
return this->getNodeID(node) + DataType::mPFSum[NodeT::LEVEL];
}
@@ -3366,7 +3366,7 @@
}; // LeafNode class
template<typename ValueT, typename CoordT, template<uint32_t> class MaskT, uint32_t LOG2DIM>
-inline void LeafNode<ValueT, CoordT, MaskT, LOG2DIM>::updateBBox()
+inline __hostdev__ void LeafNode<ValueT, CoordT, MaskT, LOG2DIM>::updateBBox()
{
static_assert(LOG2DIM == 3, "LeafNode::updateBBox: only supports LOGDIM = 3!");
if (!this->isActive()) return;
Index: nanovdb/nanovdb/util/SampleFromVoxels.h
===================================================================
--- a/nanovdb/nanovdb/util/SampleFromVoxels.h (revision 62751)
+++ b/nanovdb/nanovdb/util/SampleFromVoxels.h (working copy)
@@ -22,7 +22,7 @@
#define NANOVDB_SAMPLE_FROM_VOXELS_H_HAS_BEEN_INCLUDED
// Only define __hostdev__ when compiling as NVIDIA CUDA
-#ifdef __CUDACC__
+#if defined(__CUDACC__) || defined(__HIP__)
#define __hostdev__ __host__ __device__
#else
#include <cmath> // for floor
@@ -136,7 +136,7 @@
template<typename TreeOrAccT>
template<typename Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 0, true>::operator()(const Vec3T& xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 0, true>::operator()(const Vec3T& xyz) const
{
const CoordT ijk = Round<CoordT>(xyz);
if (ijk != mPos) {
@@ -147,7 +147,7 @@
}
template<typename TreeOrAccT>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 0, true>::operator()(const CoordT& ijk) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 0, true>::operator()(const CoordT& ijk) const
{
if (ijk != mPos) {
mPos = ijk;
@@ -158,7 +158,7 @@
template<typename TreeOrAccT>
template<typename Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 0, false>::operator()(const Vec3T& xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 0, false>::operator()(const Vec3T& xyz) const
{
return mAcc.getValue(Round<CoordT>(xyz));
}
@@ -195,7 +195,7 @@
}; // TrilinearSamplerBase
template<typename TreeOrAccT>
-void TrilinearSampler<TreeOrAccT>::stencil(CoordT& ijk, ValueT (&v)[2][2][2]) const
+__hostdev__ void TrilinearSampler<TreeOrAccT>::stencil(CoordT& ijk, ValueT (&v)[2][2][2]) const
{
v[0][0][0] = mAcc.getValue(ijk); // i, j, k
@@ -224,7 +224,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType TrilinearSampler<TreeOrAccT>::sample(const Vec3T<RealT> &uvw, const ValueT (&v)[2][2][2])
+__hostdev__ typename TreeOrAccT::ValueType TrilinearSampler<TreeOrAccT>::sample(const Vec3T<RealT> &uvw, const ValueT (&v)[2][2][2])
{
#if 0
auto lerp = [](ValueT a, ValueT b, ValueT w){ return fma(w, b-a, a); };// = w*(b-a) + a
@@ -239,7 +239,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-Vec3T<typename TreeOrAccT::ValueType> TrilinearSampler<TreeOrAccT>::gradient(const Vec3T<RealT> &uvw, const ValueT (&v)[2][2][2])
+__hostdev__ Vec3T<typename TreeOrAccT::ValueType> TrilinearSampler<TreeOrAccT>::gradient(const Vec3T<RealT> &uvw, const ValueT (&v)[2][2][2])
{
static_assert(std::is_floating_point<ValueT>::value, "TrilinearSampler::gradient requires a floating-point type");
#if 0
@@ -270,7 +270,7 @@
}
template<typename TreeOrAccT>
-bool TrilinearSampler<TreeOrAccT>::zeroCrossing(const ValueT (&v)[2][2][2])
+__hostdev__ bool TrilinearSampler<TreeOrAccT>::zeroCrossing(const ValueT (&v)[2][2][2])
{
static_assert(std::is_floating_point<ValueT>::value, "TrilinearSampler::zeroCrossing requires a floating-point type");
const bool less = v[0][0][0] < ValueT(0);
@@ -363,7 +363,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, true>::operator()(Vec3T<RealT> xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, true>::operator()(Vec3T<RealT> xyz) const
{
this->cache(xyz);
return BaseT::sample(xyz, mVal);
@@ -370,7 +370,7 @@
}
template<typename TreeOrAccT>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, true>::operator()(const CoordT &ijk) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, true>::operator()(const CoordT &ijk) const
{
return ijk == mPos ? mVal[0][0][0] : BaseT::mAcc.getValue(ijk);
}
@@ -377,7 +377,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-Vec3T<typename TreeOrAccT::ValueType> SampleFromVoxels<TreeOrAccT, 1, true>::gradient(Vec3T<RealT> xyz) const
+__hostdev__ Vec3T<typename TreeOrAccT::ValueType> SampleFromVoxels<TreeOrAccT, 1, true>::gradient(Vec3T<RealT> xyz) const
{
this->cache(xyz);
return BaseT::gradient(xyz, mVal);
@@ -393,7 +393,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-void SampleFromVoxels<TreeOrAccT, 1, true>::cache(Vec3T<RealT>& xyz) const
+__hostdev__ void SampleFromVoxels<TreeOrAccT, 1, true>::cache(Vec3T<RealT>& xyz) const
{
CoordT ijk = Floor<CoordT>(xyz);
if (ijk != mPos) {
@@ -406,7 +406,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, false>::operator()(Vec3T<RealT> xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, false>::operator()(Vec3T<RealT> xyz) const
{
ValueT val[2][2][2];
CoordT ijk = Floor<CoordT>(xyz);
@@ -418,7 +418,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, false>::operator()(Vec3T<RealT> xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 1, false>::operator()(Vec3T<RealT> xyz) const
{
auto lerp = [](ValueT a, ValueT b, RealT w) { return a + ValueT(w) * (b - a); };
@@ -463,7 +463,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-inline Vec3T<typename TreeOrAccT::ValueType> SampleFromVoxels<TreeOrAccT, 1, false>::gradient(Vec3T<RealT> xyz) const
+inline __hostdev__ Vec3T<typename TreeOrAccT::ValueType> SampleFromVoxels<TreeOrAccT, 1, false>::gradient(Vec3T<RealT> xyz) const
{
ValueT val[2][2][2];
CoordT ijk = Floor<CoordT>(xyz);
@@ -473,7 +473,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-bool SampleFromVoxels<TreeOrAccT, 1, false>::zeroCrossing(Vec3T<RealT> xyz) const
+__hostdev__ bool SampleFromVoxels<TreeOrAccT, 1, false>::zeroCrossing(Vec3T<RealT> xyz) const
{
ValueT val[2][2][2];
CoordT ijk = Floor<CoordT>(xyz);
@@ -510,7 +510,7 @@
}; // TriquadraticSamplerBase
template<typename TreeOrAccT>
-void TriquadraticSampler<TreeOrAccT>::stencil(const CoordT &ijk, ValueT (&v)[3][3][3]) const
+__hostdev__ void TriquadraticSampler<TreeOrAccT>::stencil(const CoordT &ijk, ValueT (&v)[3][3][3]) const
{
CoordT p(ijk[0] - 1, 0, 0);
for (int dx = 0; dx < 3; ++dx, ++p[0]) {
@@ -526,7 +526,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType TriquadraticSampler<TreeOrAccT>::sample(const Vec3T<RealT> &uvw, const ValueT (&v)[3][3][3])
+__hostdev__ typename TreeOrAccT::ValueType TriquadraticSampler<TreeOrAccT>::sample(const Vec3T<RealT> &uvw, const ValueT (&v)[3][3][3])
{
auto kernel = [](const ValueT* value, double weight)->ValueT {
return weight * (weight * (0.5f * (value[0] + value[2]) - value[1]) +
@@ -545,7 +545,7 @@
}
template<typename TreeOrAccT>
-bool TriquadraticSampler<TreeOrAccT>::zeroCrossing(const ValueT (&v)[3][3][3])
+__hostdev__ bool TriquadraticSampler<TreeOrAccT>::zeroCrossing(const ValueT (&v)[3][3][3])
{
static_assert(std::is_floating_point<ValueT>::value, "TrilinearSampler::zeroCrossing requires a floating-point type");
const bool less = v[0][0][0] < ValueT(0);
@@ -624,7 +624,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 2, true>::operator()(Vec3T<RealT> xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 2, true>::operator()(Vec3T<RealT> xyz) const
{
this->cache(xyz);
return BaseT::sample(xyz, mVal);
@@ -631,7 +631,7 @@
}
template<typename TreeOrAccT>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 2, true>::operator()(const CoordT &ijk) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 2, true>::operator()(const CoordT &ijk) const
{
return ijk == mPos ? mVal[1][1][1] : BaseT::mAcc.getValue(ijk);
}
@@ -646,7 +646,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-void SampleFromVoxels<TreeOrAccT, 2, true>::cache(Vec3T<RealT>& xyz) const
+__hostdev__ void SampleFromVoxels<TreeOrAccT, 2, true>::cache(Vec3T<RealT>& xyz) const
{
CoordT ijk = Floor<CoordT>(xyz);
if (ijk != mPos) {
@@ -657,7 +657,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 2, false>::operator()(Vec3T<RealT> xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 2, false>::operator()(Vec3T<RealT> xyz) const
{
ValueT val[3][3][3];
CoordT ijk = Floor<CoordT>(xyz);
@@ -667,7 +667,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-bool SampleFromVoxels<TreeOrAccT, 2, false>::zeroCrossing(Vec3T<RealT> xyz) const
+__hostdev__ bool SampleFromVoxels<TreeOrAccT, 2, false>::zeroCrossing(Vec3T<RealT> xyz) const
{
ValueT val[3][3][3];
CoordT ijk = Floor<CoordT>(xyz);
@@ -710,7 +710,7 @@
}; // TricubicSampler
template<typename TreeOrAccT>
-void TricubicSampler<TreeOrAccT>::stencil(const CoordT& ijk, ValueT (&C)[64]) const
+__hostdev__ void TricubicSampler<TreeOrAccT>::stencil(const CoordT& ijk, ValueT (&C)[64]) const
{
auto fetch = [&](int i, int j, int k) -> ValueT& { return C[((i + 1) << 4) + ((j + 1) << 2) + k + 1]; };
@@ -929,7 +929,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 3, true>::operator()(Vec3T<RealT> xyz) const
+__hostdev__ typename TreeOrAccT::ValueType SampleFromVoxels<TreeOrAccT, 3, true>::operator()(Vec3T<RealT> xyz) const
{
this->cache(xyz);
return BaseT::sample(xyz, mC);
@@ -937,7 +937,7 @@
template<typename TreeOrAccT>
template<typename RealT, template<typename...> class Vec3T>
-void SampleFromVoxels<TreeOrAccT, 3, true>::cache(Vec3T<RealT>& xyz) const
+__hostdev__ void SampleFromVoxels<TreeOrAccT, 3, true>::cache(Vec3T<RealT>& xyz) const
{
CoordT ijk = Floor<CoordT>(xyz);
if (ijk != mPos) {

View File

@@ -197,3 +197,38 @@ index 67ec0d15f..6dc3e85a0 100644
#else
#error Unknown architecture.
#endif
diff --git a/pxr/base/arch/demangle.cpp b/pxr/base/arch/demangle.cpp
index 67ec0d15f..6dc3e85a0 100644
--- a/pxr/base/arch/demangle.cpp
+++ b/pxr/base/arch/demangle.cpp
@@ -36,6 +36,7 @@
#if (ARCH_COMPILER_GCC_MAJOR == 3 && ARCH_COMPILER_GCC_MINOR >= 1) || \
ARCH_COMPILER_GCC_MAJOR > 3 || defined(ARCH_COMPILER_CLANG)
#define _AT_LEAST_GCC_THREE_ONE_OR_CLANG
+#include <cxxabi.h>
#endif
PXR_NAMESPACE_OPEN_SCOPE
@@ -138,7 +139,6 @@
#endif
#if defined(_AT_LEAST_GCC_THREE_ONE_OR_CLANG)
-#include <cxxabi.h>
/*
* This routine doesn't work when you get to gcc3.4.
diff --git a/pxr/base/work/singularTask.h b/pxr/base/work/singularTask.h
index 67ec0d15f..6dc3e85a0 100644
--- a/pxr/base/work/singularTask.h
+++ b/pxr/base/work/singularTask.h
@@ -120,7 +120,7 @@
// case we go again to ensure the task can do whatever it
// was awakened to do. Once we successfully take the count
// to zero, we stop.
- size_t old = count;
+ std::size_t old = count;
do { _fn(); } while (
!count.compare_exchange_strong(old, 0));
});

View File

@@ -1,64 +1,39 @@
@echo off
if NOT "%1" == "" (
if "%1" == "2013" (
echo "Building for VS2013"
set VSVER=12.0
set VSVER_SHORT=12
set BuildDir=VS12
goto par2
)
if "%1" == "2015" (
echo "Building for VS2015"
set VSVER=14.0
set VSVER_SHORT=14
set BuildDir=VS14
goto par2
)
if "%1" == "2017" (
echo "Building for VS2017"
set VSVER=15.0
set VSVER_SHORT=15
set BuildDir=VS15
goto par2
)
if "%1" == "2019" (
echo "Building for VS2019"
set VSVER=15.0
set VSVER_SHORT=15
set BuildDir=VS15
goto par2
)
)
:usage
Echo Usage build_deps 2013/2015/2017 x64/x86
Echo Usage build_deps 2017/2019 x64
goto exit
:par2
if NOT "%2" == "" (
if "%2" == "x86" (
echo "Building for x86"
set HARVESTROOT=Windows_vc
set ARCH=86
if "%1" == "2013" (
set CMAKE_BUILDER=Visual Studio 12 2013
)
if "%1" == "2015" (
set CMAKE_BUILDER=Visual Studio 14 2015
)
if "%1" == "2017" (
set CMAKE_BUILDER=Visual Studio 15 2017
)
goto start
)
if "%2" == "x64" (
echo "Building for x64"
set HARVESTROOT=Win64_vc
set ARCH=64
if "%1" == "2013" (
set CMAKE_BUILDER=Visual Studio 12 2013 Win64
)
if "%1" == "2015" (
set CMAKE_BUILDER=Visual Studio 14 2015 Win64
if "%1" == "2019" (
set CMAKE_BUILDER=Visual Studio 16 2019
set CMAKE_BUILD_ARCH=-A x64
)
if "%1" == "2017" (
set CMAKE_BUILDER=Visual Studio 15 2017 Win64
set CMAKE_BUILD_ARCH=
)
goto start
)
)
@@ -120,7 +95,7 @@ set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads
mkdir %STAGING%\%BuildDir%%ARCH%R
cd %Staging%\%BuildDir%%ARCH%R
echo %DATE% %TIME% : Start > %StatusFile%
cmake -G "%CMAKE_BUILDER%" -Thost=x64 %SOURCE_DIR% -DPACKAGE_DIR=%BUILD_DIR%/packages -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DBUILD_MODE=Release -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/
cmake -G "%CMAKE_BUILDER%" %CMAKE_BUILD_ARCH% -Thost=x64 %SOURCE_DIR% -DPACKAGE_DIR=%BUILD_DIR%/packages -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DBUILD_MODE=Release -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/
echo %DATE% %TIME% : Release Configuration done >> %StatusFile%
if "%dobuild%" == "1" (
msbuild /m "ll.vcxproj" /p:Configuration=Release /fl /flp:logfile=BlenderDeps_llvm.log;Verbosity=normal
@@ -133,7 +108,7 @@ if "%NODEBUG%" == "1" goto exit
cd %BUILD_DIR%
mkdir %STAGING%\%BuildDir%%ARCH%D
cd %Staging%\%BuildDir%%ARCH%D
cmake -G "%CMAKE_BUILDER%" -Thost=x64 %SOURCE_DIR% -DPACKAGE_DIR=%BUILD_DIR%/packages -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS%
cmake -G "%CMAKE_BUILDER%" %CMAKE_BUILD_ARCH% -Thost=x64 %SOURCE_DIR% -DPACKAGE_DIR=%BUILD_DIR%/packages -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS%
echo %DATE% %TIME% : Debug Configuration done >> %StatusFile%
if "%dobuild%" == "1" (
msbuild /m "ll.vcxproj" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps_llvm.log;;Verbosity=normal

View File

@@ -0,0 +1,83 @@
# - Find Brotli library (compression for freetype/woff2).
# This module defines
# BROTLI_INCLUDE_DIRS, where to find Brotli headers, Set when
# BROTLI_INCLUDE_DIR is found.
# BROTLI_LIBRARIES, libraries to link against to use Brotli.
# BROTLI_ROOT_DIR, The base directory to search for Brotli.
# This can also be an environment variable.
# BROTLI_FOUND, If false, do not try to use Brotli.
#
#=============================================================================
# Copyright 2022 Blender Foundation.
#
# Distributed under the OSI-approved BSD 3-Clause License,
# see accompanying file BSD-3-Clause-license.txt for details.
#=============================================================================
# If BROTLI_ROOT_DIR was defined in the environment, use it.
IF(NOT BROTLI_ROOT_DIR AND NOT $ENV{BROTLI_ROOT_DIR} STREQUAL "")
SET(BROTLI_ROOT_DIR $ENV{BROTLI_ROOT_DIR})
ENDIF()
SET(_BROTLI_SEARCH_DIRS
${BROTLI_ROOT_DIR}
)
FIND_PATH(BROTLI_INCLUDE_DIR
NAMES
brotli/decode.h
HINTS
${_BROTLI_SEARCH_DIRS}
PATH_SUFFIXES
include
DOC "Brotli header files"
)
FIND_LIBRARY(BROTLI_LIBRARY_COMMON
NAMES
# Some builds use a special `-static` postfix in their static libraries names.
brotlicommon-static
brotlicommon
HINTS
${_BROTLI_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
DOC "Brotli static common library"
)
FIND_LIBRARY(BROTLI_LIBRARY_DEC
NAMES
# Some builds use a special `-static` postfix in their static libraries names.
brotlidec-static
brotlidec
HINTS
${_BROTLI_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
DOC "Brotli static decode library"
)
IF(${BROTLI_LIBRARY_COMMON_NOTFOUND} or ${BROTLI_LIBRARY_DEC_NOTFOUND})
set(BROTLI_FOUND FALSE)
ELSE()
# handle the QUIETLY and REQUIRED arguments and set BROTLI_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Brotli DEFAULT_MSG BROTLI_LIBRARY_COMMON BROTLI_LIBRARY_DEC BROTLI_INCLUDE_DIR)
IF(BROTLI_FOUND)
get_filename_component(BROTLI_LIBRARY_DIR ${BROTLI_LIBRARY_COMMON} DIRECTORY)
SET(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
SET(BROTLI_LIBRARIES ${BROTLI_LIBRARY_DEC} ${BROTLI_LIBRARY_COMMON})
ENDIF()
ENDIF()
MARK_AS_ADVANCED(
BROTLI_INCLUDE_DIR
BROTLI_LIBRARY_COMMON
BROTLI_LIBRARY_DEC
BROTLI_LIBRARY_DIR
)
UNSET(_BROTLI_SEARCH_DIRS)

View File

@@ -33,6 +33,8 @@ if(NOT FFMPEG_FIND_COMPONENTS)
avfilter
avformat
avutil
swscale
swresample
)
endif()
@@ -50,9 +52,9 @@ foreach(_component ${FFMPEG_FIND_COMPONENTS})
string(TOUPPER ${_component} _upper_COMPONENT)
find_library(FFMPEG_${_upper_COMPONENT}_LIBRARY
NAMES
${_upper_COMPONENT}
${_component}
HINTS
${LIBDIR}/ffmpeg
${_ffmpeg_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)

View File

@@ -21,7 +21,7 @@ ENDIF()
SET(_optix_SEARCH_DIRS
${OPTIX_ROOT_DIR}
"$ENV{PROGRAMDATA}/NVIDIA Corporation/OptiX SDK 7.0.0"
"$ENV{PROGRAMDATA}/NVIDIA Corporation/OptiX SDK 7.3.0"
)
FIND_PATH(OPTIX_INCLUDE_DIR

View File

@@ -114,7 +114,7 @@ def is_c_header(filename: str) -> bool:
def is_c(filename: str) -> bool:
ext = splitext(filename)[1]
return (ext in {".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl"})
return (ext in {".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl", ".metal"})
def is_c_any(filename: str) -> bool:

View File

@@ -180,7 +180,7 @@ def create_nb_project_main():
f.write(' </logicalFolder>\n')
f.write(' </logicalFolder>\n')
# default, but this dir is infact not in blender dir so we can ignore it
# default, but this dir is in fact not in blender dir so we can ignore it
# f.write(' <sourceFolderFilter>^(nbproject)$</sourceFolderFilter>\n')
f.write(r' <sourceFolderFilter>^(nbproject|__pycache__|.*\.py|.*\.html|.*\.blend)$</sourceFolderFilter>\n')

View File

@@ -19,9 +19,6 @@ set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
set(WITH_COREAUDIO OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_OPTIX OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_EMBREE OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL OFF CACHE BOOL "" FORCE)
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)

View File

@@ -61,6 +61,7 @@ set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
# platform dependent options
if(APPLE)
set(WITH_COREAUDIO ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_METAL ON CACHE BOOL "" FORCE)
endif()
if(NOT WIN32)
set(WITH_JACK ON CACHE BOOL "" FORCE)
@@ -81,4 +82,5 @@ if(NOT APPLE)
set(WITH_CYCLES_DEVICE_OPTIX ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUBIN_COMPILER OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_HIP_BINARIES ON CACHE BOOL "" FORCE)
endif()

View File

@@ -488,7 +488,6 @@ function(blender_add_test_executable
include_directories(${includes})
include_directories(${includes_sys})
setup_libdirs()
BLENDER_SRC_GTEST_EX(
NAME ${name}
@@ -525,83 +524,6 @@ function(setup_heavy_lib_pool)
endif()
endfunction()
function(SETUP_LIBDIRS)
# NOTE: For all new libraries, use absolute library paths.
# This should eventually be phased out.
# APPLE plaform uses full paths for linking libraries, and avoids link_directories.
if(NOT MSVC AND NOT APPLE)
link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs
link_directories(${PYTHON_LIBPATH})
endif()
if(WITH_SDL AND NOT WITH_SDL_DYNLOAD)
link_directories(${SDL_LIBPATH})
endif()
if(WITH_CODEC_FFMPEG)
link_directories(${FFMPEG_LIBPATH})
endif()
if(WITH_IMAGE_OPENEXR)
link_directories(${OPENEXR_LIBPATH})
endif()
if(WITH_IMAGE_TIFF)
link_directories(${TIFF_LIBPATH})
endif()
if(WITH_BOOST)
link_directories(${BOOST_LIBPATH})
endif()
if(WITH_OPENIMAGEIO)
link_directories(${OPENIMAGEIO_LIBPATH})
endif()
if(WITH_OPENIMAGEDENOISE)
link_directories(${OPENIMAGEDENOISE_LIBPATH})
endif()
if(WITH_OPENCOLORIO)
link_directories(${OPENCOLORIO_LIBPATH})
endif()
if(WITH_OPENVDB)
link_directories(${OPENVDB_LIBPATH})
endif()
if(WITH_OPENAL)
link_directories(${OPENAL_LIBPATH})
endif()
if(WITH_JACK AND NOT WITH_JACK_DYNLOAD)
link_directories(${JACK_LIBPATH})
endif()
if(WITH_PULSEAUDIO AND NOT WITH_PULSEAUDIO_DYNLOAD)
link_directories(${LIBPULSE_LIBPATH})
endif()
if(WITH_CODEC_SNDFILE)
link_directories(${LIBSNDFILE_LIBPATH})
endif()
if(WITH_FFTW3)
link_directories(${FFTW3_LIBPATH})
endif()
if(WITH_OPENCOLLADA)
link_directories(${OPENCOLLADA_LIBPATH})
# # Never set
# link_directories(${PCRE_LIBPATH})
# link_directories(${EXPAT_LIBPATH})
endif()
if(WITH_LLVM)
link_directories(${LLVM_LIBPATH})
endif()
if(WITH_ALEMBIC)
link_directories(${ALEMBIC_LIBPATH})
endif()
if(WITH_GMP)
link_directories(${GMP_LIBPATH})
endif()
if(WIN32 AND NOT UNIX)
link_directories(${PTHREADS_LIBPATH})
endif()
endif()
endfunction()
# Platform specific linker flags for targets.
function(setup_platform_linker_flags
target)
@@ -1292,29 +1214,6 @@ macro(openmp_delayload
endif()
endmacro()
macro(blender_precompile_headers target cpp header)
if(MSVC)
# get the name for the pch output file
get_filename_component(pchbase ${cpp} NAME_WE)
set(pchfinal "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${pchbase}.pch")
# mark the cpp as the one outputting the pch
set_property(SOURCE ${cpp} APPEND PROPERTY OBJECT_OUTPUTS "${pchfinal}")
# get all sources for the target
get_target_property(sources ${target} SOURCES)
# make all sources depend on the pch to enforce the build order
foreach(src ${sources})
set_property(SOURCE ${src} APPEND PROPERTY OBJECT_DEPENDS "${pchfinal}")
endforeach()
target_sources(${target} PRIVATE ${cpp} ${header})
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "/Yu${header} /Fp${pchfinal} /FI${header}")
set_source_files_properties(${cpp} PROPERTIES COMPILE_FLAGS "/Yc${header} /Fp${pchfinal}")
endif()
endmacro()
macro(set_and_warn_dependency
_dependency _setting _val)
# when $_dependency is disabled, forces $_setting = $_val

View File

@@ -166,13 +166,18 @@ if(WITH_FFTW3)
find_package(Fftw3)
endif()
# FreeType compiled with Brotli compression for woff2.
find_package(Freetype REQUIRED)
list(APPEND FREETYPE_LIBRARIES
${LIBDIR}/brotli/lib/libbrotlicommon-static.a
${LIBDIR}/brotli/lib/libbrotlidec-static.a)
if(WITH_IMAGE_OPENEXR)
find_package(OpenEXR)
endif()
if(WITH_CODEC_FFMPEG)
set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg)
set(FFMPEG_FIND_COMPONENTS
avcodec avdevice avformat avutil
mp3lame ogg opus swresample swscale
@@ -257,9 +262,6 @@ if(WITH_BOOST)
if(WITH_INTERNATIONAL)
list(APPEND _boost_FIND_COMPONENTS locale)
endif()
if(WITH_CYCLES_NETWORK)
list(APPEND _boost_FIND_COMPONENTS serialization)
endif()
if(WITH_OPENVDB)
list(APPEND _boost_FIND_COMPONENTS iostreams)
endif()
@@ -339,7 +341,7 @@ if(WITH_LLVM)
endif()
if(WITH_CYCLES_OSL)
if(WITH_CYCLES AND WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl)
find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
@@ -359,7 +361,7 @@ if(WITH_CYCLES_OSL)
endif()
endif()
if(WITH_CYCLES_EMBREE)
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED)
# Increase stack size for Embree, only works for executables.
if(NOT WITH_PYTHON_MODULE)
@@ -482,8 +484,11 @@ string(APPEND PLATFORM_LINKFLAGS " -stdlib=libc++")
# Suppress ranlib "has no symbols" warnings (workaround for T48250)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
# llvm-ranlib doesn't support this flag. Xcode's libtool does.
if(NOT ${CMAKE_RANLIB} MATCHES ".*llvm-ranlib$")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()
if(WITH_COMPILER_CCACHE)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode")
@@ -510,3 +515,6 @@ list(APPEND CMAKE_BUILD_RPATH "${OpenMP_LIBRARY_DIR}")
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
# Same as `CFBundleIdentifier` in Info.plist.
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.blenderfoundation.blender")

View File

@@ -96,7 +96,7 @@ else()
# Detect SDK version to use.
if(NOT DEFINED OSX_SYSTEM)
execute_process(
COMMAND xcrun --show-sdk-version
COMMAND xcrun --sdk macosx --show-sdk-version
OUTPUT_VARIABLE OSX_SYSTEM
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

View File

@@ -18,7 +18,7 @@
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
# Libraries configuration for any *nix system including Linux and Unix.
# Libraries configuration for any *nix system including Linux and Unix (excluding APPLE).
# Detect precompiled library directory
if(NOT DEFINED LIBDIR)
@@ -48,6 +48,9 @@ if(NOT DEFINED LIBDIR)
unset(LIBDIR_CENTOS7_ABI)
endif()
# Support restoring this value once pre-compiled libraries have been handled.
set(WITH_STATIC_LIBS_INIT ${WITH_STATIC_LIBS})
if(EXISTS ${LIBDIR})
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
@@ -100,7 +103,22 @@ find_package_wrapper(JPEG REQUIRED)
find_package_wrapper(PNG REQUIRED)
find_package_wrapper(ZLIB REQUIRED)
find_package_wrapper(Zstd REQUIRED)
find_package_wrapper(Freetype REQUIRED)
if(NOT WITH_SYSTEM_FREETYPE)
# FreeType compiled with Brotli compression for woff2.
find_package_wrapper(Freetype REQUIRED)
if(EXISTS ${LIBDIR})
find_package_wrapper(Brotli REQUIRED)
# NOTE: This is done on WIN32 & APPLE but fails on some Linux systems.
# See: https://devtalk.blender.org/t/22536
# So `BROTLI_LIBRARIES` need to be added `FREETYPE_LIBRARIES`.
#
# list(APPEND FREETYPE_LIBRARIES
# ${BROTLI_LIBRARIES}
# )
endif()
endif()
if(WITH_PYTHON)
# No way to set py35, remove for now.
@@ -178,26 +196,30 @@ endif()
if(WITH_CODEC_FFMPEG)
if(EXISTS ${LIBDIR})
# For precompiled lib directory, all ffmpeg dependencies are in the same folder
file(GLOB ffmpeg_libs ${LIBDIR}/ffmpeg/lib/*.a ${LIBDIR}/sndfile/lib/*.a)
set(FFMPEG ${LIBDIR}/ffmpeg CACHE PATH "FFMPEG Directory")
set(FFMPEG_LIBRARIES ${ffmpeg_libs} ${ffmpeg_libs} CACHE STRING "FFMPEG Libraries")
else()
set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg)
# Override FFMPEG components to also include static library dependencies
# included with precompiled libraries, and to ensure correct link order.
set(FFMPEG_FIND_COMPONENTS
avformat avcodec avdevice avutil swresample swscale
sndfile
FLAC
mp3lame
opus
theora theoradec theoraenc
vorbis vorbisenc vorbisfile ogg
vpx
x264
xvidcore)
elseif(FFMPEG)
# Old cache variable used for root dir, convert to new standard.
set(FFMPEG_ROOT_DIR ${FFMPEG})
endif()
find_package(FFmpeg)
mark_as_advanced(FFMPEG)
# lame, but until we have proper find module for ffmpeg
set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
if(EXISTS "${FFMPEG}/include/ffmpeg/")
list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg")
if(NOT FFMPEG_FOUND)
set(WITH_CODEC_FFMPEG OFF)
message(STATUS "FFmpeg not found, disabling it")
endif()
# end lameness
mark_as_advanced(FFMPEG_LIBRARIES)
set(FFMPEG_LIBPATH ${FFMPEG}/lib)
endif()
if(WITH_FFTW3)
@@ -241,7 +263,7 @@ if(WITH_INPUT_NDOF)
endif()
endif()
if(WITH_CYCLES_OSL)
if(WITH_CYCLES AND WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT)
set(OSL_ROOT ${CYCLES_OSL})
@@ -314,7 +336,7 @@ if(WITH_BOOST)
endif()
set(Boost_USE_MULTITHREADED ON)
set(__boost_packages filesystem regex thread date_time)
if(WITH_CYCLES_OSL)
if(WITH_CYCLES AND WITH_CYCLES_OSL)
if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6"))
list(APPEND __boost_packages wave)
else()
@@ -323,9 +345,6 @@ if(WITH_BOOST)
if(WITH_INTERNATIONAL)
list(APPEND __boost_packages locale)
endif()
if(WITH_CYCLES_NETWORK)
list(APPEND __boost_packages serialization)
endif()
if(WITH_OPENVDB)
list(APPEND __boost_packages iostreams)
endif()
@@ -403,7 +422,7 @@ if(WITH_OPENCOLORIO)
endif()
endif()
if(WITH_CYCLES_EMBREE)
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED)
endif()
@@ -535,6 +554,21 @@ add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
#
# Keep last, so indirectly linked libraries don't override our own pre-compiled libs.
if(EXISTS ${LIBDIR})
# Clear the prefix path as it causes the `LIBDIR` to override system locations.
unset(CMAKE_PREFIX_PATH)
# Since the pre-compiled `LIBDIR` directories have been handled, don't prefer static libraries.
set(WITH_STATIC_LIBS ${WITH_STATIC_LIBS_INIT})
endif()
if(WITH_SYSTEM_FREETYPE)
find_package_wrapper(Freetype)
if(NOT FREETYPE_FOUND)
message(FATAL_ERROR "Failed finding system FreeType version!")
endif()
endif()
if(WITH_LZO AND WITH_SYSTEM_LZO)
find_package_wrapper(LZO)
if(NOT LZO_FOUND)
@@ -647,6 +681,9 @@ endif()
# ----------------------------------------------------------------------------
# Compilers
# Only set the linker once.
set(_IS_LINKER_DEFAULT ON)
# GNU Compiler
if(CMAKE_COMPILER_IS_GNUCC)
# ffp-contract=off:
@@ -665,26 +702,89 @@ if(CMAKE_COMPILER_IS_GNUCC)
string(PREPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO "${GCC_EXTRA_FLAGS_RELEASE} ")
unset(GCC_EXTRA_FLAGS_RELEASE)
if(WITH_LINKER_GOLD)
# NOTE(@campbellbarton): Eventually mold will be able to use `-fuse-ld=mold`,
# however at the moment this only works for GCC 12.1+ (unreleased at time of writing).
# So a workaround is used here "-B" which points to another path to find system commands
# such as `ld`.
if(WITH_LINKER_MOLD AND _IS_LINKER_DEFAULT)
find_program(MOLD_BIN "mold")
mark_as_advanced(MOLD_BIN)
if(NOT MOLD_BIN)
message(STATUS "The \"mold\" binary could not be found, using system linker.")
set(WITH_LINKER_MOLD OFF)
else()
# By default mold installs the binary to:
# - `{PREFIX}/bin/mold` as well as a symbolic-link in...
# - `{PREFIX}/lib/mold/ld`.
# (where `PREFIX` is typically `/usr/`).
#
# This block of code finds `{PREFIX}/lib/mold` from the `mold` binary.
# Other methods of searching for the path could also be made to work,
# we could even make our own directory and symbolic-link, however it's more
# convenient to use the one provided by mold.
#
# Use the binary path to "mold", to find the common prefix which contains "lib/mold".
# The parent directory: e.g. `/usr/bin/mold` -> `/usr/bin/`.
get_filename_component(MOLD_PREFIX "${MOLD_BIN}" DIRECTORY)
# The common prefix path: e.g. `/usr/bin/` -> `/usr/` to use as a hint.
get_filename_component(MOLD_PREFIX "${MOLD_PREFIX}" DIRECTORY)
# Find `{PREFIX}/lib/mold/ld`, store the directory component (without the `ld`).
# Then pass `-B {PREFIX}/lib/mold` to GCC so the `ld` located there overrides the default.
find_path(
MOLD_BIN_DIR "ld"
HINTS "${MOLD_PREFIX}"
# The default path is `libexec`, Arch Linux for e.g.
# replaces this with `lib` so check both.
PATH_SUFFIXES "libexec/mold" "lib/mold" "lib64/mold"
NO_DEFAULT_PATH
NO_CACHE
)
if(NOT MOLD_BIN_DIR)
message(STATUS
"The mold linker could not find the directory containing the linker command "
"(typically "
"\"${MOLD_PREFIX}/libexec/mold/ld\") or "
"\"${MOLD_PREFIX}/lib/mold/ld\") using system linker.")
set(WITH_LINKER_MOLD OFF)
endif()
unset(MOLD_PREFIX)
endif()
if(WITH_LINKER_MOLD)
# GCC will search for `ld` in this directory first.
string(APPEND CMAKE_EXE_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
set(_IS_LINKER_DEFAULT OFF)
endif()
unset(MOLD_BIN)
unset(MOLD_BIN_DIR)
endif()
if(WITH_LINKER_GOLD AND _IS_LINKER_DEFAULT)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
string(APPEND CMAKE_C_FLAGS " -fuse-ld=gold")
string(APPEND CMAKE_CXX_FLAGS " -fuse-ld=gold")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
set(_IS_LINKER_DEFAULT OFF)
else()
message(STATUS "GNU gold linker isn't available, using the default system linker.")
endif()
unset(LD_VERSION)
endif()
if(WITH_LINKER_LLD)
if(WITH_LINKER_LLD AND _IS_LINKER_DEFAULT)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "LLD")
string(APPEND CMAKE_C_FLAGS " -fuse-ld=lld")
string(APPEND CMAKE_CXX_FLAGS " -fuse-ld=lld")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=lld")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=lld")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=lld")
set(_IS_LINKER_DEFAULT OFF)
else()
message(STATUS "LLD linker isn't available, using the default system linker.")
endif()
@@ -694,6 +794,28 @@ if(CMAKE_COMPILER_IS_GNUCC)
# CLang is the same as GCC for now.
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
if(WITH_LINKER_MOLD AND _IS_LINKER_DEFAULT)
find_program(MOLD_BIN "mold")
mark_as_advanced(MOLD_BIN)
if(NOT MOLD_BIN)
message(STATUS "The \"mold\" binary could not be found, using system linker.")
set(WITH_LINKER_MOLD OFF)
else()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
string(APPEND CMAKE_EXE_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
else()
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
endif()
set(_IS_LINKER_DEFAULT OFF)
endif()
unset(MOLD_BIN)
endif()
# Intel C++ Compiler
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
# think these next two are broken
@@ -717,6 +839,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
string(APPEND PLATFORM_LINKFLAGS " -static-intel")
endif()
unset(_IS_LINKER_DEFAULT)
# Avoid conflicts with Mesa llvmpipe, Luxrender, and other plug-ins that may
# use the same libraries as Blender with a different version or build options.
set(PLATFORM_LINKFLAGS

View File

@@ -347,7 +347,11 @@ set(FREETYPE_INCLUDE_DIRS
${LIBDIR}/freetype/include
${LIBDIR}/freetype/include/freetype2
)
set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib)
set(FREETYPE_LIBRARIES
${LIBDIR}/freetype/lib/freetype2ST.lib
${LIBDIR}/brotli/lib/brotlidec-static.lib
${LIBDIR}/brotli/lib/brotlicommon-static.lib
)
windows_find_package(freetype REQUIRED)
if(WITH_FFTW3)
@@ -477,7 +481,7 @@ if(WITH_PYTHON)
endif()
if(WITH_BOOST)
if(WITH_CYCLES_OSL)
if(WITH_CYCLES AND WITH_CYCLES_OSL)
set(boost_extra_libs wave)
endif()
if(WITH_INTERNATIONAL)
@@ -520,7 +524,7 @@ if(WITH_BOOST)
debug ${BOOST_LIBPATH}/libboost_thread-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_LIBPATH}/libboost_chrono-${BOOST_DEBUG_POSTFIX}
)
if(WITH_CYCLES_OSL)
if(WITH_CYCLES AND WITH_CYCLES_OSL)
set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
optimized ${BOOST_LIBPATH}/libboost_wave-${BOOST_POSTFIX}
debug ${BOOST_LIBPATH}/libboost_wave-${BOOST_DEBUG_POSTFIX})
@@ -708,7 +712,7 @@ if(WITH_CODEC_SNDFILE)
set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBPATH}/libsndfile-1.lib)
endif()
if(WITH_CYCLES_OSL)
if(WITH_CYCLES AND WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
set(OSL_SHADER_DIR ${CYCLES_OSL}/shaders)
# Shaders have moved around a bit between OSL versions, check multiple locations
@@ -741,7 +745,7 @@ if(WITH_CYCLES_OSL)
endif()
endif()
if(WITH_CYCLES_EMBREE)
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
windows_find_package(Embree)
if(NOT EMBREE_FOUND)
set(EMBREE_INCLUDE_DIRS ${LIBDIR}/embree/include)

View File

@@ -27,7 +27,7 @@ if(WITH_WINDOWS_BUNDLE_CRT)
# Install the CRT to the blender.crt Sub folder.
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ./blender.crt COMPONENT Libraries)
# Generating the manifest is a relativly expensive operation since
# Generating the manifest is a relatively expensive operation since
# it is collecting an sha1 hash for every file required. so only do
# this work when the libs have either changed or the manifest does
# not exist yet.

View File

@@ -3,7 +3,32 @@ for %%X in (svn.exe) do (set SVN=%%~$PATH:X)
for %%X in (cmake.exe) do (set CMAKE=%%~$PATH:X)
for %%X in (ctest.exe) do (set CTEST=%%~$PATH:X)
for %%X in (git.exe) do (set GIT=%%~$PATH:X)
REM For python, default on 39 but if that does not exist also check
REM the 310,311 and 312 folders to see if those are there, it checks
REM this far ahead to ensure good lib folder compatiblity in the future.
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\39\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done
)
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\310\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done
)
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\311\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done
)
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\312\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done
)
if NOT EXIST %PYTHON% (
echo Warning: Python not found, there is likely an issue with the library folder
set PYTHON=""
)
:detect_python_done
if NOT "%verbose%" == "" (
echo svn : "%SVN%"
echo cmake : "%CMAKE%"
@@ -11,7 +36,3 @@ if NOT "%verbose%" == "" (
echo git : "%GIT%"
echo python : "%PYTHON%"
)
if "%CMAKE%" == "" (
echo Cmake not found in path, required for building, exiting...
exit /b 1
)

View File

@@ -9,17 +9,11 @@ exit /b 1
:detect_done
echo found clang-format in %CF_PATH%
if EXIST %PYTHON% (
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\39\bin\python.exe
goto detect_python_done
if NOT EXIST %PYTHON% (
echo python not found, required for this operation
exit /b 1
)
echo python not found in lib folder
exit /b 1
:detect_python_done
echo found python (%PYTHON%)
set FORMAT_PATHS=%BLENDER_DIR%\source\tools\utils_maintenance\clang_format_paths.py
REM The formatting script expects clang-format to be in the current PATH.

View File

@@ -1,18 +1,8 @@
if EXIST "%PYTHON%" (
goto detect_python_done
if NOT EXIST %PYTHON% (
echo python not found, required for this operation
exit /b 1
)
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\39\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done
)
echo python not found at %PYTHON%
exit /b 1
:detect_python_done
echo found python (%PYTHON%)
call "%~dp0\find_inkscape.cmd"
if EXIST "%INKSCAPE_BIN%" (

View File

@@ -1,18 +1,8 @@
if EXIST %PYTHON% (
goto detect_python_done
if NOT EXIST %PYTHON% (
echo python not found, required for this operation
exit /b 1
)
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\39\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done
)
echo python not found at %PYTHON%
exit /b 1
:detect_python_done
echo found python (%PYTHON%)
call "%~dp0\find_blender.cmd"
if EXIST "%BLENDER_BIN%" (

View File

@@ -1,10 +1,7 @@
if EXIST %PYTHON% (
goto detect_python_done
if NOT EXIST %PYTHON% (
echo python not found, required for this operation
exit /b 1
)
echo python not found in lib folder
exit /b 1
:detect_python_done
REM Use -B to avoid writing __pycache__ in lib directory and causing update conflicts.

View File

@@ -6,91 +6,87 @@
* as part of the normal development process.
*/
/** \defgroup MEM Guarded memory (de)allocation
* \ingroup intern
/* TODO: other modules.
* - `libmv`
* - `cycles`
* - `opencolorio`
* - `opensubdiv`
* - `openvdb`
* - `quadriflow`
*/
/** \defgroup clog C-Logging (CLOG)
* \ingroup intern
*/
/** \defgroup intern_atomic Atomic Operations
* \ingroup intern */
/** \defgroup ctr container
* \ingroup intern
*/
/** \defgroup intern_clog C-Logging (CLOG)
* \ingroup intern */
/** \defgroup iksolver iksolver
* \ingroup intern
*/
/** \defgroup intern_eigen Eigen
* \ingroup intern */
/** \defgroup itasc itasc
* \ingroup intern
*/
/** \defgroup intern_glew-mx GLEW with Multiple Rendering Context's
* \ingroup intern */
/** \defgroup memutil memutil
* \ingroup intern
*/
/** \defgroup intern_iksolver Inverse Kinematics (Solver)
* \ingroup intern */
/** \defgroup mikktspace mikktspace
* \ingroup intern
*/
/** \defgroup intern_itasc Inverse Kinematics (ITASC)
* \ingroup intern */
/** \defgroup moto moto
* \ingroup intern
*/
/** \defgroup intern_libc_compat libc Compatibility For Linux
* \ingroup intern */
/** \defgroup eigen eigen
* \ingroup intern
*/
/** \defgroup intern_locale Locale
* \ingroup intern */
/** \defgroup smoke smoke
* \ingroup intern
*/
/** \defgroup intern_mantaflow Manta-Flow Fluid Simulation
* \ingroup intern */
/** \defgroup string string
* \ingroup intern
*/
/** \defgroup intern_mem Guarded Memory (de)allocation
* \ingroup intern */
/** \defgroup intern_memutil Memory Utilities (memutil)
* \ingroup intern */
/** \defgroup intern_mikktspace MikktSpace
* \ingroup intern */
/** \defgroup intern_rigidbody Rigid-Body C-API
* \ingroup intern */
/** \defgroup intern_sky_model Sky Model
* \ingroup intern */
/** \defgroup intern_utf_conv UTF-8/16 Conversion (utfconv)
* \ingroup intern */
/** \defgroup audaspace Audaspace
* \ingroup intern undoc
* \todo add to doxygen
*/
* \todo add to doxygen */
/** \defgroup audcoreaudio Audaspace CoreAudio
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audfx Audaspace FX
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audopenal Audaspace OpenAL
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audpulseaudio Audaspace PulseAudio
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audwasapi Audaspace WASAPI
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audpython Audaspace Python
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audsdl Audaspace SDL
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audsrc Audaspace SRC
*
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audffmpeg Audaspace FFMpeg
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audfftw Audaspace FFTW
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audjack Audaspace Jack
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup audsndfile Audaspace sndfile
* \ingroup audaspace
*/
* \ingroup audaspace */
/** \defgroup GHOST GHOST API
* \ingroup intern GUI

View File

@@ -5,7 +5,8 @@
/** \defgroup bmesh BMesh
* \ingroup blender
*/
/** \defgroup compositor Compositing */
/** \defgroup compositor Compositing
* \ingroup blender */
/** \defgroup python Python
* \ingroup blender
@@ -78,7 +79,8 @@
* \ingroup blender
*/
/** \defgroup data DNA, RNA and .blend access*/
/** \defgroup data DNA, RNA and .blend access
* \ingroup blender */
/** \defgroup gpu GPU
* \ingroup blender
@@ -101,11 +103,12 @@
* merged in docs.
*/
/** \defgroup gui GUI */
/**
* \defgroup gui GUI
* \ingroup blender */
/** \defgroup wm Window Manager
* \ingroup blender gui
*/
* \ingroup gui */
/* ================================ */
@@ -279,7 +282,8 @@
* \ingroup gui
*/
/** \defgroup externformats External Formats */
/** \defgroup externformats External Formats
* \ingroup blender */
/** \defgroup collada COLLADA
* \ingroup externformats
@@ -308,4 +312,7 @@
/* ================================ */
/** \defgroup undoc Undocumented
* \brief Modules and libraries that are still undocumented, or lacking proper integration into the doxygen system, are marked in this group. */
*
* \brief Modules and libraries that are still undocumented,
* or lacking proper integration into the doxygen system, are marked in this group.
*/

View File

@@ -61,7 +61,7 @@ def blender_extract_info(blender_bin: str) -> Dict[str, str]:
stdout=subprocess.PIPE,
).stdout.decode(encoding="utf-8")
blender_version_ouput = subprocess.run(
blender_version_output = subprocess.run(
[blender_bin, "--version"],
env=blender_env,
check=True,
@@ -73,7 +73,7 @@ def blender_extract_info(blender_bin: str) -> Dict[str, str]:
# check for each lines prefix to ensure these aren't included.
blender_version = ""
blender_date = ""
for l in blender_version_ouput.split("\n"):
for l in blender_version_output.split("\n"):
if l.startswith("Blender "):
# Remove 'Blender' prefix.
blender_version = l.split(" ", 1)[1].strip()

View File

@@ -11,7 +11,7 @@ import queue
execution_queue = queue.Queue()
# This function can savely be called in another thread.
# This function can safely be called in another thread.
# The function will be executed when the timer runs the next time.
def run_in_main_thread(function):
execution_queue.put(function)

View File

@@ -8,27 +8,42 @@ def set_pose_matrices(obj, matrix_map):
"Assign pose space matrices of all bones at once, ignoring constraints."
def rec(pbone, parent_matrix):
matrix = matrix_map[pbone.name]
if pbone.name in matrix_map:
matrix = matrix_map[pbone.name]
## Instead of:
# pbone.matrix = matrix
# bpy.context.view_layer.update()
## Instead of:
# pbone.matrix = matrix
# bpy.context.view_layer.update()
# Compute and assign local matrix, using the new parent matrix
if pbone.parent:
pbone.matrix_basis = pbone.bone.convert_local_to_pose(
matrix,
pbone.bone.matrix_local,
parent_matrix=parent_matrix,
parent_matrix_local=pbone.parent.bone.matrix_local,
invert=True
)
# Compute and assign local matrix, using the new parent matrix
if pbone.parent:
pbone.matrix_basis = pbone.bone.convert_local_to_pose(
matrix,
pbone.bone.matrix_local,
parent_matrix=parent_matrix,
parent_matrix_local=pbone.parent.bone.matrix_local,
invert=True
)
else:
pbone.matrix_basis = pbone.bone.convert_local_to_pose(
matrix,
pbone.bone.matrix_local,
invert=True
)
else:
pbone.matrix_basis = pbone.bone.convert_local_to_pose(
matrix,
pbone.bone.matrix_local,
invert=True
)
# Compute the updated pose matrix from local and new parent matrix
if pbone.parent:
matrix = pbone.bone.convert_local_to_pose(
pbone.matrix_basis,
pbone.bone.matrix_local,
parent_matrix=parent_matrix,
parent_matrix_local=pbone.parent.bone.matrix_local,
)
else:
matrix = pbone.bone.convert_local_to_pose(
pbone.matrix_basis,
pbone.bone.matrix_local,
)
# Recursively process children, passing the new matrix through
for child in pbone.children:

View File

@@ -42,8 +42,13 @@ class SimpleMouseOperator(bpy.types.Operator):
self.y = event.mouse_y
return self.execute(context)
# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
self.layout.operator(SimpleMouseOperator.bl_idname, text="Simple Mouse Operator")
# Register and add to the view menu (required to also use F3 search "Simple Mouse Operator" for quick access)
bpy.utils.register_class(SimpleMouseOperator)
bpy.types.VIEW3D_MT_view.append(menu_func)
# Test call to the newly defined operator.
# Here we call the operator and invoke it, meaning that the settings are taken

View File

@@ -43,7 +43,7 @@ def menu_func(self, context):
self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
# Register and add to the file selector
# Register and add to the file selector (required to also use F3 search "Text Export Operator" for quick access)
bpy.utils.register_class(ExportSomeData)
bpy.types.TOPBAR_MT_file_export.append(menu_func)

View File

@@ -27,8 +27,14 @@ class DialogOperator(bpy.types.Operator):
wm = context.window_manager
return wm.invoke_props_dialog(self)
# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
self.layout.operator(DialogOperator.bl_idname, text="Dialog Operator")
# Register and add to the object menu (required to also use F3 search "Dialog Operator" for quick access)
bpy.utils.register_class(DialogOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
# Test call.
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')

View File

@@ -41,8 +41,13 @@ class CustomDrawOperator(bpy.types.Operator):
col.prop(self, "my_string")
# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
self.layout.operator(CustomDrawOperator.bl_idname, text="Custom Draw Operator")
# Register and add to the object menu (required to also use F3 search "Custom Draw Operator" for quick access)
bpy.utils.register_class(CustomDrawOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
# test call
bpy.ops.object.custom_draw('INVOKE_DEFAULT')

View File

@@ -55,8 +55,13 @@ class ModalOperator(bpy.types.Operator):
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
self.layout.operator(ModalOperator.bl_idname, text="Modal Operator")
# Register and add to the object menu (required to also use F3 search "Modal Operator" for quick access)
bpy.utils.register_class(ModalOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
# test call
bpy.ops.object.modal_operator('INVOKE_DEFAULT')

View File

@@ -31,8 +31,13 @@ class SearchEnumOperator(bpy.types.Operator):
context.window_manager.invoke_search_popup(self)
return {'RUNNING_MODAL'}
# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
self.layout.operator(SearchEnumOperator.bl_idname, text="Search Enum Operator")
# Register and add to the object menu (required to also use F3 search "Search Enum Operator" for quick access)
bpy.utils.register_class(SearchEnumOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)
# test call
bpy.ops.object.search_enum_operator('INVOKE_DEFAULT')

View File

@@ -22,8 +22,13 @@ class HelloWorldOperator(bpy.types.Operator):
print("Hello World")
return {'FINISHED'}
# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
self.layout.operator(HelloWorldOperator.bl_idname, text="Hello World Operator")
# Register and add to the view menu (required to also use F3 search "Hello World Operator" for quick access)
bpy.utils.register_class(HelloWorldOperator)
bpy.types.VIEW3D_MT_view.append(menu_func)
# test call to the newly defined operator
bpy.ops.wm.hello_world()

View File

@@ -106,24 +106,6 @@ including advanced features.
floating-point values. These values are interpreted as a plane equation.
.. function:: glColor (red, green, blue, alpha):
B{glColor3b, glColor3d, glColor3f, glColor3i, glColor3s, glColor3ub, glColor3ui, glColor3us,
glColor4b, glColor4d, glColor4f, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us,
glColor3bv, glColor3dv, glColor3fv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv,
glColor3usv, glColor4bv, glColor4dv, glColor4fv, glColor4iv, glColor4sv, glColor4ubv,
glColor4uiv, glColor4usv}
Set a new color.
.. seealso:: `OpenGL Docs <https://khronos.org/registry/OpenGL-Refpages/gl4/html/glColor.xhtml>`__
:type red, green, blue, alpha: Depends on function prototype.
:arg red, green, blue: Specify new red, green, and blue values for the current color.
:arg alpha: Specifies a new alpha value for the current color. Included only in the
four-argument glColor4 commands. (With '4' colors only)
.. function:: glColorMask(red, green, blue, alpha):
Enable and disable writing of frame buffer color components

View File

@@ -728,7 +728,7 @@ Abusing RNA property callbacks
------------------------------
Python-defined RNA properties can have custom callbacks. Trying to perform complex operations
from there, like calling an operator, may work, but is not officialy recommended nor supported.
from there, like calling an operator, may work, but is not officially recommended nor supported.
Main reason is that those callback should be very fast, but additionally, it may for example
create issues with undo/redo system (most operators store an history step, and editing an RNA
@@ -743,7 +743,7 @@ will re-allocate objects data,
any references to a meshes vertices/polygons/UVs, armatures bones,
curves points, etc. cannot be accessed after switching mode.
Only the reference to the data its self can be re-accessed, the following example will crash.
Only the reference to the data itself can be re-accessed, the following example will crash.
.. code-block:: python

View File

@@ -1103,6 +1103,7 @@ context_type_map = {
"selectable_objects": ("Object", True),
"selected_asset_files": ("FileSelectEntry", True),
"selected_bones": ("EditBone", True),
"selected_editable_actions": ("Action", True),
"selected_editable_bones": ("EditBone", True),
"selected_editable_fcurves": ("FCurve", True),
"selected_editable_keyframes": ("Keyframe", True),
@@ -1118,12 +1119,13 @@ context_type_map = {
"selected_pose_bones": ("PoseBone", True),
"selected_pose_bones_from_active_object": ("PoseBone", True),
"selected_sequences": ("Sequence", True),
"selected_visible_actions": ("Action", True),
"selected_visible_fcurves": ("FCurve", True),
"sequences": ("Sequence", True),
"soft_body": ("SoftBodyModifier", False),
"speaker": ("Speaker", False),
"texture": ("Texture", False),
"texture_slot": ("MaterialTextureSlot", False),
"texture_slot": ("TextureSlot", False),
"texture_user": ("ID", False),
"texture_user_property": ("Property", False),
"ui_list": ("UIList", False),
@@ -1760,6 +1762,7 @@ except ModuleNotFoundError:
fw("html_show_sphinx = False\n")
fw("html_baseurl = 'https://docs.blender.org/api/current/'\n")
fw("html_use_opensearch = 'https://docs.blender.org/api/current'\n")
fw("html_show_search_summary = True\n")
fw("html_split_index = True\n")
fw("html_static_path = ['static']\n")
fw("html_extra_path = ['static/favicon.ico', 'static/blender_logo.svg']\n")

View File

@@ -1092,12 +1092,12 @@ if(WITH_PYTHON)
configure_file(${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py ESCAPE_QUOTES @ONLY)
if(APPLE)
add_custom_command(OUTPUT build COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
add_custom_command(OUTPUT build COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR} setup.py)
elseif(WIN32)
set(ENV{VS100COMNTOOLS} $ENV{VS120COMNTOOLS})
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR} setup.py)
else()
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR} setup.py)
endif()
add_custom_target(pythonmodule ALL DEPENDS build SOURCES ${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${PYTHON_SRC} ${PYTHON_HDR})
add_dependencies(pythonmodule audaspace)

View File

@@ -8,20 +8,20 @@ import numpy
from distutils.core import setup, Extension
if len(sys.argv) > 2 and sys.argv[1] == '--build-docs':
import subprocess
from distutils.core import Distribution
from distutils.command.build import build
import subprocess
from distutils.core import Distribution
from distutils.command.build import build
dist = Distribution()
cmd = build(dist)
cmd.finalize_options()
#print(cmd.build_platlib)
dist = Distribution()
cmd = build(dist)
cmd.finalize_options()
#print(cmd.build_platlib)
os.environ['PYTHONPATH'] = os.path.join(os.getcwd(), cmd.build_platlib)
os.environ['LD_LIBRARY_PATH'] = os.getcwd()
os.environ['PYTHONPATH'] = os.path.join(os.getcwd(), cmd.build_platlib)
os.environ['LD_LIBRARY_PATH'] = os.getcwd()
ret = subprocess.call(sys.argv[2:])
sys.exit(ret)
ret = subprocess.call(sys.argv[2:])
sys.exit(ret)
# the following line is not working due to https://bugs.python.org/issue9023
@@ -43,7 +43,8 @@ audaspace = Extension(
library_dirs = ['.', 'Release', 'Debug'],
language = 'c++',
extra_compile_args = extra_args,
sources = [os.path.join(source_directory, file) for file in ['PyAPI.cpp', 'PyDevice.cpp', 'PyHandle.cpp', 'PySound.cpp', 'PySequenceEntry.cpp', 'PySequence.cpp', 'PyPlaybackManager.cpp', 'PyDynamicMusic.cpp', 'PyThreadPool.cpp', 'PySource.cpp'] + (['PyImpulseResponse.cpp', 'PyHRTF.cpp'] if '@WITH_FFTW@' == 'ON' else [])]
define_macros = [('WITH_CONVOLUTION', None)] if '@WITH_FFTW@' == 'ON' else [],
sources = [os.path.join(source_directory, file) for file in ['PyAPI.cpp', 'PyDevice.cpp', 'PyHandle.cpp', 'PySound.cpp', 'PySequenceEntry.cpp', 'PySequence.cpp', 'PyPlaybackManager.cpp', 'PyDynamicMusic.cpp', 'PyThreadPool.cpp', 'PySource.cpp'] + (['PyImpulseResponse.cpp', 'PyHRTF.cpp'] if '@WITH_FFTW@' == 'ON' else [])]
)
setup(
@@ -56,6 +57,6 @@ setup(
license = 'Apache License 2.0',
long_description = codecs.open(os.path.join(source_directory, '../../README.md'), 'r', 'utf-8').read(),
ext_modules = [audaspace],
headers = [os.path.join(source_directory, file) for file in ['PyAPI.h', 'PyDevice.h', 'PyHandle.h', 'PySound.h', 'PySequenceEntry.h', 'PySequence.h', 'PyPlaybackManager.h', 'PyDynamicMusic.h', 'PyThreadPool.h', 'PySource.h'] + (['PyImpulseResponse.h', 'PyHRTF.h'] if '@WITH_FFTW@' == 'ON' else [])] + ['Audaspace.h']
headers = [os.path.join(source_directory, file) for file in ['PyAPI.h', 'PyDevice.h', 'PyHandle.h', 'PySound.h', 'PySequenceEntry.h', 'PySequence.h', 'PyPlaybackManager.h', 'PyDynamicMusic.h', 'PyThreadPool.h', 'PySource.h'] + (['PyImpulseResponse.h', 'PyHRTF.h'] if '@WITH_FFTW@' == 'ON' else [])] + ['Audaspace.h']
)

View File

@@ -95,6 +95,13 @@ void WASAPIDevice::runMixingThread()
sleep_duration = std::chrono::milliseconds(buffer_size * 1000 / int(m_specs.rate) / 2);
}
if(m_default_device_changed)
{
m_default_device_changed = false;
result = AUDCLNT_E_DEVICE_INVALIDATED;
goto stop_thread;
}
if(FAILED(result = m_audio_client->GetCurrentPadding(&padding)))
goto stop_thread;
@@ -296,13 +303,78 @@ bool WASAPIDevice::setupDevice(DeviceSpecs &specs)
return true;
}
ULONG WASAPIDevice::AddRef()
{
return InterlockedIncrement(&m_reference_count);
}
ULONG WASAPIDevice::Release()
{
ULONG reference_count = InterlockedDecrement(&m_reference_count);
if(0 == reference_count)
delete this;
return reference_count;
}
HRESULT WASAPIDevice::QueryInterface(REFIID riid, void **ppvObject)
{
if(riid == __uuidof(IMMNotificationClient))
{
*ppvObject = reinterpret_cast<IMMNotificationClient*>(this);
AddRef();
}
else if(riid == IID_IUnknown)
{
*ppvObject = reinterpret_cast<IUnknown*>(this);
AddRef();
}
else
{
*ppvObject = nullptr;
return E_NOINTERFACE;
}
return S_OK;
}
HRESULT WASAPIDevice::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState)
{
return S_OK;
}
HRESULT WASAPIDevice::OnDeviceAdded(LPCWSTR pwstrDeviceId)
{
return S_OK;
}
HRESULT WASAPIDevice::OnDeviceRemoved(LPCWSTR pwstrDeviceId)
{
return S_OK;
}
HRESULT WASAPIDevice::OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId)
{
if(flow != EDataFlow::eCapture)
m_default_device_changed = true;
return S_OK;
}
HRESULT WASAPIDevice::OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key)
{
return S_OK;
}
WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
m_buffersize(buffersize),
m_imm_device_enumerator(nullptr),
m_imm_device(nullptr),
m_audio_client(nullptr),
m_wave_format_extensible({})
m_wave_format_extensible({}),
m_default_device_changed(false),
m_reference_count(1)
{
// initialize COM if it hasn't happened yet
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
@@ -327,6 +399,8 @@ WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
create();
m_imm_device_enumerator->RegisterEndpointNotificationCallback(this);
return;
error:
@@ -340,6 +414,8 @@ WASAPIDevice::~WASAPIDevice()
{
stopMixingThread();
m_imm_device_enumerator->UnregisterEndpointNotificationCallback(this);
SafeRelease(&m_audio_client);
SafeRelease(&m_imm_device);
SafeRelease(&m_imm_device_enumerator);

View File

@@ -40,7 +40,7 @@ AUD_NAMESPACE_BEGIN
/**
* This device plays back through WASAPI, the Windows audio API.
*/
class AUD_PLUGIN_API WASAPIDevice : public ThreadedDevice
class AUD_PLUGIN_API WASAPIDevice : IMMNotificationClient, public ThreadedDevice
{
private:
int m_buffersize;
@@ -48,6 +48,8 @@ private:
IMMDevice* m_imm_device;
IAudioClient* m_audio_client;
WAVEFORMATEXTENSIBLE m_wave_format_extensible;
bool m_default_device_changed;
LONG m_reference_count;
AUD_LOCAL HRESULT setupRenderClient(IAudioRenderClient*& render_client, UINT32& buffer_size);
@@ -58,6 +60,17 @@ private:
AUD_LOCAL bool setupDevice(DeviceSpecs& specs);
// IUnknown implementation
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
// IMMNotificationClient implementation
HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId);
HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId);
HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId);
HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key);
// delete copy constructor and operator=
WASAPIDevice(const WASAPIDevice&) = delete;
WASAPIDevice& operator=(const WASAPIDevice&) = delete;

12
extern/hipew/README vendored Normal file
View File

@@ -0,0 +1,12 @@
The HIP Extension Wrangler Library (HIPEW) is a cross-platform open-source
C/C++ library to dynamically load the HIP library.
HIP (Heterogeneous-Compute Interface for Portability) is an API for C++
programming on AMD GPUs.
It is maintained as part of the Blender project, but included in extern/
for consistency with CUEW and CLEW libraries.
LICENSE
HIPEW is released under the Apache 2.0 license.

5
extern/hipew/README.blender vendored Normal file
View File

@@ -0,0 +1,5 @@
Project: Blender
URL: https://git.blender.org/blender.git
License: Apache 2.0
Upstream version: N/A
Local modifications: None

View File

@@ -804,31 +804,29 @@ typedef enum hipDeviceP2PAttr {
} hipDeviceP2PAttr;
typedef struct HIP_MEMCPY3D {
size_t srcXInBytes;
size_t srcY;
size_t srcZ;
size_t srcLOD;
unsigned int srcXInBytes;
unsigned int srcY;
unsigned int srcZ;
unsigned int srcLOD;
hipMemoryType srcMemoryType;
const void* srcHost;
hipDeviceptr_t srcDevice;
hArray * srcArray;
void* reserved0;
size_t srcPitch;
size_t srcHeight;
size_t dstXInBytes;
size_t dstY;
size_t dstZ;
size_t dstLOD;
hArray srcArray;
unsigned int srcPitch;
unsigned int srcHeight;
unsigned int dstXInBytes;
unsigned int dstY;
unsigned int dstZ;
unsigned int dstLOD;
hipMemoryType dstMemoryType;
void* dstHost;
hipDeviceptr_t dstDevice;
hArray * dstArray;
void* reserved1;
size_t dstPitch;
size_t dstHeight;
size_t WidthInBytes;
size_t Height;
size_t Depth;
hArray dstArray;
unsigned int dstPitch;
unsigned int dstHeight;
unsigned int WidthInBytes;
unsigned int Height;
unsigned int Depth;
} HIP_MEMCPY3D;
typedef struct HIP_MEMCPY3D_PEER_st {
@@ -879,7 +877,7 @@ typedef struct HIP_RESOURCE_DESC_st {
hipResourceType resType;
union {
struct {
hArray * h_Array;
hArray h_Array;
} array;
struct {
hipMipmappedArray_t hMipmappedArray;
@@ -1074,9 +1072,10 @@ typedef enum hiprtcResult {
typedef hipError_t HIPAPI thipGetErrorName(hipError_t error, const char** pStr);
typedef hipError_t HIPAPI thipInit(unsigned int Flags);
typedef hipError_t HIPAPI thipDriverGetVersion(int* driverVersion);
typedef hipError_t HIPAPI thipGetDevice(hipDevice_t* device, int ordinal);
typedef hipError_t HIPAPI thipGetDevice(int* device);
typedef hipError_t HIPAPI thipGetDeviceCount(int* count);
typedef hipError_t HIPAPI thipGetDeviceProperties(hipDeviceProp_t* props, int deviceId);
typedef hipError_t HIPAPI thipDeviceGet(hipDevice_t* device, int ordinal);
typedef hipError_t HIPAPI thipDeviceGetName(char* name, int len, hipDevice_t dev);
typedef hipError_t HIPAPI thipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attrib, hipDevice_t dev);
typedef hipError_t HIPAPI thipDeviceComputeCapability(int* major, int* minor, hipDevice_t dev);
@@ -1209,6 +1208,7 @@ extern thipDriverGetVersion *hipDriverGetVersion;
extern thipGetDevice *hipGetDevice;
extern thipGetDeviceCount *hipGetDeviceCount;
extern thipGetDeviceProperties *hipGetDeviceProperties;
extern thipDeviceGet* hipDeviceGet;
extern thipDeviceGetName *hipDeviceGetName;
extern thipDeviceGetAttribute *hipDeviceGetAttribute;
extern thipDeviceComputeCapability *hipDeviceComputeCapability;
@@ -1333,6 +1333,7 @@ enum {
HIPEW_SUCCESS = 0,
HIPEW_ERROR_OPEN_FAILED = -1,
HIPEW_ERROR_ATEXIT_FAILED = -2,
HIPEW_ERROR_OLD_DRIVER = -3,
};
enum {

View File

@@ -71,6 +71,7 @@ thipDriverGetVersion *hipDriverGetVersion;
thipGetDevice *hipGetDevice;
thipGetDeviceCount *hipGetDeviceCount;
thipGetDeviceProperties *hipGetDeviceProperties;
thipDeviceGet* hipDeviceGet;
thipDeviceGetName *hipDeviceGetName;
thipDeviceGetAttribute *hipDeviceGetAttribute;
thipDeviceComputeCapability *hipDeviceComputeCapability;
@@ -213,6 +214,36 @@ static void hipewHipExit(void) {
}
}
#ifdef _WIN32
static int hipewHasOldDriver(const char *hip_path) {
DWORD verHandle = 0;
DWORD verSize = GetFileVersionInfoSize(hip_path, &verHandle);
int old_driver = 0;
if (verSize != 0) {
LPSTR verData = (LPSTR)malloc(verSize);
if (GetFileVersionInfo(hip_path, verHandle, verSize, verData)) {
LPBYTE lpBuffer = NULL;
UINT size = 0;
if (VerQueryValue(verData, "\\", (VOID FAR * FAR *)&lpBuffer, &size)) {
if (size) {
VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer;
/* Magic value from
* https://docs.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo */
if (verInfo->dwSignature == 0xfeef04bd) {
unsigned int fileVersionLS0 = (verInfo->dwFileVersionLS >> 16) & 0xffff;
unsigned int fileversionLS1 = (verInfo->dwFileVersionLS >> 0) & 0xffff;
/* Corresponds to versions older than AMD Radeon Pro 21.Q4. */
old_driver = ((fileVersionLS0 < 3354) || (fileVersionLS0 == 3354 && fileversionLS1 < 13));
}
}
}
}
free(verData);
}
return old_driver;
}
#endif
static int hipewHipInit(void) {
/* Library paths. */
#ifdef _WIN32
@@ -226,7 +257,7 @@ static int hipewHipInit(void) {
#endif
static int initialized = 0;
static int result = 0;
int error, driver_version;
int error;
if (initialized) {
return result;
@@ -240,6 +271,14 @@ static int hipewHipInit(void) {
return result;
}
#ifdef _WIN32
/* Test for driver version. */
if(hipewHasOldDriver(hip_paths[0])) {
result = HIPEW_ERROR_OLD_DRIVER;
return result;
}
#endif
/* Load library. */
hip_lib = dynamic_library_open_find(hip_paths);
@@ -255,6 +294,7 @@ static int hipewHipInit(void) {
HIP_LIBRARY_FIND_CHECKED(hipGetDevice);
HIP_LIBRARY_FIND_CHECKED(hipGetDeviceCount);
HIP_LIBRARY_FIND_CHECKED(hipGetDeviceProperties);
HIP_LIBRARY_FIND_CHECKED(hipDeviceGet);
HIP_LIBRARY_FIND_CHECKED(hipDeviceGetName);
HIP_LIBRARY_FIND_CHECKED(hipDeviceGetAttribute);
HIP_LIBRARY_FIND_CHECKED(hipDeviceComputeCapability);
@@ -525,8 +565,6 @@ int hipewCompilerVersion(void) {
const char *path = hipewCompilerPath();
const char *marker = "Hip compilation tools, release ";
FILE *pipe;
int major, minor;
char *versionstr;
char buf[128];
char output[65536] = "\0";
char command[65536] = "\0";

View File

@@ -1,7 +1,7 @@
Project: NanoSVG
URL: https://github.com/memononen/nanosvg
License: zlib
Upstream version:
Upstream version: 3cdd4a9d7886
Local modifications: Added some functionality to manage grease pencil layers
Added a fix to SVG import arc and float errors (https://developer.blender.org/rB11dc674c78b49fc4e0b7c134c375b6c8b8eacbcc)

View File

@@ -25,7 +25,6 @@ add_subdirectory(ghost)
add_subdirectory(guardedalloc)
add_subdirectory(libmv)
add_subdirectory(memutil)
add_subdirectory(numaapi)
add_subdirectory(opencolorio)
add_subdirectory(opensubdiv)
add_subdirectory(mikktspace)

View File

@@ -45,7 +45,7 @@
*/
/** \file
* \ingroup Atomic
* \ingroup intern_atomic
*
* \brief Provides wrapper around system-specific atomic primitives,
* and some extensions (faked-atomic operations over float numbers).

View File

@@ -44,6 +44,10 @@
* The Original Code is: adapted from jemalloc.
*/
/** \file
* \ingroup intern_atomic
*/
#ifndef __ATOMIC_OPS_EXT_H__
#define __ATOMIC_OPS_EXT_H__

View File

@@ -5,7 +5,7 @@
* All rights reserved.
* Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved.
* Copyright (C) 2009-2013 Facebook, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice(s),
@@ -13,7 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright notice(s),
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
@@ -26,6 +26,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file
* \ingroup intern_atomic
*/
#ifndef __ATOMIC_OPS_MSVC_H__
#define __ATOMIC_OPS_MSVC_H__

View File

@@ -44,6 +44,10 @@
* The Original Code is: adapted from jemalloc.
*/
/** \file
* \ingroup intern_atomic
*/
#ifndef __ATOMIC_OPS_UNIX_H__
#define __ATOMIC_OPS_UNIX_H__

View File

@@ -44,6 +44,10 @@
* The Original Code is: adapted from jemalloc.
*/
/** \file
* \ingroup intern_atomic
*/
#ifndef __ATOMIC_OPS_UTILS_H__
#define __ATOMIC_OPS_UTILS_H__

View File

@@ -14,11 +14,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __CLG_LOG_H__
#define __CLG_LOG_H__
/** \file
* \ingroup clog
* \ingroup intern_clog
*
* C Logging Library (clog)
* ========================
@@ -68,6 +65,9 @@
* - 4+: May be used for more details than 3, should be avoided but not prevented.
*/
#ifndef __CLG_LOG_H__
#define __CLG_LOG_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

View File

@@ -15,7 +15,7 @@
*/
/** \file
* \ingroup clog
* \ingroup intern_clog
*/
#include <assert.h>
@@ -388,7 +388,7 @@ static void clg_ctx_fatal_action(CLogContext *ctx)
static void clg_ctx_backtrace(CLogContext *ctx)
{
/* Note: we avoid writing to 'FILE', for back-trace we make an exception,
/* NOTE: we avoid writing to 'FILE', for back-trace we make an exception,
* if necessary we could have a version of the callback that writes to file
* descriptor all at once. */
ctx->callbacks.backtrace_fn(ctx->output_file);

View File

@@ -226,6 +226,9 @@ add_definitions(
-DCCL_NAMESPACE_END=}
)
if(WITH_CYCLES_DEBUG)
add_definitions(-DWITH_CYCLES_DEBUG)
endif()
if(WITH_CYCLES_STANDALONE_GUI)
add_definitions(-DWITH_CYCLES_STANDALONE_GUI)
endif()
@@ -334,7 +337,7 @@ else()
endif()
# Warnings
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_float_conversion "-Werror=float-conversion")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_double_promotion "-Werror=double-promotion")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_no_error_unused_macros "-Wno-error=unused-macros")

View File

@@ -51,8 +51,6 @@ list(APPEND LIBRARIES ${CYCLES_GL_LIBRARIES})
# Common configuration.
cycles_link_directories()
add_definitions(${GL_DEFINITIONS})
include_directories(${INC})

View File

@@ -82,7 +82,7 @@ static void session_print_status()
string status, substatus;
/* get status */
float progress = options.session->progress.get_progress();
double progress = options.session->progress.get_progress();
options.session->progress.get_status(status, substatus);
if (substatus != "")
@@ -183,7 +183,7 @@ static void display_info(Progress &progress)
progress.get_time(total_time, sample_time);
progress.get_status(status, substatus);
float progress_val = progress.get_progress();
double progress_val = progress.get_progress();
if (substatus != "")
status += ": " + substatus;

View File

@@ -40,6 +40,7 @@ set(SRC
object_cull.cpp
output_driver.cpp
particles.cpp
pointcloud.cpp
curves.cpp
logging.cpp
python.cpp
@@ -87,6 +88,7 @@ endif()
set(ADDON_FILES
addon/__init__.py
addon/camera.py
addon/engine.py
addon/operators.py
addon/osl.py
@@ -101,6 +103,11 @@ add_definitions(${GL_DEFINITIONS})
if(WITH_CYCLES_DEVICE_HIP)
add_definitions(-DWITH_HIP)
endif()
if(WITH_CYCLES_DEVICE_METAL)
add_definitions(-DWITH_METAL)
endif()
if(WITH_MOD_FLUID)
add_definitions(-DWITH_FLUID)
endif()

View File

@@ -0,0 +1,84 @@
#
# Copyright 2011-2021 Blender Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# <pep8 compliant>
# Fit to match default projective camera with focal_length 50 and sensor_width 36.
default_fisheye_polynomial = [-1.1735143712967577e-05,
-0.019988736953434998,
-3.3525322965709175e-06,
3.099275275886036e-06,
-2.6064646454854524e-08]
# Utilities to generate lens polynomials to match built-in camera types, only here
# for reference at the moment, not used by the code.
def create_grid(sensor_height, sensor_width):
import numpy as np
if sensor_height is None:
sensor_height = sensor_width / (16 / 9) # Default aspect ration 16:9
uu, vv = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 100))
uu = (uu - 0.5) * sensor_width
vv = (vv - 0.5) * sensor_height
rr = np.sqrt(uu ** 2 + vv ** 2)
return rr
def fisheye_lens_polynomial_from_projective(focal_length=50, sensor_width=36, sensor_height=None):
import numpy as np
rr = create_grid(sensor_height, sensor_width)
polynomial = np.polyfit(rr.flat, (-np.arctan(rr / focal_length)).flat, 4)
return list(reversed(polynomial))
def fisheye_lens_polynomial_from_projective_fov(fov, sensor_width=36, sensor_height=None):
import numpy as np
f = sensor_width / 2 / np.tan(fov / 2)
return fisheye_lens_polynomial_from_projective(f, sensor_width, sensor_height)
def fisheye_lens_polynomial_from_equisolid(lens=10.5, sensor_width=36, sensor_height=None):
import numpy as np
rr = create_grid(sensor_height, sensor_width)
x = rr.reshape(-1)
x = np.stack([x**i for i in [1, 2, 3, 4]])
y = (-2 * np.arcsin(rr / (2 * lens))).reshape(-1)
polynomial = np.linalg.lstsq(x.T, y.T, rcond=None)[0]
return [0] + list(polynomial)
def fisheye_lens_polynomial_from_equidistant(fov=180, sensor_width=36, sensor_height=None):
import numpy as np
return [0, -np.radians(fov) / sensor_width, 0, 0, 0]
def fisheye_lens_polynomial_from_distorted_projective_polynomial(k1, k2, k3, focal_length=50, sensor_width=36, sensor_height=None):
import numpy as np
rr = create_grid(sensor_height, sensor_width)
r2 = (rr / focal_length) ** 2
r4 = r2 * r2
r6 = r4 * r2
r_coeff = 1 + k1 * r2 + k2 * r4 + k3 * r6
polynomial = np.polyfit(rr.flat, (-np.arctan(rr / focal_length * r_coeff)).flat, 4)
return list(reversed(polynomial))
def fisheye_lens_polynomial_from_distorted_projective_divisions(k1, k2, focal_length=50, sensor_width=36, sensor_height=None):
import numpy as np
rr = create_grid(sensor_height, sensor_width)
r2 = (rr / focal_length) ** 2
r4 = r2 * r2
r_coeff = 1 + k1 * r2 + k2 * r4
polynomial = np.polyfit(rr.flat, (-np.arctan(rr / focal_length / r_coeff)).flat, 4)
return list(reversed(polynomial))

View File

@@ -28,7 +28,7 @@ def _configure_argument_parser():
action='store_true')
parser.add_argument("--cycles-device",
help="Set the device to use for Cycles, overriding user preferences and the scene setting."
"Valid options are 'CPU', 'CUDA', 'OPTIX', or 'HIP'"
"Valid options are 'CPU', 'CUDA', 'OPTIX', 'HIP' or 'METAL'."
"Additionally, you can append '+CPU' to any GPU type for hybrid rendering.",
default=None)
return parser
@@ -60,9 +60,8 @@ def init():
path = os.path.dirname(__file__)
user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', path='')))
temp_path = bpy.app.tempdir
_cycles.init(path, user_path, temp_path, bpy.app.background)
_cycles.init(path, user_path, bpy.app.background)
_parse_command_line()

View File

@@ -33,6 +33,7 @@ from math import pi
# enums
from . import engine
from . import camera
enum_devices = (
('CPU', "CPU", "Use CPU for rendering"),
@@ -72,6 +73,8 @@ enum_panorama_types = (
('FISHEYE_EQUISOLID', "Fisheye Equisolid",
"Similar to most fisheye modern lens, takes sensor dimensions into consideration"),
('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"),
('FISHEYE_LENS_POLYNOMIAL', "Fisheye Lens Polynomial",
"Defines the lens projection as polynomial to allow real world camera lenses to be mimicked."),
)
enum_curve_shape = (
@@ -111,7 +114,8 @@ enum_device_type = (
('CPU', "CPU", "CPU", 0),
('CUDA', "CUDA", "CUDA", 1),
('OPTIX', "OptiX", "OptiX", 3),
("HIP", "HIP", "HIP", 4)
('HIP', "HIP", "HIP", 4),
('METAL', "Metal", "Metal", 5)
)
enum_texture_limit = (
@@ -218,6 +222,12 @@ enum_denoising_prefilter = (
('ACCURATE', "Accurate", "Prefilter noisy guiding passes before denoising color. Improves quality when guiding passes are noisy using extra processing time", 3),
)
enum_direct_light_sampling_type = (
('MULTIPLE_IMPORTANCE_SAMPLING', "Multiple Importance Sampling", "Multiple importance sampling is used to combine direct light contributions from next-event estimation and forward path tracing", 0),
('FORWARD_PATH_TRACING', "Forward Path Tracing", "Direct light contributions are only sampled using forward path tracing", 1),
('NEXT_EVENT_ESTIMATION', "Next-Event Estimation", "Direct light contributions are only sampled using next-event estimation", 2),
)
def update_render_passes(self, context):
scene = context.scene
view_layer = context.view_layer
@@ -325,6 +335,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=1024,
)
sample_offset: IntProperty(
name="Sample Offset",
description="Number of samples to skip when starting render",
min=0, max=(1 << 24),
default=0,
)
time_limit: FloatProperty(
name="Time Limit",
description="Limit the render time (excluding synchronization time)."
@@ -346,7 +363,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
name="Scrambling Distance",
default=1.0,
min=0.0, max=1.0,
description="Lower values give faster rendering with GPU rendering and less noise with all devices at the cost of possible artifacts if set too low. Only works when not using adaptive sampling",
description="Reduce randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts if set too low. Only works when not using adaptive sampling",
)
preview_scrambling_distance: BoolProperty(
name="Scrambling Distance viewport",
@@ -354,10 +371,10 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Uses the Scrambling Distance value for the viewport. Faster but may flicker",
)
adaptive_scrambling_distance: BoolProperty(
name="Adaptive Scrambling Distance",
auto_scrambling_distance: BoolProperty(
name="Automatic Scrambling Distance",
default=False,
description="Uses a formula to adapt the scrambling distance strength based on the sample count",
description="Automatically reduce the randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts. Only works when not using adaptive sampling",
)
use_layer_samples: EnumProperty(
@@ -415,6 +432,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=0,
)
direct_light_sampling_type: EnumProperty(
name="Direct Light Sampling",
description="The type of strategy used for sampling direct light contributions",
items=enum_direct_light_sampling_type,
default='MULTIPLE_IMPORTANCE_SAMPLING',
)
min_light_bounces: IntProperty(
name="Min Light Bounces",
description="Minimum number of light bounces. Setting this higher reduces noise in the first bounces, "
@@ -643,6 +667,11 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Use special type BVH optimized for hair (uses more ram but renders faster)",
default=True,
)
debug_use_compact_bvh: BoolProperty(
name="Use Compact BVH",
description="Use compact BVH structure (uses less ram but renders slower)",
default=True,
)
debug_bvh_time_steps: IntProperty(
name="BVH Time Steps",
description="Split BVH primitives by this number of time steps to speed up render time in cost of memory",
@@ -770,15 +799,15 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
)
use_auto_tile: BoolProperty(
name="Auto Tiles",
description="Automatically render high resolution images in tiles to reduce memory usage, using the specified tile size. Tiles are cached to disk while rendering to save memory",
name="Use Tiling",
description="Render high resolution images in tiles to reduce memory usage, using the specified tile size. Tiles are cached to disk while rendering to save memory",
default=True,
)
tile_size: IntProperty(
name="Tile Size",
default=2048,
description="",
min=8, max=16384,
min=8, max=8192,
)
# Various fine-tuning debug flags
@@ -870,6 +899,32 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
default=pi,
)
fisheye_polynomial_k0: FloatProperty(
name="Fisheye Polynomial K0",
description="Coefficient K0 of the lens polinomial",
default=camera.default_fisheye_polynomial[0], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k1: FloatProperty(
name="Fisheye Polynomial K1",
description="Coefficient K1 of the lens polinomial",
default=camera.default_fisheye_polynomial[1], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k2: FloatProperty(
name="Fisheye Polynomial K2",
description="Coefficient K2 of the lens polinomial",
default=camera.default_fisheye_polynomial[2], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k3: FloatProperty(
name="Fisheye Polynomial K3",
description="Coefficient K3 of the lens polinomial",
default=camera.default_fisheye_polynomial[3], precision=6, step=0.1, subtype='ANGLE',
)
fisheye_polynomial_k4: FloatProperty(
name="Fisheye Polynomial K4",
description="Coefficient K4 of the lens polinomial",
default=camera.default_fisheye_polynomial[4], precision=6, step=0.1, subtype='ANGLE',
)
@classmethod
def register(cls):
bpy.types.Camera.cycles = PointerProperty(
@@ -1292,8 +1347,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
def get_device_types(self, context):
import _cycles
has_cuda, has_optix, has_hip = _cycles.get_device_types()
has_cuda, has_optix, has_hip, has_metal = _cycles.get_device_types()
list = [('NONE', "None", "Don't use compute device", 0)]
if has_cuda:
list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1))
@@ -1301,6 +1355,8 @@ class CyclesPreferences(bpy.types.AddonPreferences):
list.append(('OPTIX', "OptiX", "Use OptiX for GPU acceleration", 3))
if has_hip:
list.append(('HIP', "HIP", "Use HIP for GPU acceleration", 4))
if has_metal:
list.append(('METAL', "Metal", "Use Metal for GPU acceleration", 5))
return list
@@ -1326,7 +1382,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
def update_device_entries(self, device_list):
for device in device_list:
if not device[1] in {'CUDA', 'OPTIX', 'CPU', 'HIP'}:
if not device[1] in {'CUDA', 'OPTIX', 'CPU', 'HIP', 'METAL'}:
continue
# Try to find existing Device entry
entry = self.find_existing_device_entry(device)
@@ -1370,7 +1426,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
import _cycles
# Ensure `self.devices` is not re-allocated when the second call to
# get_devices_for_type is made, freeing items from the first list.
for device_type in ('CUDA', 'OPTIX', 'HIP'):
for device_type in ('CUDA', 'OPTIX', 'HIP', 'METAL'):
self.update_device_entries(_cycles.available_devices(device_type))
# Deprecated: use refresh_devices instead.
@@ -1396,6 +1452,19 @@ class CyclesPreferences(bpy.types.AddonPreferences):
num += 1
return num
def has_multi_device(self):
import _cycles
compute_device_type = self.get_compute_device_type()
device_list = _cycles.available_devices(compute_device_type)
for device in device_list:
if device[1] == compute_device_type:
continue
for dev in self.devices:
if dev.use and dev.id == device[2]:
return True
return False
def has_active_device(self):
return self.get_num_gpu_devices() > 0
@@ -1422,6 +1491,8 @@ class CyclesPreferences(bpy.types.AddonPreferences):
col.label(text="Requires discrete AMD GPU with RDNA architecture", icon='BLANK1')
if sys.platform[:3] == "win":
col.label(text="and AMD Radeon Pro 21.Q4 driver or newer", icon='BLANK1')
elif device_type == 'METAL':
col.label(text="Requires Apple Silicon and macOS 12.0 or newer", icon='BLANK1')
return
for device in devices:

View File

@@ -97,6 +97,11 @@ def use_cpu(context):
return (get_device_type(context) == 'NONE' or cscene.device == 'CPU')
def use_metal(context):
cscene = context.scene.cycles
return (get_device_type(context) == 'METAL' and cscene.device == 'GPU')
def use_cuda(context):
cscene = context.scene.cycles
@@ -113,11 +118,11 @@ def use_optix(context):
return (get_device_type(context) == 'OPTIX' and cscene.device == 'GPU')
def use_sample_all_lights(context):
def use_multi_device(context):
cscene = context.scene.cycles
return cscene.sample_all_lights_direct or cscene.sample_all_lights_indirect
if cscene.device != 'GPU':
return False
return context.preferences.addons[__package__].preferences.has_multi_device()
def show_device_active(context):
@@ -290,15 +295,18 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
col.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling)
col.prop(cscene, "sampling_pattern", text="Pattern")
col = layout.column(align=True)
col.prop(cscene, "sample_offset")
layout.separator()
col = layout.column(align=True)
col.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling)
col.prop(cscene, "scrambling_distance", text="Scrambling Distance")
col.prop(cscene, "adaptive_scrambling_distance", text="Adaptive")
sub = col.row(align=True)
heading = layout.column(align=True, heading="Scrambling Distance")
heading.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling)
heading.prop(cscene, "auto_scrambling_distance", text="Automatic")
sub = heading.row()
sub.active = not cscene.use_preview_adaptive_sampling
sub.prop(cscene, "preview_scrambling_distance", text="Viewport")
heading.prop(cscene, "scrambling_distance", text="Multiplier")
layout.separator()
@@ -659,6 +667,10 @@ class CYCLES_RENDER_PT_performance_acceleration_structure(CyclesButtonsPanel, Pa
bl_label = "Acceleration Structure"
bl_parent_id = "CYCLES_RENDER_PT_performance"
@classmethod
def poll(cls, context):
return not use_optix(context) or has_multi_device(context)
def draw(self, context):
import _cycles
@@ -671,21 +683,33 @@ class CYCLES_RENDER_PT_performance_acceleration_structure(CyclesButtonsPanel, Pa
col = layout.column()
use_embree = False
use_embree = _cycles.with_embree
if use_cpu(context):
use_embree = _cycles.with_embree
if not use_embree:
col.prop(cscene, "debug_use_spatial_splits")
if use_embree:
col.prop(cscene, "debug_use_compact_bvh")
else:
sub = col.column()
sub.active = not cscene.debug_use_spatial_splits
sub.prop(cscene, "debug_bvh_time_steps")
col.prop(cscene, "debug_use_hair_bvh")
sub = col.column(align=True)
sub.label(text="Cycles built without Embree support")
sub.label(text="CPU raytracing performance will be poor")
else:
col.prop(cscene, "debug_use_spatial_splits")
sub = col.column()
sub.active = not cscene.debug_use_spatial_splits
sub.prop(cscene, "debug_bvh_time_steps")
col.prop(cscene, "debug_use_spatial_splits")
sub = col.column()
sub.active = not use_embree
sub.prop(cscene, "debug_use_hair_bvh")
sub = col.column()
sub.active = not cscene.debug_use_spatial_splits and not use_embree
sub.prop(cscene, "debug_bvh_time_steps")
col.prop(cscene, "debug_use_hair_bvh")
# CPU is used in addition to a GPU
if use_multi_device(context) and use_embree:
col.prop(cscene, "debug_use_compact_bvh")
class CYCLES_RENDER_PT_performance_final_render(CyclesButtonsPanel, Panel):
@@ -1012,7 +1036,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
def poll(cls, context):
ob = context.object
if CyclesButtonsPanel.poll(context) and ob:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA'}:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA', 'HAIR', 'POINTCLOUD'}:
return True
if ob.instance_type == 'COLLECTION' and ob.instance_collection:
return True
@@ -1051,7 +1075,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
def has_geometry_visibility(ob):
return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT'}) or
return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT', 'VOLUME', 'POINTCLOUD', 'HAIR'}) or
(ob.instance_type == 'COLLECTION' and ob.instance_collection))
@@ -1795,18 +1819,45 @@ class CYCLES_RENDER_PT_bake_output(CyclesButtonsPanel, Panel):
rd = scene.render
if rd.use_bake_multires:
layout.prop(rd, "bake_margin")
layout.prop(rd, "use_bake_clear", text="Clear Image")
if rd.bake_type == 'DISPLACEMENT':
layout.prop(rd, "use_bake_lores_mesh")
else:
layout.prop(cbk, "target")
if cbk.target == 'IMAGE_TEXTURES':
layout.prop(cbk, "margin")
layout.prop(cbk, "use_clear", text="Clear Image")
class CYCLES_RENDER_PT_bake_output_margin(CyclesButtonsPanel, Panel):
bl_label = "Margin"
bl_context = "render"
bl_parent_id = "CYCLES_RENDER_PT_bake_output"
COMPAT_ENGINES = {'CYCLES'}
@classmethod
def poll(cls, context):
scene = context.scene
cbk = scene.render.bake
return cbk.target == 'IMAGE_TEXTURES'
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
scene = context.scene
cscene = scene.cycles
cbk = scene.render.bake
rd = scene.render
if rd.use_bake_multires:
layout.prop(rd, "bake_margin_type", text="Type")
layout.prop(rd, "bake_margin", text="Size")
else:
if cbk.target == 'IMAGE_TEXTURES':
layout.prop(cbk, "margin_type", text="Type")
layout.prop(cbk, "margin", text="Size")
class CYCLES_RENDER_PT_debug(CyclesDebugButtonsPanel, Panel):
bl_label = "Debug"
@@ -1816,37 +1867,38 @@ class CYCLES_RENDER_PT_debug(CyclesDebugButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
scene = context.scene
cscene = scene.cycles
col = layout.column()
col = layout.column(heading="CPU")
col.label(text="CPU Flags:")
row = col.row(align=True)
row.prop(cscene, "debug_use_cpu_sse2", toggle=True)
row.prop(cscene, "debug_use_cpu_sse3", toggle=True)
row.prop(cscene, "debug_use_cpu_sse41", toggle=True)
row.prop(cscene, "debug_use_cpu_avx", toggle=True)
row.prop(cscene, "debug_use_cpu_avx2", toggle=True)
col.prop(cscene, "debug_bvh_layout")
col.prop(cscene, "debug_bvh_layout", text="BVH")
col.separator()
col = layout.column()
col.label(text="CUDA Flags:")
col = layout.column(heading="CUDA")
col.prop(cscene, "debug_use_cuda_adaptive_compile")
col = layout.column(heading="OptiX")
col.prop(cscene, "debug_use_optix_debug", text="Module Debug")
col.separator()
col = layout.column()
col.label(text="OptiX Flags:")
col.prop(cscene, "debug_use_optix_debug")
col.prop(cscene, "debug_bvh_type", text="Viewport BVH")
col.separator()
col = layout.column()
col.prop(cscene, "debug_bvh_type")
import _cycles
if _cycles.with_debug:
col.prop(cscene, "direct_light_sampling_type")
class CYCLES_RENDER_PT_simplify(CyclesButtonsPanel, Panel):
@@ -2174,6 +2226,7 @@ classes = (
CYCLES_RENDER_PT_bake_influence,
CYCLES_RENDER_PT_bake_selected_to_active,
CYCLES_RENDER_PT_bake_output,
CYCLES_RENDER_PT_bake_output_margin,
CYCLES_RENDER_PT_debug,
node_panel(CYCLES_MATERIAL_PT_settings),
node_panel(CYCLES_MATERIAL_PT_settings_surface),

View File

@@ -69,6 +69,12 @@ struct BlenderCamera {
float pole_merge_angle_from;
float pole_merge_angle_to;
float fisheye_polynomial_k0;
float fisheye_polynomial_k1;
float fisheye_polynomial_k2;
float fisheye_polynomial_k3;
float fisheye_polynomial_k4;
enum { AUTO, HORIZONTAL, VERTICAL } sensor_fit;
float sensor_width;
float sensor_height;
@@ -200,6 +206,12 @@ static void blender_camera_from_object(BlenderCamera *bcam,
bcam->longitude_min = RNA_float_get(&ccamera, "longitude_min");
bcam->longitude_max = RNA_float_get(&ccamera, "longitude_max");
bcam->fisheye_polynomial_k0 = RNA_float_get(&ccamera, "fisheye_polynomial_k0");
bcam->fisheye_polynomial_k1 = RNA_float_get(&ccamera, "fisheye_polynomial_k1");
bcam->fisheye_polynomial_k2 = RNA_float_get(&ccamera, "fisheye_polynomial_k2");
bcam->fisheye_polynomial_k3 = RNA_float_get(&ccamera, "fisheye_polynomial_k3");
bcam->fisheye_polynomial_k4 = RNA_float_get(&ccamera, "fisheye_polynomial_k4");
bcam->interocular_distance = b_camera.stereo().interocular_distance();
if (b_camera.stereo().convergence_mode() == BL::CameraStereoData::convergence_mode_PARALLEL) {
bcam->convergence_distance = FLT_MAX;
@@ -422,7 +434,8 @@ static void blender_camera_sync(Camera *cam,
cam->set_full_height(height);
/* panorama sensor */
if (bcam->type == CAMERA_PANORAMA && bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID) {
if (bcam->type == CAMERA_PANORAMA && (bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID ||
bcam->panorama_type == PANORAMA_FISHEYE_LENS_POLYNOMIAL)) {
float fit_xratio = (float)bcam->render_width * bcam->pixelaspect.x;
float fit_yratio = (float)bcam->render_height * bcam->pixelaspect.y;
bool horizontal_fit;
@@ -465,6 +478,12 @@ static void blender_camera_sync(Camera *cam,
cam->set_latitude_min(bcam->latitude_min);
cam->set_latitude_max(bcam->latitude_max);
cam->set_fisheye_polynomial_k0(bcam->fisheye_polynomial_k0);
cam->set_fisheye_polynomial_k1(bcam->fisheye_polynomial_k1);
cam->set_fisheye_polynomial_k2(bcam->fisheye_polynomial_k2);
cam->set_fisheye_polynomial_k3(bcam->fisheye_polynomial_k3);
cam->set_fisheye_polynomial_k4(bcam->fisheye_polynomial_k4);
cam->set_longitude_min(bcam->longitude_min);
cam->set_longitude_max(bcam->longitude_max);

View File

@@ -199,7 +199,7 @@ static bool ObtainCacheParticleUV(Hair *hair,
b_mesh->uv_layers.begin(l);
float2 uv = zero_float2();
if (b_mesh->uv_layers.length())
if (!b_mesh->uv_layers.empty())
b_psys.uv_on_emitter(psmd, *b_pa, pa_no, uv_num, &uv.x);
CData->curve_uv.push_back_slow(uv);
@@ -261,7 +261,7 @@ static bool ObtainCacheParticleVcol(Hair *hair,
b_mesh->vertex_colors.begin(l);
float4 vcol = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
if (b_mesh->vertex_colors.length())
if (!b_mesh->vertex_colors.empty())
b_psys.mcol_on_emitter(psmd, *b_pa, pa_no, vcol_num, &vcol.x);
CData->curve_vcol.push_back_slow(vcol);
@@ -819,11 +819,14 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, H
new_hair.set_used_shaders(used_shaders);
if (view_layer.use_hair) {
#ifdef WITH_HAIR_NODES
if (b_ob_info.object_data.is_a(&RNA_Hair)) {
/* Hair object. */
sync_hair(&new_hair, b_ob_info, false);
}
else {
else
#endif
{
/* Particle hair. */
bool need_undeformed = new_hair.need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
@@ -870,12 +873,15 @@ void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
/* Export deformed coordinates. */
if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) {
#ifdef WITH_HAIR_NODES
if (b_ob_info.object_data.is_a(&RNA_Hair)) {
/* Hair object. */
sync_hair(hair, b_ob_info, true, motion_step);
return;
}
else {
else
#endif
{
/* Particle hair. */
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob_info, b_depsgraph, false, Mesh::SUBDIVISION_NONE);

View File

@@ -27,6 +27,7 @@ enum ComputeDevice {
COMPUTE_DEVICE_CUDA = 1,
COMPUTE_DEVICE_OPTIX = 3,
COMPUTE_DEVICE_HIP = 4,
COMPUTE_DEVICE_METAL = 5,
COMPUTE_DEVICE_NUM
};
@@ -85,6 +86,9 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences, BL::Scene &b_scen
else if (compute_device == COMPUTE_DEVICE_HIP) {
mask |= DEVICE_MASK_HIP;
}
else if (compute_device == COMPUTE_DEVICE_METAL) {
mask |= DEVICE_MASK_METAL;
}
vector<DeviceInfo> devices = Device::available_devices(mask);
/* Match device preferences and available devices. */

View File

@@ -272,12 +272,300 @@ uint BlenderDisplaySpaceShader::get_shader_program()
return shader_program_;
}
/* --------------------------------------------------------------------
* DrawTile.
*/
/* Higher level representation of a texture from the graphics library. */
class GLTexture {
public:
/* Global counter for all allocated OpenGL textures used by instances of this class. */
static inline std::atomic<int> num_used = 0;
GLTexture() = default;
~GLTexture()
{
assert(gl_id == 0);
}
GLTexture(const GLTexture &other) = delete;
GLTexture &operator=(GLTexture &other) = delete;
GLTexture(GLTexture &&other) noexcept
: gl_id(other.gl_id), width(other.width), height(other.height)
{
other.reset();
}
GLTexture &operator=(GLTexture &&other)
{
if (this == &other) {
return *this;
}
gl_id = other.gl_id;
width = other.width;
height = other.height;
other.reset();
return *this;
}
bool gl_resources_ensure()
{
if (gl_id) {
return true;
}
/* Create texture. */
glGenTextures(1, &gl_id);
if (!gl_id) {
LOG(ERROR) << "Error creating texture.";
return false;
}
/* Configure the texture. */
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gl_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
/* Clamp to edge so that precision issues when zoomed out (which forces linear interpolation)
* does not cause unwanted repetition. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
++num_used;
return true;
}
void gl_resources_destroy()
{
if (!gl_id) {
return;
}
glDeleteTextures(1, &gl_id);
reset();
--num_used;
}
/* OpenGL resource IDs of the texture.
*
* NOTE: Allocated on the render engine's context. */
uint gl_id = 0;
/* Dimensions of the texture in pixels. */
int width = 0;
int height = 0;
protected:
void reset()
{
gl_id = 0;
width = 0;
height = 0;
}
};
/* Higher level representation of a Pixel Buffer Object (PBO) from the graphics library. */
class GLPixelBufferObject {
public:
/* Global counter for all allocated OpenGL PBOs used by instances of this class. */
static inline std::atomic<int> num_used = 0;
GLPixelBufferObject() = default;
~GLPixelBufferObject()
{
assert(gl_id == 0);
}
GLPixelBufferObject(const GLPixelBufferObject &other) = delete;
GLPixelBufferObject &operator=(GLPixelBufferObject &other) = delete;
GLPixelBufferObject(GLPixelBufferObject &&other) noexcept
: gl_id(other.gl_id), width(other.width), height(other.height)
{
other.reset();
}
GLPixelBufferObject &operator=(GLPixelBufferObject &&other)
{
if (this == &other) {
return *this;
}
gl_id = other.gl_id;
width = other.width;
height = other.height;
other.reset();
return *this;
}
bool gl_resources_ensure()
{
if (gl_id) {
return true;
}
glGenBuffers(1, &gl_id);
if (!gl_id) {
LOG(ERROR) << "Error creating texture pixel buffer object.";
return false;
}
++num_used;
return true;
}
void gl_resources_destroy()
{
if (!gl_id) {
return;
}
glDeleteBuffers(1, &gl_id);
reset();
--num_used;
}
/* OpenGL resource IDs of the PBO.
*
* NOTE: Allocated on the render engine's context. */
uint gl_id = 0;
/* Dimensions of the PBO. */
int width = 0;
int height = 0;
protected:
void reset()
{
gl_id = 0;
width = 0;
height = 0;
}
};
class DrawTile {
public:
DrawTile() = default;
~DrawTile() = default;
DrawTile(const DrawTile &other) = delete;
DrawTile &operator=(const DrawTile &other) = delete;
DrawTile(DrawTile &&other) noexcept = default;
DrawTile &operator=(DrawTile &&other) = default;
bool gl_resources_ensure()
{
if (!texture.gl_resources_ensure()) {
gl_resources_destroy();
return false;
}
if (!gl_vertex_buffer) {
glGenBuffers(1, &gl_vertex_buffer);
if (!gl_vertex_buffer) {
LOG(ERROR) << "Error allocating tile VBO.";
gl_resources_destroy();
return false;
}
}
return true;
}
void gl_resources_destroy()
{
texture.gl_resources_destroy();
if (gl_vertex_buffer) {
glDeleteBuffers(1, &gl_vertex_buffer);
gl_vertex_buffer = 0;
}
}
inline bool ready_to_draw() const
{
return texture.gl_id != 0;
}
/* Texture which contains pixels of the tile. */
GLTexture texture;
/* Display parameters the texture of this tile has been updated for. */
BlenderDisplayDriver::Params params;
/* OpenGL resources needed for drawing. */
uint gl_vertex_buffer = 0;
};
class DrawTileAndPBO {
public:
bool gl_resources_ensure()
{
if (!tile.gl_resources_ensure() || !buffer_object.gl_resources_ensure()) {
gl_resources_destroy();
return false;
}
return true;
}
void gl_resources_destroy()
{
tile.gl_resources_destroy();
buffer_object.gl_resources_destroy();
}
DrawTile tile;
GLPixelBufferObject buffer_object;
};
/* --------------------------------------------------------------------
* BlenderDisplayDriver.
*/
struct BlenderDisplayDriver::Tiles {
/* Resources of a tile which is being currently rendered. */
DrawTileAndPBO current_tile;
/* All tiles which rendering is finished and which content will not be changed. */
struct {
vector<DrawTile> tiles;
void gl_resources_destroy_and_clear()
{
for (DrawTile &tile : tiles) {
tile.gl_resources_destroy();
}
tiles.clear();
}
} finished_tiles;
};
BlenderDisplayDriver::BlenderDisplayDriver(BL::RenderEngine &b_engine, BL::Scene &b_scene)
: b_engine_(b_engine), display_shader_(BlenderDisplayShader::create(b_engine, b_scene))
: b_engine_(b_engine),
display_shader_(BlenderDisplayShader::create(b_engine, b_scene)),
tiles_(make_unique<Tiles>())
{
/* Create context while on the main thread. */
gl_context_create();
@@ -292,6 +580,21 @@ BlenderDisplayDriver::~BlenderDisplayDriver()
* Update procedure.
*/
void BlenderDisplayDriver::next_tile_begin()
{
if (!tiles_->current_tile.tile.ready_to_draw()) {
LOG(ERROR)
<< "Unexpectedly moving to the next tile without any data provided for current tile.";
return;
}
/* Moving to the next tile without giving render data for the current tile is not an expected
* situation. */
DCHECK(!need_clear_);
tiles_->finished_tiles.tiles.emplace_back(std::move(tiles_->current_tile.tile));
}
bool BlenderDisplayDriver::update_begin(const Params &params,
int texture_width,
int texture_height)
@@ -312,58 +615,96 @@ bool BlenderDisplayDriver::update_begin(const Params &params,
glWaitSync((GLsync)gl_render_sync_, 0, GL_TIMEOUT_IGNORED);
}
if (!gl_texture_resources_ensure()) {
DrawTile &current_tile = tiles_->current_tile.tile;
GLPixelBufferObject &current_tile_buffer_object = tiles_->current_tile.buffer_object;
/* Clear storage of all finished tiles when display clear is requested.
* Do it when new tile data is provided to handle the display clear flag in a single place.
* It also makes the logic reliable from the whether drawing did happen or not point of view. */
if (need_clear_) {
tiles_->finished_tiles.gl_resources_destroy_and_clear();
need_clear_ = false;
}
if (!tiles_->current_tile.gl_resources_ensure()) {
tiles_->current_tile.gl_resources_destroy();
gl_context_disable();
return false;
}
/* Update texture dimensions if needed. */
if (texture_.width != texture_width || texture_.height != texture_height) {
if (current_tile.texture.width != texture_width ||
current_tile.texture.height != texture_height) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_.gl_id);
glBindTexture(GL_TEXTURE_2D, current_tile.texture.gl_id);
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA16F, texture_width, texture_height, 0, GL_RGBA, GL_HALF_FLOAT, 0);
texture_.width = texture_width;
texture_.height = texture_height;
current_tile.texture.width = texture_width;
current_tile.texture.height = texture_height;
glBindTexture(GL_TEXTURE_2D, 0);
/* Texture did change, and no pixel storage was provided. Tag for an explicit zeroing out to
* avoid undefined content. */
texture_.need_clear = true;
}
/* Update PBO dimensions if needed.
*
* NOTE: Allocate the PBO for the the size which will fit the final render resolution (as in,
* NOTE: Allocate the PBO for the size which will fit the final render resolution (as in,
* at a resolution divider 1. This was we don't need to recreate graphics interoperability
* objects which are costly and which are tied to the specific underlying buffer size.
* The downside of this approach is that when graphics interoperability is not used we are
* sending too much data to GPU when resolution divider is not 1. */
/* TODO(sergey): Investigate whether keeping the PBO exact size of the texture makes non-interop
* mode faster. */
const int buffer_width = params.full_size.x;
const int buffer_height = params.full_size.y;
if (texture_.buffer_width != buffer_width || texture_.buffer_height != buffer_height) {
const int buffer_width = params.size.x;
const int buffer_height = params.size.y;
if (current_tile_buffer_object.width != buffer_width ||
current_tile_buffer_object.height != buffer_height) {
const size_t size_in_bytes = sizeof(half4) * buffer_width * buffer_height;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, current_tile_buffer_object.gl_id);
glBufferData(GL_PIXEL_UNPACK_BUFFER, size_in_bytes, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
texture_.buffer_width = buffer_width;
texture_.buffer_height = buffer_height;
current_tile_buffer_object.width = buffer_width;
current_tile_buffer_object.height = buffer_height;
}
/* New content will be provided to the texture in one way or another, so mark this in a
* centralized place. */
texture_.need_update = true;
texture_.params = params;
/* Store an updated parameters of the current tile.
* In theory it is only needed once per update of the tile, but doing it on every update is
* the easiest and is not expensive. */
tiles_->current_tile.tile.params = params;
return true;
}
static void update_tile_texture_pixels(const DrawTileAndPBO &tile)
{
const GLTexture &texture = tile.tile.texture;
DCHECK_NE(tile.buffer_object.gl_id, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture.gl_id);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, tile.buffer_object.gl_id);
glTexSubImage2D(
GL_TEXTURE_2D, 0, 0, 0, texture.width, texture.height, GL_RGBA, GL_HALF_FLOAT, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
}
void BlenderDisplayDriver::update_end()
{
/* Unpack the PBO into the texture as soon as the new content is provided.
*
* This allows to ensure that the unpacking happens while resources like graphics interop (which
* lifetime is outside of control of the display driver) are still valid, as well as allows to
* move the tile from being current to finished immediately after this call.
*
* One concern with this approach is that if the update happens more often than drawing then
* doing the unpack here occupies GPU transfer for no good reason. However, the render scheduler
* takes care of ensuring updates don't happen that often. In regular applications redraw will
* happen much more often than this update. */
update_tile_texture_pixels(tiles_->current_tile);
gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
@@ -376,7 +717,11 @@ void BlenderDisplayDriver::update_end()
half4 *BlenderDisplayDriver::map_texture_buffer()
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id);
const uint pbo_gl_id = tiles_->current_tile.buffer_object.gl_id;
DCHECK_NE(pbo_gl_id, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo_gl_id);
half4 *mapped_rgba_pixels = reinterpret_cast<half4 *>(
glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY));
@@ -384,15 +729,6 @@ half4 *BlenderDisplayDriver::map_texture_buffer()
LOG(ERROR) << "Error mapping BlenderDisplayDriver pixel buffer object.";
}
if (texture_.need_clear) {
const int64_t texture_width = texture_.width;
const int64_t texture_height = texture_.height;
memset(reinterpret_cast<void *>(mapped_rgba_pixels),
0,
texture_width * texture_height * sizeof(half4));
texture_.need_clear = false;
}
return mapped_rgba_pixels;
}
@@ -411,12 +747,9 @@ BlenderDisplayDriver::GraphicsInterop BlenderDisplayDriver::graphics_interop_get
{
GraphicsInterop interop_dst;
interop_dst.buffer_width = texture_.buffer_width;
interop_dst.buffer_height = texture_.buffer_height;
interop_dst.opengl_pbo_id = texture_.gl_pbo_id;
interop_dst.need_clear = texture_.need_clear;
texture_.need_clear = false;
interop_dst.buffer_width = tiles_->current_tile.buffer_object.width;
interop_dst.buffer_height = tiles_->current_tile.buffer_object.height;
interop_dst.opengl_pbo_id = tiles_->current_tile.buffer_object.gl_id;
return interop_dst;
}
@@ -437,7 +770,7 @@ void BlenderDisplayDriver::graphics_interop_deactivate()
void BlenderDisplayDriver::clear()
{
texture_.need_clear = true;
need_clear_ = true;
}
void BlenderDisplayDriver::set_zoom(float zoom_x, float zoom_y)
@@ -445,26 +778,155 @@ void BlenderDisplayDriver::set_zoom(float zoom_x, float zoom_y)
zoom_ = make_float2(zoom_x, zoom_y);
}
/* Update vertex buffer with new coordinates of vertex positions and texture coordinates.
* This buffer is used to render texture in the viewport.
*
* NOTE: The buffer needs to be bound. */
static void vertex_buffer_update(const DisplayDriver::Params &params)
{
const int x = params.full_offset.x;
const int y = params.full_offset.y;
const int width = params.size.x;
const int height = params.size.y;
/* Invalidate old contents - avoids stalling if the buffer is still waiting in queue to be
* rendered. */
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
float *vpointer = reinterpret_cast<float *>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY));
if (!vpointer) {
return;
}
vpointer[0] = 0.0f;
vpointer[1] = 0.0f;
vpointer[2] = x;
vpointer[3] = y;
vpointer[4] = 1.0f;
vpointer[5] = 0.0f;
vpointer[6] = x + width;
vpointer[7] = y;
vpointer[8] = 1.0f;
vpointer[9] = 1.0f;
vpointer[10] = x + width;
vpointer[11] = y + height;
vpointer[12] = 0.0f;
vpointer[13] = 1.0f;
vpointer[14] = x;
vpointer[15] = y + height;
glUnmapBuffer(GL_ARRAY_BUFFER);
}
static void draw_tile(const float2 &zoom,
const int texcoord_attribute,
const int position_attribute,
const DrawTile &draw_tile)
{
if (!draw_tile.ready_to_draw()) {
return;
}
const GLTexture &texture = draw_tile.texture;
DCHECK_NE(texture.gl_id, 0);
DCHECK_NE(draw_tile.gl_vertex_buffer, 0);
glBindBuffer(GL_ARRAY_BUFFER, draw_tile.gl_vertex_buffer);
/* Draw at the parameters for which the texture has been updated for. This allows to always draw
* texture during bordered-rendered camera view without flickering. The validness of the display
* parameters for a texture is guaranteed by the initial "clear" state which makes drawing to
* have an early output.
*
* Such approach can cause some extra "jelly" effect during panning, but it is not more jelly
* than overlay of selected objects. Also, it's possible to redraw texture at an intersection of
* the texture draw parameters and the latest updated draw parameters (although, complexity of
* doing it might not worth it. */
vertex_buffer_update(draw_tile.params);
glBindTexture(GL_TEXTURE_2D, texture.gl_id);
/* Trick to keep sharp rendering without jagged edges on all GPUs.
*
* The idea here is to enforce driver to use linear interpolation when the image is not zoomed
* in.
* For the render result with a resolution divider in effect we always use nearest interpolation.
*
* Use explicit MIN assignment to make sure the driver does not have an undefined behavior at
* the zoom level 1. The MAG filter is always NEAREST. */
const float zoomed_width = draw_tile.params.size.x * zoom.x;
const float zoomed_height = draw_tile.params.size.y * zoom.y;
if (texture.width != draw_tile.params.size.x || texture.height != draw_tile.params.size.y) {
/* Resolution divider is different from 1, force nearest interpolation. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
else if (zoomed_width - draw_tile.params.size.x > 0.5f ||
zoomed_height - draw_tile.params.size.y > 0.5f) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
glVertexAttribPointer(
texcoord_attribute, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (const GLvoid *)0);
glVertexAttribPointer(position_attribute,
2,
GL_FLOAT,
GL_FALSE,
4 * sizeof(float),
(const GLvoid *)(sizeof(float) * 2));
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
void BlenderDisplayDriver::flush()
{
/* This is called from the render thread that also calls update_begin/end, right before ending
* the render loop. We wait for any queued PBO and render commands to be done, before destroying
* the render thread and activating the context in the main thread to destroy resources.
*
* If we don't do this, the NVIDIA driver hangs for a few seconds for when ending 3D viewport
* rendering, for unknown reasons. This was found with NVIDIA driver version 470.73 and a Quadro
* RTX 6000 on Linux. */
if (!gl_context_enable()) {
return;
}
if (gl_upload_sync_) {
glWaitSync((GLsync)gl_upload_sync_, 0, GL_TIMEOUT_IGNORED);
}
if (gl_render_sync_) {
glWaitSync((GLsync)gl_render_sync_, 0, GL_TIMEOUT_IGNORED);
}
gl_context_disable();
}
void BlenderDisplayDriver::draw(const Params &params)
{
/* See do_update_begin() for why no locking is required here. */
const bool transparent = true; // TODO(sergey): Derive this from Film.
if (!gl_draw_resources_ensure()) {
return;
}
if (use_gl_context_) {
gl_context_mutex_.lock();
}
if (texture_.need_clear) {
if (need_clear_) {
/* Texture is requested to be cleared and was not yet cleared.
*
* Do early return which should be equivalent of drawing all-zero texture.
* Watch out for the lock though so that the clear happening during update is properly
* synchronized here. */
gl_context_mutex_.unlock();
if (use_gl_context_) {
gl_context_mutex_.unlock();
}
return;
}
@@ -477,66 +939,37 @@ void BlenderDisplayDriver::draw(const Params &params)
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
display_shader_->bind(params.full_size.x, params.full_size.y);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_.gl_id);
/* Trick to keep sharp rendering without jagged edges on all GPUs.
*
* The idea here is to enforce driver to use linear interpolation when the image is not zoomed
* in.
* For the render result with a resolution divider in effect we always use nearest interpolation.
*
* Use explicit MIN assignment to make sure the driver does not have an undefined behavior at
* the zoom level 1. The MAG filter is always NEAREST. */
const float zoomed_width = params.size.x * zoom_.x;
const float zoomed_height = params.size.y * zoom_.y;
if (texture_.width != params.size.x || texture_.height != params.size.y) {
/* Resolution divider is different from 1, force nearest interpolation. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
else if (zoomed_width - params.size.x > 0.5f || zoomed_height - params.size.y > 0.5f) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
texture_update_if_needed();
vertex_buffer_update(params);
/* TODO(sergey): Does it make sense/possible to cache/reuse the VAO? */
/* NOTE: The VAO is to be allocated on the drawing context as it is not shared across contexts.
* Simplest is to allocate it on every redraw so that it is possible to destroy it from a
* correct context. */
GLuint vertex_array_object;
glGenVertexArrays(1, &vertex_array_object);
glBindVertexArray(vertex_array_object);
display_shader_->bind(params.full_size.x, params.full_size.y);
const int texcoord_attribute = display_shader_->get_tex_coord_attrib_location();
const int position_attribute = display_shader_->get_position_attrib_location();
glEnableVertexAttribArray(texcoord_attribute);
glEnableVertexAttribArray(position_attribute);
glVertexAttribPointer(
texcoord_attribute, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (const GLvoid *)0);
glVertexAttribPointer(position_attribute,
2,
GL_FLOAT,
GL_FALSE,
4 * sizeof(float),
(const GLvoid *)(sizeof(float) * 2));
draw_tile(zoom_, texcoord_attribute, position_attribute, tiles_->current_tile.tile);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glDeleteVertexArrays(1, &vertex_array_object);
for (const DrawTile &tile : tiles_->finished_tiles.tiles) {
draw_tile(zoom_, texcoord_attribute, position_attribute, tile);
}
display_shader_->unbind();
glBindTexture(GL_TEXTURE_2D, 0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteVertexArrays(1, &vertex_array_object);
if (transparent) {
glDisable(GL_BLEND);
}
@@ -544,6 +977,11 @@ void BlenderDisplayDriver::draw(const Params &params)
gl_render_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
if (VLOG_IS_ON(5)) {
VLOG(5) << "Number of textures: " << GLTexture::num_used;
VLOG(5) << "Number of PBOs: " << GLPixelBufferObject::num_used;
}
if (use_gl_context_) {
gl_context_mutex_.unlock();
}
@@ -618,154 +1056,16 @@ void BlenderDisplayDriver::gl_context_dispose()
}
}
bool BlenderDisplayDriver::gl_draw_resources_ensure()
{
if (!texture_.gl_id) {
/* If there is no texture allocated, there is nothing to draw. Inform the draw call that it can
* can not continue. Note that this is not an unrecoverable error, so once the texture is known
* we will come back here and create all the GPU resources needed for draw. */
return false;
}
if (gl_draw_resource_creation_attempted_) {
return gl_draw_resources_created_;
}
gl_draw_resource_creation_attempted_ = true;
if (!vertex_buffer_) {
glGenBuffers(1, &vertex_buffer_);
if (!vertex_buffer_) {
LOG(ERROR) << "Error creating vertex buffer.";
return false;
}
}
gl_draw_resources_created_ = true;
return true;
}
void BlenderDisplayDriver::gl_resources_destroy()
{
gl_context_enable();
if (vertex_buffer_ != 0) {
glDeleteBuffers(1, &vertex_buffer_);
}
if (texture_.gl_pbo_id) {
glDeleteBuffers(1, &texture_.gl_pbo_id);
texture_.gl_pbo_id = 0;
}
if (texture_.gl_id) {
glDeleteTextures(1, &texture_.gl_id);
texture_.gl_id = 0;
}
tiles_->current_tile.gl_resources_destroy();
tiles_->finished_tiles.gl_resources_destroy_and_clear();
gl_context_disable();
gl_context_dispose();
}
bool BlenderDisplayDriver::gl_texture_resources_ensure()
{
if (texture_.creation_attempted) {
return texture_.is_created;
}
texture_.creation_attempted = true;
DCHECK(!texture_.gl_id);
DCHECK(!texture_.gl_pbo_id);
/* Create texture. */
glGenTextures(1, &texture_.gl_id);
if (!texture_.gl_id) {
LOG(ERROR) << "Error creating texture.";
return false;
}
/* Configure the texture. */
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_.gl_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0);
/* Create PBO for the texture. */
glGenBuffers(1, &texture_.gl_pbo_id);
if (!texture_.gl_pbo_id) {
LOG(ERROR) << "Error creating texture pixel buffer object.";
return false;
}
/* Creation finished with a success. */
texture_.is_created = true;
return true;
}
void BlenderDisplayDriver::texture_update_if_needed()
{
if (!texture_.need_update) {
return;
}
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id);
glTexSubImage2D(
GL_TEXTURE_2D, 0, 0, 0, texture_.width, texture_.height, GL_RGBA, GL_HALF_FLOAT, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
texture_.need_update = false;
}
void BlenderDisplayDriver::vertex_buffer_update(const Params & /*params*/)
{
/* Draw at the parameters for which the texture has been updated for. This allows to always draw
* texture during bordered-rendered camera view without flickering. The validness of the display
* parameters for a texture is guaranteed by the initial "clear" state which makes drawing to
* have an early output.
*
* Such approach can cause some extra "jelly" effect during panning, but it is not more jelly
* than overlay of selected objects. Also, it's possible to redraw texture at an intersection of
* the texture draw parameters and the latest updated draw parameters (although, complexity of
* doing it might not worth it. */
const int x = texture_.params.full_offset.x;
const int y = texture_.params.full_offset.y;
const int width = texture_.params.size.x;
const int height = texture_.params.size.y;
/* Invalidate old contents - avoids stalling if the buffer is still waiting in queue to be
* rendered. */
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
float *vpointer = reinterpret_cast<float *>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY));
if (!vpointer) {
return;
}
vpointer[0] = 0.0f;
vpointer[1] = 0.0f;
vpointer[2] = x;
vpointer[3] = y;
vpointer[4] = 1.0f;
vpointer[5] = 0.0f;
vpointer[6] = x + width;
vpointer[7] = y;
vpointer[8] = 1.0f;
vpointer[9] = 1.0f;
vpointer[10] = x + width;
vpointer[11] = y + height;
vpointer[12] = 0.0f;
vpointer[13] = 1.0f;
vpointer[14] = x;
vpointer[15] = y + height;
glUnmapBuffer(GL_ARRAY_BUFFER);
}
CCL_NAMESPACE_END

View File

@@ -26,6 +26,7 @@
#include "util/thread.h"
#include "util/unique_ptr.h"
#include "util/vector.h"
CCL_NAMESPACE_BEGIN
@@ -112,6 +113,8 @@ class BlenderDisplayDriver : public DisplayDriver {
void set_zoom(float zoom_x, float zoom_y);
protected:
virtual void next_tile_begin() override;
virtual bool update_begin(const Params &params, int texture_width, int texture_height) override;
virtual void update_end() override;
@@ -122,33 +125,17 @@ class BlenderDisplayDriver : public DisplayDriver {
virtual void draw(const Params &params) override;
virtual void flush() override;
/* Helper function which allocates new GPU context. */
void gl_context_create();
bool gl_context_enable();
void gl_context_disable();
void gl_context_dispose();
/* Make sure texture is allocated and its initial configuration is performed. */
bool gl_texture_resources_ensure();
/* Ensure all runtime GPU resources needed for drawing are allocated.
* Returns true if all resources needed for drawing are available. */
bool gl_draw_resources_ensure();
/* Destroy all GPU resources which are being used by this object. */
void gl_resources_destroy();
/* Update GPU texture dimensions and content if needed (new pixel data was provided).
*
* NOTE: The texture needs to be bound. */
void texture_update_if_needed();
/* Update vertex buffer with new coordinates of vertex positions and texture coordinates.
* This buffer is used to render texture in the viewport.
*
* NOTE: The buffer needs to be bound. */
void vertex_buffer_update(const Params &params);
BL::RenderEngine b_engine_;
/* OpenGL context which is used the render engine doesn't have its own. */
@@ -159,50 +146,14 @@ class BlenderDisplayDriver : public DisplayDriver {
/* Mutex used to guard the `gl_context_`. */
thread_mutex gl_context_mutex_;
/* Texture which contains pixels of the render result. */
struct {
/* Indicates whether texture creation was attempted and succeeded.
* Used to avoid multiple attempts of texture creation on GPU issues or GPU context
* misconfiguration. */
bool creation_attempted = false;
bool is_created = false;
/* OpenGL resource IDs of the texture itself and Pixel Buffer Object (PBO) used to write
* pixels to it.
*
* NOTE: Allocated on the engine's context. */
uint gl_id = 0;
uint gl_pbo_id = 0;
/* Is true when new data was written to the PBO, meaning, the texture might need to be resized
* and new data is to be uploaded to the GPU. */
bool need_update = false;
/* Content of the texture is to be filled with zeroes. */
std::atomic<bool> need_clear = true;
/* Dimensions of the texture in pixels. */
int width = 0;
int height = 0;
/* Dimensions of the underlying PBO. */
int buffer_width = 0;
int buffer_height = 0;
/* Display parameters the texture has been updated for. */
Params params;
} texture_;
/* Content of the display is to be filled with zeroes. */
std::atomic<bool> need_clear_ = true;
unique_ptr<BlenderDisplayShader> display_shader_;
/* Special track of whether GPU resources were attempted to be created, to avoid attempts of
* their re-creation on failure on every redraw. */
bool gl_draw_resource_creation_attempted_ = false;
bool gl_draw_resources_created_ = false;
/* Vertex buffer which hold vertices of a triangle fan which is textures with the texture
* holding the render result. */
uint vertex_buffer_ = 0;
/* Opaque storage for an internal state and data for tiles. */
struct Tiles;
unique_ptr<Tiles> tiles_;
void *gl_render_sync_ = nullptr;
void *gl_upload_sync_ = nullptr;

View File

@@ -19,6 +19,7 @@
#include "scene/hair.h"
#include "scene/mesh.h"
#include "scene/object.h"
#include "scene/pointcloud.h"
#include "scene/volume.h"
#include "blender/sync.h"
@@ -31,10 +32,18 @@ CCL_NAMESPACE_BEGIN
static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_particle_hair)
{
#ifdef WITH_HAIR_NODES
if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) {
#else
if (use_particle_hair) {
#endif
return Geometry::HAIR;
}
if (b_ob_info.object_data.is_a(&RNA_PointCloud)) {
return Geometry::POINTCLOUD;
}
if (b_ob_info.object_data.is_a(&RNA_Volume) ||
(b_ob_info.object_data == b_ob_info.real_object.data() &&
object_fluid_gas_domain_find(b_ob_info.real_object))) {
@@ -107,6 +116,9 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
else if (geom_type == Geometry::VOLUME) {
geom = scene->create_node<Volume>();
}
else if (geom_type == Geometry::POINTCLOUD) {
geom = scene->create_node<PointCloud>();
}
else {
geom = scene->create_node<Mesh>();
}
@@ -166,6 +178,10 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
Volume *volume = static_cast<Volume *>(geom);
sync_volume(b_ob_info, volume);
}
else if (geom_type == Geometry::POINTCLOUD) {
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
sync_pointcloud(pointcloud, b_ob_info);
}
else {
Mesh *mesh = static_cast<Mesh *>(geom);
sync_mesh(b_depsgraph, b_ob_info, mesh);
@@ -215,7 +231,11 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
if (progress.get_cancel())
return;
#ifdef WITH_HAIR_NODES
if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) {
#else
if (use_particle_hair) {
#endif
Hair *hair = static_cast<Hair *>(geom);
sync_hair_motion(b_depsgraph, b_ob_info, hair, motion_step);
}
@@ -223,6 +243,10 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
object_fluid_gas_domain_find(b_ob_info.real_object)) {
/* No volume motion blur support yet. */
}
else if (b_ob_info.object_data.is_a(&RNA_PointCloud)) {
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
sync_pointcloud_motion(pointcloud, b_ob_info, motion_step);
}
else {
Mesh *mesh = static_cast<Mesh *>(geom);
sync_mesh_motion(b_depsgraph, b_ob_info, mesh, motion_step);

View File

@@ -24,8 +24,14 @@ CCL_NAMESPACE_BEGIN
/* Packed Images */
BlenderImageLoader::BlenderImageLoader(BL::Image b_image, int frame)
: b_image(b_image), frame(frame), free_cache(!b_image.has_data())
BlenderImageLoader::BlenderImageLoader(BL::Image b_image,
const int frame,
const bool is_preview_render)
: b_image(b_image),
frame(frame),
/* Don't free cache for preview render to avoid race condition from T93560, to be fixed
properly later as we are close to release. */
free_cache(!is_preview_render && !b_image.has_data())
{
}

View File

@@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN
class BlenderImageLoader : public ImageLoader {
public:
BlenderImageLoader(BL::Image b_image, int frame);
BlenderImageLoader(BL::Image b_image, const int frame, const bool is_preview_render);
bool load_metadata(const ImageDeviceFeatures &features, ImageMetaData &metadata) override;
bool load_pixels(const ImageMetaData &metadata,

View File

@@ -555,7 +555,7 @@ static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh,
/* Create uv map attributes. */
static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh)
{
if (b_mesh.uv_layers.length() != 0) {
if (!b_mesh.uv_layers.empty()) {
for (BL::MeshUVLoopLayer &l : b_mesh.uv_layers) {
const bool active_render = l.active_render();
AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE;
@@ -619,7 +619,7 @@ static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh)
static void attr_create_subd_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, bool subdivide_uvs)
{
if (b_mesh.uv_layers.length() != 0) {
if (!b_mesh.uv_layers.empty()) {
BL::Mesh::uv_layers_iterator l;
int i = 0;
@@ -951,7 +951,7 @@ static void create_mesh(Scene *scene,
N = attr_N->data_float3();
/* create generated coordinates from undeformed coordinates */
const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.length() == 0) &&
const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.empty()) &&
(mesh->need_attribute(scene, ATTR_STD_UV_TANGENT));
if (mesh->need_attribute(scene, ATTR_STD_GENERATED) || need_default_tangent) {
Attribute *attr = attributes.add(ATTR_STD_GENERATED);
@@ -1071,7 +1071,15 @@ static void create_subd_mesh(Scene *scene,
for (BL::MeshEdge &e : b_mesh.edges) {
if (e.crease() != 0.0f) {
mesh->add_crease(e.vertices()[0], e.vertices()[1], e.crease());
mesh->add_edge_crease(e.vertices()[0], e.vertices()[1], e.crease());
}
}
for (BL::MeshVertexCreaseLayer &c : b_mesh.vertex_creases) {
for (int i = 0; i < c.data.length(); ++i) {
if (c.data[i].value() != 0.0f) {
mesh->add_vertex_crease(i, c.data[i].value());
}
}
}
@@ -1086,40 +1094,6 @@ static void create_subd_mesh(Scene *scene,
/* Sync */
/* Check whether some of "built-in" motion-related attributes are needed to be exported (includes
* things like velocity from cache modifier, fluid simulation).
*
* NOTE: This code is run prior to object motion blur initialization. so can not access properties
* set by `sync_object_motion_init()`. */
static bool mesh_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene)
{
const Scene::MotionType need_motion = scene->need_motion();
if (need_motion == Scene::MOTION_NONE) {
/* Simple case: neither motion pass nor motion blur is needed, no need in the motion related
* attributes. */
return false;
}
if (need_motion == Scene::MOTION_BLUR) {
/* A bit tricky and implicit case:
* - Motion blur is enabled in the scene, which implies specific number of time steps for
* objects.
* - If the object has motion blur disabled on it, it will have 0 time steps.
* - Motion attribute expects non-zero time steps.
*
* Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */
PointerRNA cobject = RNA_pointer_get(&b_ob_info.real_object.ptr, "cycles");
const bool use_motion = get_boolean(cobject, "use_motion_blur");
if (!use_motion) {
return false;
}
}
/* Motion pass which implies 3 motion steps, or motion blur which is not disabled on object
* level. */
return true;
}
void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Mesh *mesh)
{
/* make a copy of the shaders as the caller in the main thread still need them for syncing the
@@ -1144,7 +1118,7 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, M
if (b_mesh) {
/* Motion blur attribute is relative to seconds, we need it relative to frames. */
const bool need_motion = mesh_need_motion_attribute(b_ob_info, scene);
const bool need_motion = object_need_motion_attribute(b_ob_info, scene);
const float motion_scale = (need_motion) ?
scene->motion_shutter_time() /
(b_scene.render().fps() / b_scene.render().fps_base()) :

View File

@@ -72,7 +72,8 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info)
BL::Object::type_enum type = b_ob_info.iter_object.type();
if (type == BL::Object::type_VOLUME || type == BL::Object::type_HAIR) {
if (type == BL::Object::type_VOLUME || type == BL::Object::type_HAIR ||
type == BL::Object::type_POINTCLOUD) {
/* Will be exported attached to mesh. */
return true;
}
@@ -206,7 +207,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
return NULL;
}
/* only interested in object that we can create meshes from */
/* only interested in object that we can create geometry from */
if (!object_is_geometry(b_ob_info)) {
return NULL;
}
@@ -294,7 +295,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
object->set_visibility(visibility);
object->set_is_shadow_catcher(b_ob.is_shadow_catcher());
object->set_is_shadow_catcher(b_ob.is_shadow_catcher() || b_parent.is_shadow_catcher());
float shadow_terminator_shading_offset = get_float(cobject, "shadow_terminator_offset");
object->set_shadow_terminator_shading_offset(shadow_terminator_shading_offset);
@@ -528,6 +529,17 @@ void BlenderSync::sync_procedural(BL::Object &b_ob,
string absolute_path = blender_absolute_path(b_data, b_ob, b_mesh_cache.cache_file().filepath());
procedural->set_filepath(ustring(absolute_path));
array<ustring> layers;
for (BL::CacheFileLayer &layer : cache_file.layers) {
if (layer.hide_layer()) {
continue;
}
absolute_path = blender_absolute_path(b_data, b_ob, layer.filepath());
layers.push_back_slow(ustring(absolute_path));
}
procedural->set_layers(layers);
procedural->set_scale(cache_file.scale());
procedural->set_use_prefetch(cache_file.use_prefetch());

View File

@@ -51,8 +51,6 @@ bool BlenderOutputDriver::read_render_tile(const Tile &tile)
BL::RenderLayer b_rlay = *b_single_rlay;
vector<float> pixels(tile.size.x * tile.size.y * 4);
/* Copy each pass.
* TODO:copy only the required ones for better performance? */
for (BL::RenderPass &b_pass : b_rlay.passes) {
@@ -66,7 +64,7 @@ bool BlenderOutputDriver::read_render_tile(const Tile &tile)
bool BlenderOutputDriver::update_render_tile(const Tile &tile)
{
/* Use final write for preview renders, otherwise render result wouldn't be be updated
/* Use final write for preview renders, otherwise render result wouldn't be updated
* quickly on Blender side. For all other cases we use the display driver. */
if (b_engine_.is_preview()) {
write_render_tile(tile);
@@ -109,7 +107,7 @@ void BlenderOutputDriver::write_render_tile(const Tile &tile)
BL::RenderLayer b_rlay = *b_single_rlay;
vector<float> pixels(tile.size.x * tile.size.y * 4);
vector<float> pixels(static_cast<size_t>(tile.size.x) * tile.size.y * 4);
/* Copy each pass. */
for (BL::RenderPass &b_pass : b_rlay.passes) {
@@ -120,7 +118,7 @@ void BlenderOutputDriver::write_render_tile(const Tile &tile)
b_pass.rect(&pixels[0]);
}
b_engine_.end_result(b_rr, true, false, true);
b_engine_.end_result(b_rr, false, false, true);
}
CCL_NAMESPACE_END

View File

@@ -0,0 +1,303 @@
/*
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "scene/pointcloud.h"
#include "scene/attribute.h"
#include "scene/scene.h"
#include "blender/sync.h"
#include "blender/util.h"
#include "util/foreach.h"
#include "util/hash.h"
CCL_NAMESPACE_BEGIN
template<typename TypeInCycles, typename GetValueAtIndex>
static void fill_generic_attribute(BL::PointCloud &b_pointcloud,
TypeInCycles *data,
const GetValueAtIndex &get_value_at_index)
{
const int num_points = b_pointcloud.points.length();
for (int i = 0; i < num_points; i++) {
data[i] = get_value_at_index(i);
}
}
static void attr_create_motion(PointCloud *pointcloud,
BL::Attribute &b_attribute,
const float motion_scale)
{
if (!(b_attribute.domain() == BL::Attribute::domain_POINT) &&
(b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) {
return;
}
BL::FloatVectorAttribute b_vector_attribute(b_attribute);
const int num_points = pointcloud->get_points().size();
/* Find or add attribute */
float3 *P = &pointcloud->get_points()[0];
Attribute *attr_mP = pointcloud->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if (!attr_mP) {
attr_mP = pointcloud->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
}
/* Only export previous and next frame, we don't have any in between data. */
float motion_times[2] = {-1.0f, 1.0f};
for (int step = 0; step < 2; step++) {
const float relative_time = motion_times[step] * 0.5f * motion_scale;
float3 *mP = attr_mP->data_float3() + step * num_points;
for (int i = 0; i < num_points; i++) {
mP[i] = P[i] + get_float3(b_vector_attribute.data[i].vector()) * relative_time;
}
}
}
static void copy_attributes(PointCloud *pointcloud,
BL::PointCloud b_pointcloud,
const bool need_motion,
const float motion_scale)
{
AttributeSet &attributes = pointcloud->attributes;
static const ustring u_velocity("velocity");
for (BL::Attribute &b_attribute : b_pointcloud.attributes) {
const ustring name{b_attribute.name().c_str()};
if (need_motion && name == u_velocity) {
attr_create_motion(pointcloud, b_attribute, motion_scale);
}
if (attributes.find(name)) {
continue;
}
const AttributeElement element = ATTR_ELEMENT_VERTEX;
const BL::Attribute::data_type_enum b_data_type = b_attribute.data_type();
switch (b_data_type) {
case BL::Attribute::data_type_FLOAT: {
BL::FloatAttribute b_float_attribute{b_attribute};
Attribute *attr = attributes.add(name, TypeFloat, element);
float *data = attr->data_float();
fill_generic_attribute(
b_pointcloud, data, [&](int i) { return b_float_attribute.data[i].value(); });
break;
}
case BL::Attribute::data_type_BOOLEAN: {
BL::BoolAttribute b_bool_attribute{b_attribute};
Attribute *attr = attributes.add(name, TypeFloat, element);
float *data = attr->data_float();
fill_generic_attribute(
b_pointcloud, data, [&](int i) { return (float)b_bool_attribute.data[i].value(); });
break;
}
case BL::Attribute::data_type_INT: {
BL::IntAttribute b_int_attribute{b_attribute};
Attribute *attr = attributes.add(name, TypeFloat, element);
float *data = attr->data_float();
fill_generic_attribute(
b_pointcloud, data, [&](int i) { return (float)b_int_attribute.data[i].value(); });
break;
}
case BL::Attribute::data_type_FLOAT_VECTOR: {
BL::FloatVectorAttribute b_vector_attribute{b_attribute};
Attribute *attr = attributes.add(name, TypeVector, element);
float3 *data = attr->data_float3();
fill_generic_attribute(b_pointcloud, data, [&](int i) {
BL::Array<float, 3> v = b_vector_attribute.data[i].vector();
return make_float3(v[0], v[1], v[2]);
});
break;
}
case BL::Attribute::data_type_FLOAT_COLOR: {
BL::FloatColorAttribute b_color_attribute{b_attribute};
Attribute *attr = attributes.add(name, TypeRGBA, element);
float4 *data = attr->data_float4();
fill_generic_attribute(b_pointcloud, data, [&](int i) {
BL::Array<float, 4> v = b_color_attribute.data[i].color();
return make_float4(v[0], v[1], v[2], v[3]);
});
break;
}
case BL::Attribute::data_type_FLOAT2: {
BL::Float2Attribute b_float2_attribute{b_attribute};
Attribute *attr = attributes.add(name, TypeFloat2, element);
float2 *data = attr->data_float2();
fill_generic_attribute(b_pointcloud, data, [&](int i) {
BL::Array<float, 2> v = b_float2_attribute.data[i].vector();
return make_float2(v[0], v[1]);
});
break;
}
default:
/* Not supported. */
break;
}
}
}
static void export_pointcloud(Scene *scene,
PointCloud *pointcloud,
BL::PointCloud b_pointcloud,
const bool need_motion,
const float motion_scale)
{
/* TODO: optimize so we can straight memcpy arrays from Blender? */
/* Add requested attributes. */
Attribute *attr_random = NULL;
if (pointcloud->need_attribute(scene, ATTR_STD_POINT_RANDOM)) {
attr_random = pointcloud->attributes.add(ATTR_STD_POINT_RANDOM);
}
/* Reserve memory. */
const int num_points = b_pointcloud.points.length();
pointcloud->reserve(num_points);
/* Export points. */
BL::PointCloud::points_iterator b_point_iter;
for (b_pointcloud.points.begin(b_point_iter); b_point_iter != b_pointcloud.points.end();
++b_point_iter) {
BL::Point b_point = *b_point_iter;
const float3 co = get_float3(b_point.co());
const float radius = b_point.radius();
pointcloud->add_point(co, radius);
/* Random number per point. */
if (attr_random != NULL) {
attr_random->add(hash_uint2_to_float(b_point.index(), 0));
}
}
/* Export attributes */
copy_attributes(pointcloud, b_pointcloud, need_motion, motion_scale);
}
static void export_pointcloud_motion(PointCloud *pointcloud,
BL::PointCloud b_pointcloud,
int motion_step)
{
/* Find or add attribute. */
Attribute *attr_mP = pointcloud->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
bool new_attribute = false;
if (!attr_mP) {
attr_mP = pointcloud->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
new_attribute = true;
}
/* Export motion points. */
const int num_points = pointcloud->num_points();
float3 *mP = attr_mP->data_float3() + motion_step * num_points;
bool have_motion = false;
int num_motion_points = 0;
const array<float3> &pointcloud_points = pointcloud->get_points();
BL::PointCloud::points_iterator b_point_iter;
for (b_pointcloud.points.begin(b_point_iter); b_point_iter != b_pointcloud.points.end();
++b_point_iter) {
BL::Point b_point = *b_point_iter;
if (num_motion_points < num_points) {
float3 P = get_float3(b_point.co());
P.w = b_point.radius();
mP[num_motion_points] = P;
have_motion = have_motion || (P != pointcloud_points[num_motion_points]);
num_motion_points++;
}
}
/* In case of new attribute, we verify if there really was any motion. */
if (new_attribute) {
if (num_motion_points != num_points || !have_motion) {
pointcloud->attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
}
else if (motion_step > 0) {
/* Motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now. */
for (int step = 0; step < motion_step; step++) {
pointcloud->copy_center_to_motion_step(step);
}
}
}
/* Export attributes */
copy_attributes(pointcloud, b_pointcloud, false, 0.0f);
}
void BlenderSync::sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info)
{
size_t old_numpoints = pointcloud->num_points();
array<Node *> used_shaders = pointcloud->get_used_shaders();
PointCloud new_pointcloud;
new_pointcloud.set_used_shaders(used_shaders);
/* TODO: add option to filter out points in the view layer. */
BL::PointCloud b_pointcloud(b_ob_info.object_data);
/* Motion blur attribute is relative to seconds, we need it relative to frames. */
const bool need_motion = object_need_motion_attribute(b_ob_info, scene);
const float motion_scale = (need_motion) ?
scene->motion_shutter_time() /
(b_scene.render().fps() / b_scene.render().fps_base()) :
0.0f;
export_pointcloud(scene, &new_pointcloud, b_pointcloud, need_motion, motion_scale);
/* update original sockets */
for (const SocketType &socket : new_pointcloud.type->inputs) {
/* Those sockets are updated in sync_object, so do not modify them. */
if (socket.name == "use_motion_blur" || socket.name == "motion_steps" ||
socket.name == "used_shaders") {
continue;
}
pointcloud->set_value(socket, new_pointcloud, socket);
}
pointcloud->attributes.clear();
foreach (Attribute &attr, new_pointcloud.attributes.attributes) {
pointcloud->attributes.attributes.push_back(std::move(attr));
}
/* tag update */
const bool rebuild = (pointcloud && old_numpoints != pointcloud->num_points());
pointcloud->tag_update(scene, rebuild);
}
void BlenderSync::sync_pointcloud_motion(PointCloud *pointcloud,
BObjectInfo &b_ob_info,
int motion_step)
{
/* Skip if nothing exported. */
if (pointcloud->num_points() == 0) {
return;
}
/* Export deformed coordinates. */
if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) {
/* PointCloud object. */
BL::PointCloud b_pointcloud(b_ob_info.object_data);
export_pointcloud_motion(pointcloud, b_pointcloud, motion_step);
}
else {
/* No deformation on this frame, copy coordinates if other frames did have it. */
pointcloud->copy_center_to_motion_step(motion_step);
}
}
CCL_NAMESPACE_END

View File

@@ -138,20 +138,18 @@ static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
static PyObject *init_func(PyObject * /*self*/, PyObject *args)
{
PyObject *path, *user_path, *temp_path;
PyObject *path, *user_path;
int headless;
if (!PyArg_ParseTuple(args, "OOOi", &path, &user_path, &temp_path, &headless)) {
if (!PyArg_ParseTuple(args, "OOi", &path, &user_path, &headless)) {
return nullptr;
}
PyObject *path_coerce = nullptr, *user_path_coerce = nullptr, *temp_path_coerce = nullptr;
PyObject *path_coerce = nullptr, *user_path_coerce = nullptr;
path_init(PyC_UnicodeAsByte(path, &path_coerce),
PyC_UnicodeAsByte(user_path, &user_path_coerce),
PyC_UnicodeAsByte(temp_path, &temp_path_coerce));
PyC_UnicodeAsByte(user_path, &user_path_coerce));
Py_XDECREF(path_coerce);
Py_XDECREF(user_path_coerce);
Py_XDECREF(temp_path_coerce);
BlenderSession::headless = headless;
@@ -735,27 +733,20 @@ static bool image_parse_filepaths(PyObject *pyfilepaths, vector<string> &filepat
static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *keywords)
{
#if 1
(void)args;
(void)keywords;
#else
static const char *keyword_list[] = {
"preferences", "scene", "view_layer", "input", "output", "tile_size", "samples", NULL};
"preferences", "scene", "view_layer", "input", "output", NULL};
PyObject *pypreferences, *pyscene, *pyviewlayer;
PyObject *pyinput, *pyoutput = NULL;
int tile_size = 0, samples = 0;
if (!PyArg_ParseTupleAndKeywords(args,
keywords,
"OOOO|Oii",
"OOOO|O",
(char **)keyword_list,
&pypreferences,
&pyscene,
&pyviewlayer,
&pyinput,
&pyoutput,
&tile_size,
&samples)) {
&pyoutput)) {
return NULL;
}
@@ -777,14 +768,10 @@ static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *key
&RNA_ViewLayer,
PyLong_AsVoidPtr(pyviewlayer),
&viewlayerptr);
PointerRNA cviewlayer = RNA_pointer_get(&viewlayerptr, "cycles");
BL::ViewLayer b_view_layer(viewlayerptr);
DenoiseParams params;
params.radius = get_int(cviewlayer, "denoising_radius");
params.strength = get_float(cviewlayer, "denoising_strength");
params.feature_strength = get_float(cviewlayer, "denoising_feature_strength");
params.relative_pca = get_boolean(cviewlayer, "denoising_relative_pca");
params.neighbor_frames = get_int(cviewlayer, "denoising_neighbor_frames");
DenoiseParams params = BlenderSync::get_denoise_params(b_scene, b_view_layer, true);
params.use = true;
/* Parse file paths list. */
vector<string> input, output;
@@ -812,24 +799,15 @@ static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *key
}
/* Create denoiser. */
DenoiserPipeline denoiser(device);
denoiser.params = params;
DenoiserPipeline denoiser(device, params);
denoiser.input = input;
denoiser.output = output;
if (tile_size > 0) {
denoiser.tile_size = make_int2(tile_size, tile_size);
}
if (samples > 0) {
denoiser.samples_override = samples;
}
/* Run denoiser. */
if (!denoiser.run()) {
PyErr_SetString(PyExc_ValueError, denoiser.error.c_str());
return NULL;
}
#endif
Py_RETURN_NONE;
}
@@ -906,16 +884,18 @@ static PyObject *enable_print_stats_func(PyObject * /*self*/, PyObject * /*args*
static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
{
vector<DeviceType> device_types = Device::available_types();
bool has_cuda = false, has_optix = false, has_hip = false;
bool has_cuda = false, has_optix = false, has_hip = false, has_metal = false;
foreach (DeviceType device_type, device_types) {
has_cuda |= (device_type == DEVICE_CUDA);
has_optix |= (device_type == DEVICE_OPTIX);
has_hip |= (device_type == DEVICE_HIP);
has_metal |= (device_type == DEVICE_METAL);
}
PyObject *list = PyTuple_New(3);
PyObject *list = PyTuple_New(4);
PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda));
PyTuple_SET_ITEM(list, 1, PyBool_FromLong(has_optix));
PyTuple_SET_ITEM(list, 2, PyBool_FromLong(has_hip));
PyTuple_SET_ITEM(list, 3, PyBool_FromLong(has_metal));
return list;
}
@@ -944,6 +924,9 @@ static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg)
else if (override == "HIP") {
BlenderSession::device_override = DEVICE_MASK_HIP;
}
else if (override == "METAL") {
BlenderSession::device_override = DEVICE_MASK_METAL;
}
else {
printf("\nError: %s is not a valid Cycles device.\n", override.c_str());
Py_RETURN_FALSE;
@@ -1054,5 +1037,13 @@ void *CCL_python_module_init()
Py_INCREF(Py_False);
}
#ifdef WITH_CYCLES_DEBUG
PyModule_AddObject(mod, "with_debug", Py_True);
Py_INCREF(Py_True);
#else /* WITH_CYCLES_DEBUG */
PyModule_AddObject(mod, "with_debug", Py_False);
Py_INCREF(Py_False);
#endif /* WITH_CYCLES_DEBUG */
return (void *)mod;
}

View File

@@ -129,7 +129,7 @@ void BlenderSession::create_session()
/* reset status/progress */
last_status = "";
last_error = "";
last_progress = -1.0f;
last_progress = -1.0;
start_resize_time = 0.0;
/* create session */
@@ -396,6 +396,13 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
/* set the current view */
b_engine.active_view_set(b_rview_name.c_str());
/* Force update in this case, since the camera transform on each frame changes
* in different views. This could be optimized by somehow storing the animated
* camera transforms separate from the fixed stereo transform. */
if ((scene->need_motion() != Scene::MOTION_NONE) && view_index > 0) {
sync->tag_update();
}
/* update scene */
BL::Object b_camera_override(b_engine.camera_override());
sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str());
@@ -495,10 +502,15 @@ void BlenderSession::render_frame_finish()
path_remove(filename);
}
/* Clear driver. */
/* Clear output driver. */
session->set_output_driver(nullptr);
session->full_buffer_written_cb = function_null;
/* The display driver holds OpenGL resources which belong to an OpenGL context held by the render
* engine on Blender side. Force destruction of those resources. */
display_driver_ = nullptr;
session->set_display_driver(nullptr);
/* All the files are handled.
* Clear the list so that this session can be re-used by Persistent Data. */
full_buffer_files_.clear();
@@ -615,6 +627,24 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
sync->sync_camera(b_render, b_camera_override, width, height, "");
sync->sync_data(
b_render, b_depsgraph, b_v3d, b_camera_override, width, height, &python_thread_state);
/* Filtering settings for combined pass. */
if (pass->get_type() == PASS_COMBINED) {
Integrator *integrator = scene->integrator;
integrator->set_use_direct_light((bake_filter & BL::BakeSettings::pass_filter_DIRECT) != 0);
integrator->set_use_indirect_light((bake_filter & BL::BakeSettings::pass_filter_INDIRECT) !=
0);
integrator->set_use_diffuse((bake_filter & BL::BakeSettings::pass_filter_DIFFUSE) != 0);
integrator->set_use_glossy((bake_filter & BL::BakeSettings::pass_filter_GLOSSY) != 0);
integrator->set_use_transmission(
(bake_filter & BL::BakeSettings::pass_filter_TRANSMISSION) != 0);
integrator->set_use_emission((bake_filter & BL::BakeSettings::pass_filter_EMIT) != 0);
}
/* Always use transparent background for baking. */
scene->background->set_transparent(true);
/* Load built-in images from Blender. */
builtin_images_load();
}
@@ -841,7 +871,7 @@ void BlenderSession::get_status(string &status, string &substatus)
session->progress.get_status(status, substatus);
}
void BlenderSession::get_progress(float &progress, double &total_time, double &render_time)
void BlenderSession::get_progress(double &progress, double &total_time, double &render_time)
{
session->progress.get_time(total_time, render_time);
progress = session->progress.get_progress();
@@ -849,10 +879,10 @@ void BlenderSession::get_progress(float &progress, double &total_time, double &r
void BlenderSession::update_bake_progress()
{
float progress = session->progress.get_progress();
double progress = session->progress.get_progress();
if (progress != last_progress) {
b_engine.update_progress(progress);
b_engine.update_progress((float)progress);
last_progress = progress;
}
}
@@ -861,7 +891,7 @@ void BlenderSession::update_status_progress()
{
string timestatus, status, substatus;
string scene_status = "";
float progress;
double progress;
double total_time, remaining_time = 0, render_time;
float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;
@@ -905,7 +935,7 @@ void BlenderSession::update_status_progress()
last_status_time = current_time;
}
if (progress != last_progress) {
b_engine.update_progress(progress);
b_engine.update_progress((float)progress);
last_progress = progress;
}

View File

@@ -82,7 +82,7 @@ class BlenderSession {
void tag_redraw();
void tag_update();
void get_status(string &status, string &substatus);
void get_progress(float &progress, double &total_time, double &render_time);
void get_progress(double &progress, double &total_time, double &render_time);
void test_cancel();
void update_status_progress();
void update_bake_progress();
@@ -108,7 +108,7 @@ class BlenderSession {
string last_status;
string last_error;
float last_progress;
double last_progress;
double last_status_time;
int width, height;

View File

@@ -378,10 +378,19 @@ static ShaderNode *add_node(Scene *scene,
}
else if (b_node.is_a(&RNA_ShaderNodeMapRange)) {
BL::ShaderNodeMapRange b_map_range_node(b_node);
MapRangeNode *map_range_node = graph->create_node<MapRangeNode>();
map_range_node->set_clamp(b_map_range_node.clamp());
map_range_node->set_range_type((NodeMapRangeType)b_map_range_node.interpolation_type());
node = map_range_node;
if (b_map_range_node.data_type() == BL::ShaderNodeMapRange::data_type_FLOAT_VECTOR) {
VectorMapRangeNode *vector_map_range_node = graph->create_node<VectorMapRangeNode>();
vector_map_range_node->set_use_clamp(b_map_range_node.clamp());
vector_map_range_node->set_range_type(
(NodeMapRangeType)b_map_range_node.interpolation_type());
node = vector_map_range_node;
}
else {
MapRangeNode *map_range_node = graph->create_node<MapRangeNode>();
map_range_node->set_clamp(b_map_range_node.clamp());
map_range_node->set_range_type((NodeMapRangeType)b_map_range_node.interpolation_type());
node = map_range_node;
}
}
else if (b_node.is_a(&RNA_ShaderNodeClamp)) {
BL::ShaderNodeClamp b_clamp_node(b_node);
@@ -680,6 +689,9 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeHairInfo)) {
node = graph->create_node<HairInfoNode>();
}
else if (b_node.is_a(&RNA_ShaderNodePointInfo)) {
node = graph->create_node<PointInfoNode>();
}
else if (b_node.is_a(&RNA_ShaderNodeVolumeInfo)) {
node = graph->create_node<VolumeInfoNode>();
}
@@ -762,11 +774,12 @@ static ShaderNode *add_node(Scene *scene,
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame);
image->handle = scene->image_manager->add_image(
new BlenderImageLoader(b_image, image_frame), image->image_params());
new BlenderImageLoader(b_image, image_frame, b_engine.is_preview()),
image->image_params());
}
else {
ustring filename = ustring(
image_user_file_path(b_image_user, b_image, b_scene.frame_current(), true));
image_user_file_path(b_image_user, b_image, b_scene.frame_current()));
image->set_filename(filename);
}
}
@@ -797,12 +810,13 @@ static ShaderNode *add_node(Scene *scene,
if (is_builtin) {
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame);
env->handle = scene->image_manager->add_image(new BlenderImageLoader(b_image, image_frame),
env->image_params());
env->handle = scene->image_manager->add_image(
new BlenderImageLoader(b_image, image_frame, b_engine.is_preview()),
env->image_params());
}
else {
env->set_filename(
ustring(image_user_file_path(b_image_user, b_image, b_scene.frame_current(), false)));
ustring(image_user_file_path(b_image_user, b_image, b_scene.frame_current())));
}
}
node = env;

View File

@@ -95,6 +95,11 @@ void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene)
this->b_scene = b_scene;
}
void BlenderSync::tag_update()
{
has_updates_ = true;
}
/* Sync */
void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
@@ -365,8 +370,8 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
int samples = get_int(cscene, "samples");
float scrambling_distance = get_float(cscene, "scrambling_distance");
bool adaptive_scrambling_distance = get_boolean(cscene, "adaptive_scrambling_distance");
if (adaptive_scrambling_distance) {
bool auto_scrambling_distance = get_boolean(cscene, "auto_scrambling_distance");
if (auto_scrambling_distance) {
scrambling_distance *= 4.0f / sqrtf(samples);
}
@@ -392,6 +397,12 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
integrator->set_ao_bounces(0);
}
#ifdef WITH_CYCLES_DEBUG
DirectLightSamplingType direct_light_sampling_type = (DirectLightSamplingType)get_enum(
cscene, "direct_light_sampling_type", DIRECT_LIGHT_SAMPLING_NUM, DIRECT_LIGHT_SAMPLING_MIS);
integrator->set_direct_light_sampling_type(direct_light_sampling_type);
#endif
const DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
integrator->set_use_denoise(denoise_params.use);
@@ -776,6 +787,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
params.bvh_type = BVH_TYPE_DYNAMIC;
params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
params.use_bvh_compact_structure = RNA_boolean_get(&cscene, "debug_use_compact_bvh");
params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
params.num_bvh_time_steps = RNA_int_get(&cscene, "debug_bvh_time_steps");
@@ -821,6 +833,14 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
SessionParams params;
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
if (background && !b_engine.is_preview()) {
/* Viewport and preview renders do not require temp directory and do request session
* parameters more often than the background render.
* Optimize RNA-C++ usage and memory allocation a bit by saving string access which we know is
* not needed for viewport render. */
params.temp_dir = b_engine.temporary_directory();
}
/* feature set */
params.experimental = (get_enum(cscene, "feature_set") != 0);
@@ -835,18 +855,25 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
/* samples */
int samples = get_int(cscene, "samples");
int preview_samples = get_int(cscene, "preview_samples");
int sample_offset = get_int(cscene, "sample_offset");
if (background) {
params.samples = samples;
params.sample_offset = sample_offset;
}
else {
params.samples = preview_samples;
if (params.samples == 0)
if (params.samples == 0) {
params.samples = INT_MAX;
}
params.sample_offset = 0;
}
/* Clamp sample offset. */
params.sample_offset = clamp(params.sample_offset, 0, Integrator::MAX_SAMPLES);
/* Clamp samples. */
params.samples = min(params.samples, Integrator::MAX_SAMPLES);
params.samples = clamp(params.samples, 0, Integrator::MAX_SAMPLES - params.sample_offset);
/* Viewport Performance */
params.pixel_size = b_engine.get_preview_pixel_size(b_scene);
@@ -865,7 +892,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
/* Time limit. */
if (background) {
params.time_limit = get_float(cscene, "time_limit");
params.time_limit = (double)get_float(cscene, "time_limit");
}
else {
/* For the viewport it kind of makes more sense to think in terms of the noise floor, which is

View File

@@ -66,6 +66,8 @@ class BlenderSync {
void reset(BL::BlendData &b_data, BL::Scene &b_scene);
void tag_update();
/* sync */
void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d);
void sync_data(BL::RenderSettings &b_render,
@@ -103,11 +105,11 @@ class BlenderSync {
static BufferParams get_buffer_params(
BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height);
private:
static DenoiseParams get_denoise_params(BL::Scene &b_scene,
BL::ViewLayer &b_view_layer,
bool background);
private:
/* sync */
void sync_lights(BL::Depsgraph &b_depsgraph, bool update_all);
void sync_materials(BL::Depsgraph &b_depsgraph, bool update_all);
@@ -167,12 +169,16 @@ class BlenderSync {
Hair *hair, BL::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, int motion_step = 0);
bool object_has_particle_hair(BL::Object b_ob);
/* Point Cloud */
void sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info);
void sync_pointcloud_motion(PointCloud *pointcloud, BObjectInfo &b_ob_info, int motion_step = 0);
/* Camera */
void sync_camera_motion(
BL::RenderSettings &b_render, BL::Object &b_ob, int width, int height, float motion_time);
/* Geometry */
Geometry *sync_geometry(BL::Depsgraph &b_depsgrpah,
Geometry *sync_geometry(BL::Depsgraph &b_depsgraph,
BObjectInfo &b_ob_info,
bool object_updated,
bool use_particle_hair,
@@ -267,7 +273,6 @@ class BlenderSync {
Progress &progress;
protected:
/* Indicates that `sync_recalc()` detected changes in the scene.
* If this flag is false then the data is considered to be up-to-date and will not be
* synchronized at all. */

View File

@@ -18,6 +18,7 @@
#define __BLENDER_UTIL_H__
#include "scene/mesh.h"
#include "scene/scene.h"
#include "util/algorithm.h"
#include "util/array.h"
@@ -33,7 +34,7 @@
extern "C" {
void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra);
void BKE_image_user_file_path(void *iuser, void *ima, char *path);
void BKE_image_user_file_path_ex(void *iuser, void *ima, char *path, bool resolve_udim);
unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame, int tile);
float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile);
}
@@ -290,25 +291,14 @@ static inline int render_resolution_y(BL::RenderSettings &b_render)
return b_render.resolution_y() * b_render.resolution_percentage() / 100;
}
static inline string image_user_file_path(BL::ImageUser &iuser,
BL::Image &ima,
int cfra,
bool load_tiled)
static inline string image_user_file_path(BL::ImageUser &iuser, BL::Image &ima, int cfra)
{
char filepath[1024];
iuser.tile(0);
BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra);
BKE_image_user_file_path(iuser.ptr.data, ima.ptr.data, filepath);
BKE_image_user_file_path_ex(iuser.ptr.data, ima.ptr.data, filepath, false);
string filepath_str = string(filepath);
if (load_tiled && ima.source() == BL::Image::source_TILED) {
string udim;
if (ima.tiles.length() > 0) {
udim = to_string(ima.tiles[0].number());
}
string_replace(filepath_str, udim, "<UDIM>");
}
return filepath_str;
return string(filepath);
}
static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra)
@@ -647,7 +637,7 @@ static inline Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob,
{
PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles");
if (cobj.data && b_ob.modifiers.length() > 0 && experimental) {
if (cobj.data && !b_ob.modifiers.empty() && experimental) {
BL::Modifier mod = b_ob.modifiers[b_ob.modifiers.length() - 1];
bool enabled = preview ? mod.show_viewport() : mod.show_render();
@@ -681,6 +671,40 @@ static inline uint object_ray_visibility(BL::Object &b_ob)
return flag;
}
/* Check whether some of "built-in" motion-related attributes are needed to be exported (includes
* things like velocity from cache modifier, fluid simulation).
*
* NOTE: This code is run prior to object motion blur initialization. so can not access properties
* set by `sync_object_motion_init()`. */
static inline bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene)
{
const Scene::MotionType need_motion = scene->need_motion();
if (need_motion == Scene::MOTION_NONE) {
/* Simple case: neither motion pass nor motion blur is needed, no need in the motion related
* attributes. */
return false;
}
if (need_motion == Scene::MOTION_BLUR) {
/* A bit tricky and implicit case:
* - Motion blur is enabled in the scene, which implies specific number of time steps for
* objects.
* - If the object has motion blur disabled on it, it will have 0 time steps.
* - Motion attribute expects non-zero time steps.
*
* Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */
PointerRNA cobject = RNA_pointer_get(&b_ob_info.real_object.ptr, "cycles");
const bool use_motion = get_boolean(cobject, "use_motion_blur");
if (!use_motion) {
return false;
}
}
/* Motion pass which implies 3 motion steps, or motion blur which is not disabled on object
* level. */
return true;
}
class EdgeMap {
public:
EdgeMap()

View File

@@ -33,6 +33,17 @@ set(SRC
unaligned.cpp
)
set(SRC_METAL
metal.mm
)
if(WITH_CYCLES_DEVICE_METAL)
list(APPEND SRC
${SRC_METAL}
)
add_definitions(-DWITH_METAL)
endif()
set(SRC_HEADERS
bvh.h
bvh2.h
@@ -46,6 +57,7 @@ set(SRC_HEADERS
sort.h
split.h
unaligned.h
metal.h
)
set(LIB

View File

@@ -26,6 +26,7 @@
#include "scene/hair.h"
#include "scene/mesh.h"
#include "scene/object.h"
#include "scene/pointcloud.h"
#include "scene/scene.h"
#include "util/algorithm.h"
@@ -113,9 +114,9 @@ void BVHBuild::add_reference_triangles(BoundBox &root,
else {
/* Motion triangles, trace optimized case: we split triangle
* primitives into separate nodes for each of the time steps.
* This way we minimize overlap of neighbor curve primitives.
* This way we minimize overlap of neighbor triangle primitives.
*/
const int num_bvh_steps = params.num_motion_curve_steps * 2 + 1;
const int num_bvh_steps = params.num_motion_triangle_steps * 2 + 1;
const float num_bvh_steps_inv_1 = 1.0f / (num_bvh_steps - 1);
const size_t num_verts = mesh->verts.size();
const size_t num_steps = mesh->motion_steps;
@@ -269,6 +270,101 @@ void BVHBuild::add_reference_curves(BoundBox &root, BoundBox &center, Hair *hair
}
}
void BVHBuild::add_reference_points(BoundBox &root,
BoundBox &center,
PointCloud *pointcloud,
int i)
{
const Attribute *point_attr_mP = NULL;
if (pointcloud->has_motion_blur()) {
point_attr_mP = pointcloud->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
}
const float3 *points_data = &pointcloud->points[0];
const float *radius_data = &pointcloud->radius[0];
const size_t num_points = pointcloud->num_points();
const float3 *motion_data = (point_attr_mP) ? point_attr_mP->data_float3() : NULL;
const size_t num_steps = pointcloud->get_motion_steps();
if (point_attr_mP == NULL) {
/* Really simple logic for static points. */
for (uint j = 0; j < num_points; j++) {
const PointCloud::Point point = pointcloud->get_point(j);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points_data, radius_data, bounds);
if (bounds.valid()) {
references.push_back(BVHReference(bounds, j, i, PRIMITIVE_POINT));
root.grow(bounds);
center.grow(bounds.center2());
}
}
}
else if (params.num_motion_point_steps == 0 || params.use_spatial_split) {
/* Simple case of motion points: single node for the whole
* shutter time. Lowest memory usage but less optimal
* rendering.
*/
/* TODO(sergey): Support motion steps for spatially split BVH. */
for (uint j = 0; j < num_points; j++) {
const PointCloud::Point point = pointcloud->get_point(j);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points_data, radius_data, bounds);
for (size_t step = 0; step < num_steps - 1; step++) {
point.bounds_grow(motion_data + step * num_points, radius_data, bounds);
}
if (bounds.valid()) {
references.push_back(BVHReference(bounds, j, i, PRIMITIVE_MOTION_POINT));
root.grow(bounds);
center.grow(bounds.center2());
}
}
}
else {
/* Motion points, trace optimized case: we split point
* primitives into separate nodes for each of the time steps.
* This way we minimize overlap of neighbor point primitives.
*/
const int num_bvh_steps = params.num_motion_point_steps * 2 + 1;
const float num_bvh_steps_inv_1 = 1.0f / (num_bvh_steps - 1);
for (uint j = 0; j < num_points; j++) {
const PointCloud::Point point = pointcloud->get_point(j);
const size_t num_steps = pointcloud->get_motion_steps();
const float3 *point_steps = point_attr_mP->data_float3();
/* Calculate bounding box of the previous time step.
* Will be reused later to avoid duplicated work on
* calculating BVH time step boundbox.
*/
float4 prev_key = point.motion_key(
points_data, radius_data, point_steps, num_points, num_steps, 0.0f, j);
BoundBox prev_bounds = BoundBox::empty;
point.bounds_grow(prev_key, prev_bounds);
/* Create all primitive time steps, */
for (int bvh_step = 1; bvh_step < num_bvh_steps; ++bvh_step) {
const float curr_time = (float)(bvh_step)*num_bvh_steps_inv_1;
float4 curr_key = point.motion_key(
points_data, radius_data, point_steps, num_points, num_steps, curr_time, j);
BoundBox curr_bounds = BoundBox::empty;
point.bounds_grow(curr_key, curr_bounds);
BoundBox bounds = prev_bounds;
bounds.grow(curr_bounds);
if (bounds.valid()) {
const float prev_time = (float)(bvh_step - 1) * num_bvh_steps_inv_1;
references.push_back(
BVHReference(bounds, j, i, PRIMITIVE_MOTION_POINT, prev_time, curr_time));
root.grow(bounds);
center.grow(bounds.center2());
}
/* Current time boundbox becomes previous one for the
* next time step.
*/
prev_bounds = curr_bounds;
}
}
}
}
void BVHBuild::add_reference_geometry(BoundBox &root,
BoundBox &center,
Geometry *geom,
@@ -282,6 +378,10 @@ void BVHBuild::add_reference_geometry(BoundBox &root,
Hair *hair = static_cast<Hair *>(geom);
add_reference_curves(root, center, hair, object_index);
}
else if (geom->geometry_type == Geometry::POINTCLOUD) {
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
add_reference_points(root, center, pointcloud, object_index);
}
}
void BVHBuild::add_reference_object(BoundBox &root, BoundBox &center, Object *ob, int i)
@@ -311,6 +411,10 @@ static size_t count_primitives(Geometry *geom)
Hair *hair = static_cast<Hair *>(geom);
return count_curve_segments(hair);
}
else if (geom->geometry_type == Geometry::POINTCLOUD) {
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
return pointcloud->num_points();
}
return 0;
}
@@ -328,8 +432,9 @@ void BVHBuild::add_references(BVHRange &root)
if (!ob->get_geometry()->is_instanced()) {
num_alloc_references += count_primitives(ob->get_geometry());
}
else
else {
num_alloc_references++;
}
}
else {
num_alloc_references += count_primitives(ob->get_geometry());
@@ -394,7 +499,7 @@ BVHNode *BVHBuild::run()
spatial_min_overlap = root.bounds().safe_area() * params.spatial_split_alpha;
spatial_free_index = 0;
need_prim_time = params.num_motion_curve_steps > 0 || params.num_motion_triangle_steps > 0;
need_prim_time = params.use_motion_steps();
/* init progress updates */
double build_start_time;
@@ -535,7 +640,8 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange &range,
const vector<BVHReference> &references) const
{
size_t size = range.size();
size_t max_leaf_size = max(params.max_triangle_leaf_size, params.max_curve_leaf_size);
size_t max_leaf_size = max(max(params.max_triangle_leaf_size, params.max_curve_leaf_size),
params.max_point_leaf_size);
if (size > max_leaf_size)
return false;
@@ -544,32 +650,44 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange &range,
size_t num_motion_triangles = 0;
size_t num_curves = 0;
size_t num_motion_curves = 0;
size_t num_points = 0;
size_t num_motion_points = 0;
for (int i = 0; i < size; i++) {
const BVHReference &ref = references[range.start() + i];
if (ref.prim_type() & PRIMITIVE_ALL_CURVE) {
if (ref.prim_type() & PRIMITIVE_ALL_MOTION) {
if (ref.prim_type() & PRIMITIVE_CURVE) {
if (ref.prim_type() & PRIMITIVE_MOTION) {
num_motion_curves++;
}
else {
num_curves++;
}
}
else if (ref.prim_type() & PRIMITIVE_ALL_TRIANGLE) {
if (ref.prim_type() & PRIMITIVE_ALL_MOTION) {
else if (ref.prim_type() & PRIMITIVE_TRIANGLE) {
if (ref.prim_type() & PRIMITIVE_MOTION) {
num_motion_triangles++;
}
else {
num_triangles++;
}
}
else if (ref.prim_type() & PRIMITIVE_POINT) {
if (ref.prim_type() & PRIMITIVE_MOTION) {
num_motion_points++;
}
else {
num_points++;
}
}
}
return (num_triangles <= params.max_triangle_leaf_size) &&
(num_motion_triangles <= params.max_motion_triangle_leaf_size) &&
(num_curves <= params.max_curve_leaf_size) &&
(num_motion_curves <= params.max_motion_curve_leaf_size);
(num_motion_curves <= params.max_motion_curve_leaf_size) &&
(num_points <= params.max_point_leaf_size) &&
(num_motion_points <= params.max_motion_point_leaf_size);
}
/* multithreaded binning builder */
@@ -817,7 +935,7 @@ BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start,
BVHNode *BVHBuild::create_leaf_node(const BVHRange &range, const vector<BVHReference> &references)
{
/* This is a bit overallocating here (considering leaf size into account),
/* This is a bit over-allocating here (considering leaf size into account),
* but chunk-based re-allocation in vector makes it difficult to use small
* size of stack storage here. Some tweaks are possible tho.
*
@@ -855,7 +973,7 @@ BVHNode *BVHBuild::create_leaf_node(const BVHRange &range, const vector<BVHRefer
for (int i = 0; i < range.size(); i++) {
const BVHReference &ref = references[range.start() + i];
if (ref.prim_index() != -1) {
uint32_t type_index = bitscan((uint32_t)(ref.prim_type() & PRIMITIVE_ALL));
uint32_t type_index = PRIMITIVE_INDEX(ref.prim_type() & PRIMITIVE_ALL);
p_ref[type_index].push_back(ref);
p_type[type_index].push_back(ref.prim_type());
p_index[type_index].push_back(ref.prim_index());

View File

@@ -39,6 +39,7 @@ class Geometry;
class Hair;
class Mesh;
class Object;
class PointCloud;
class Progress;
/* BVH Builder */
@@ -68,6 +69,7 @@ class BVHBuild {
/* Adding references. */
void add_reference_triangles(BoundBox &root, BoundBox &center, Mesh *mesh, int i);
void add_reference_curves(BoundBox &root, BoundBox &center, Hair *hair, int i);
void add_reference_points(BoundBox &root, BoundBox &center, PointCloud *pointcloud, int i);
void add_reference_geometry(BoundBox &root, BoundBox &center, Geometry *geom, int i);
void add_reference_object(BoundBox &root, BoundBox &center, Object *ob, int i);
void add_references(BVHRange &root);

View File

@@ -19,6 +19,7 @@
#include "bvh/bvh2.h"
#include "bvh/embree.h"
#include "bvh/metal.h"
#include "bvh/multi.h"
#include "bvh/optix.h"
@@ -40,8 +41,12 @@ const char *bvh_layout_name(BVHLayout layout)
return "EMBREE";
case BVH_LAYOUT_OPTIX:
return "OPTIX";
case BVH_LAYOUT_METAL:
return "METAL";
case BVH_LAYOUT_MULTI_OPTIX:
case BVH_LAYOUT_MULTI_METAL:
case BVH_LAYOUT_MULTI_OPTIX_EMBREE:
case BVH_LAYOUT_MULTI_METAL_EMBREE:
return "MULTI";
case BVH_LAYOUT_ALL:
return "ALL";
@@ -102,9 +107,18 @@ BVH *BVH::create(const BVHParams &params,
#else
(void)device;
break;
#endif
case BVH_LAYOUT_METAL:
#ifdef WITH_METAL
return bvh_metal_create(params, geometry, objects, device);
#else
(void)device;
break;
#endif
case BVH_LAYOUT_MULTI_OPTIX:
case BVH_LAYOUT_MULTI_METAL:
case BVH_LAYOUT_MULTI_OPTIX_EMBREE:
case BVH_LAYOUT_MULTI_METAL_EMBREE:
return new BVHMulti(params, geometry, objects);
case BVH_LAYOUT_NONE:
case BVH_LAYOUT_ALL:

View File

@@ -20,6 +20,7 @@
#include "scene/hair.h"
#include "scene/mesh.h"
#include "scene/object.h"
#include "scene/pointcloud.h"
#include "bvh/build.h"
#include "bvh/node.h"
@@ -386,7 +387,7 @@ void BVH2::refit_primitives(int start, int end, BoundBox &bbox, uint &visibility
}
else {
/* Primitives. */
if (pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) {
if (pack.prim_type[prim] & PRIMITIVE_CURVE) {
/* Curves. */
const Hair *hair = static_cast<const Hair *>(ob->get_geometry());
int prim_offset = (params.top_level) ? hair->prim_offset : 0;
@@ -409,6 +410,30 @@ void BVH2::refit_primitives(int start, int end, BoundBox &bbox, uint &visibility
}
}
}
else if (pack.prim_type[prim] & PRIMITIVE_POINT) {
/* Points. */
const PointCloud *pointcloud = static_cast<const PointCloud *>(ob->get_geometry());
int prim_offset = (params.top_level) ? pointcloud->prim_offset : 0;
const float3 *points = &pointcloud->points[0];
const float *radius = &pointcloud->radius[0];
PointCloud::Point point = pointcloud->get_point(pidx - prim_offset);
point.bounds_grow(points, radius, bbox);
/* Motion points. */
if (pointcloud->get_use_motion_blur()) {
Attribute *attr = pointcloud->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if (attr) {
size_t pointcloud_size = pointcloud->points.size();
size_t steps = pointcloud->get_motion_steps() - 1;
float3 *point_steps = attr->data_float3();
for (size_t i = 0; i < steps; i++)
point.bounds_grow(point_steps + i * pointcloud_size, radius, bbox);
}
}
}
else {
/* Triangles. */
const Mesh *mesh = static_cast<const Mesh *>(ob->get_geometry());
@@ -505,7 +530,8 @@ void BVH2::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
pack.leaf_nodes.resize(leaf_nodes_size);
pack.object_node.resize(objects.size());
if (params.num_motion_curve_steps > 0 || params.num_motion_triangle_steps > 0) {
if (params.num_motion_curve_steps > 0 || params.num_motion_triangle_steps > 0 ||
params.num_motion_point_steps > 0) {
pack.prim_time.resize(prim_index_size);
}
@@ -564,13 +590,7 @@ void BVH2::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
float2 *bvh_prim_time = bvh->pack.prim_time.size() ? &bvh->pack.prim_time[0] : NULL;
for (size_t i = 0; i < bvh_prim_index_size; i++) {
if (bvh->pack.prim_type[i] & PRIMITIVE_ALL_CURVE) {
pack_prim_index[pack_prim_index_offset] = bvh_prim_index[i] + geom_prim_offset;
}
else {
pack_prim_index[pack_prim_index_offset] = bvh_prim_index[i] + geom_prim_offset;
}
pack_prim_index[pack_prim_index_offset] = bvh_prim_index[i] + geom_prim_offset;
pack_prim_type[pack_prim_index_offset] = bvh_prim_type[i];
pack_prim_visibility[pack_prim_index_offset] = bvh_prim_visibility[i];
pack_prim_object[pack_prim_index_offset] = 0; // unused for instances

Some files were not shown because too many files have changed in this diff Show More