Commit Graph

108047 Commits

Author SHA1 Message Date
Jeroen Bakker 5f6033e091 Keyframe: Reduce GPU context switches.
This change reduces the GPU context switches when drawing keyframes.
In the previous situation the keyframe blocks and keyframe keys were
drawn per channel. With this patch first all the keyframe blocks are
drawn for all channels and after that the keyframe keys are collected
for all channels and send to the GPU in a single draw call.
2021-08-13 09:37:38 +02:00
Jeroen Bakker 7b5acc8009 Cleanup: remove unused draw_gpencil_channel.
Code is integrated with draw_scene_channel since 2.80.
2021-08-13 08:34:10 +02:00
Campbell Barton 160d57d33c Docs: tooltip update missing from 3e775a4fc5 2021-08-13 16:01:45 +10:00
Campbell Barton 3e775a4fc5 PyAPI: remove the .py extension requirement for startup registration
This was left over from when these scripts were loaded as modules,
where their names needed to be compatible with Pythons module naming.

Version patch existing files so text with register enabled
without a `.py` extension wont start executing on startup.

Resolves T89532.
2021-08-13 15:51:08 +10:00
Campbell Barton 41e6509818 Mesh: replace saacos with acosf for normal calculation
The clamped version of acos isn't needed as degenerate (nan) coordinates
result in zeroed vectors which don't need clamping.
2021-08-13 15:39:39 +10:00
Campbell Barton 8fa05efe0a Docs: note that normalize_v# functions zero out input containing nan 2021-08-13 15:15:54 +10:00
Campbell Barton 92f4abc37f Cleanup: remove unused BKE_mesh_calc_normals_mapping functions
This supported calculating normals for MPoly array which was copied to
an MFace aligned array.

Remove the functions entirely since MFace use is being phased out and
these function isn't used anywhere.
2021-08-13 14:41:42 +10:00
Campbell Barton b51a473e29 Cleanup: remove use of BKE_mesh_calc_normals_mapping_simple
Use BKE_mesh_calc_normals instead of
BKE_mesh_calc_normals_mapping_simple for curve modifier calculation.

This only made sense for derived-mesh which is no longer used.
2021-08-13 14:37:30 +10:00
Campbell Barton ab344775c2 Cleanup: code-comments
Use capitalization, remove unnecessary ellipsis.
2021-08-13 13:55:25 +10:00
Campbell Barton ed38d0c25d Cleanup: split BKE_mesh_calc_normals_poly function in two
Remove the 'only_face_normals' argument.

- BKE_mesh_calc_normals_poly for polygon normals.
- BKE_mesh_calc_normals_poly_and_vertex for poly and vertex normals.

Order arguments logically:

- Pair array and length arguments.
- Position normal array arguments (to be filled) last.
2021-08-13 13:33:03 +10:00
Campbell Barton 399b6ec76c Mesh: optimize normal calculation
Optimize mesh normal calculation.

- Remove the intermediate `lnors_weighted` array, accumulate directly
  into the normal array using a spin-lock for thread safety.
- Remove single threaded iteration over loops
  (normal calculation is now fully multi-threaded).
- Remove stack array (alloca) for pre-calculating edge-directions.

Summary of Performance Characteristics:

- The largest gains are for single high poly meshes, with isolated
  normal-calculation benchmarks of meshes over ~1.5 million showing
  2x+ speedup, ~25 million polygons are ~2.85x faster.

- Single lower poly meshes (250k polys) can be ~2x slower.

  Since these meshes aren't normally a bottleneck,
  and this problem isn't noticeable on large scenes,
  we considered the performance trade-off reasonable.

- The performance difference reduces with larger scenes,
  tests with production files from "Sprite Fight" showing
  the same or slightly better overall performance.

NOTE: tested on a AMD Ryzen TR 3970X 32-Core.

For more details & benchmarking scripts, see the patch description.

Reviewed By: mont29

Ref D11993
2021-08-13 10:21:30 +10:00
Hans Goudey 1275ce61b1 Cleanup: Remove unused includes
I noticed this file was recompiling when adding a node.
2021-08-12 14:12:14 -05:00
Jacques Lucke e0fd5fef12 Geometry Nodes: tag normals dirty after join
Under some circumstances the normals were not tagged dirty
even though they are.
2021-08-12 17:36:53 +02:00
Campbell Barton f801d40daf Fix T89241: 3D Text "Scale to Fit" wraps onto the second line
Disable wrapping when "scale to fit" is used, assert the error is
small so an invalid scale-to-fit value wont go by unnoticed.
2021-08-13 01:07:30 +10:00
Philipp Oeser 3930b8c69e Fix NLA action cannot be unlinked in certain cases
The poll for unlinking calls `nla_panel_context` without providing an
adt pointer, and there is a check for this pointer in
`nla_panel_context` leading to never returning true if it is not
provided. (this is fine if there are tracks already, poll would succeed
in this case, `nla_panel_context` goes a different code path then)

Same call to `nla_panel_context` is also done in the beginning of the
corresponding unlink exec function (but this time providing the pointer
because it is used later), so it makes sense to do the same thing in the
poll function. Equal check is also done in the panel poll function, so
now these are all in sync.

Part of T87681.

Maniphest Tasks: T87681

Differential Revision: https://developer.blender.org/D11041
2021-08-12 16:46:28 +02:00
Philipp Oeser 333c3c92ab Fix T89805: NLA crash without active track
Was reported for a file which does not have an active track set in
AnimData even though it was in strip twek mode (but this was accessed in
is_nlatrack_evaluatable()).

Root cause for this is not totally clear, but I assume the situation is
described as part T87681 (and is fixed in D11052).

This patch here just prevents the crash for files that are already in the
borked state.

Reviewers: sybren

Maniphest Tasks: T89805

Differential Revision: https://developer.blender.org/D12085
2021-08-12 16:41:49 +02:00
Philipp Oeser dc8844f8ef Fix T88498: 'Clear Parent' does not clear parent_bone
Clearing the parent from the UI using the X (or from python) clears the
`parsubstr` and set `partype` back to `PAROBJECT`.

Using the Clear Parent operator would leave the `parsubstr` (and thus
`parent_bone`) untouched even though this operator claims to "clear
parenting relationship completely" (it also removes parent deform
modifiers for example).

So now, also clear `parsubstr` and set back to `PAROBJECT` [which is
default].

Maniphest Tasks: T88498

Differential Revision: https://developer.blender.org/D11503
2021-08-12 16:33:20 +02:00
Henrik Dick d6891d9bee Add Extras Dropdown Menu to Constraints
Add Apply Constraint, Duplicate Constraint, and Copy To Selected
operators, and include them in a menu similar to the menu for modifiers.
The shortcuts in the extras menu are also matched to modifiers.

All the here added operators are intended to work exactly like the
analogous ones for modifiers. That means the apply operator should apply
a constraint as if it was first in the list, just like modifiers do. I
have added the same warning message as for modifiers when that happens.

The decision to use this approach of appling the constraint as if it was
first, was made for consistency with modifiers. People are already used
to how it works there. Is also provides more intricate control over the
applied transforms, then just applying all constraints up to that one.
Apply all constraints is already kinda implemented in Bake Animation.

Reviewed By: HooglyBoogly, sybren, #user_interface

Differential Revision: https://developer.blender.org/D10914
2021-08-12 14:24:27 +02:00
Germano Cavalcante 215734bc52 Fix T88386: Continuous Grab occasionally jumping on Arm64 MacOS
During the processing of a continuous drag event, other mouse move
events may be in the queue waiting to be processed.

But when a mouse wrapping happens, these waiting mouse move events
become out of date as they report a mouse position prior to wrapping.

The current code ignores these events by comparing their `timestamp` to
the time recorded in the last mouse wrapping.

The bug happens because the computed value in
`mach_absolute_time() * 1e-9` for some reason is incompatible with the
value of `[event timestamp]`.

Since macOS 10.6, we have a new way to get the amount of time the
system has been awake. `[[NSProcessInfo processInfo] systemUptime]`.

Using this updated method fixed the problem.

Differential Revision: https://developer.blender.org/D12202
2021-08-12 08:52:50 -03:00
Campbell Barton 6293cf6131 Fix T90630: Crash loading certain user preferences
Clearing the window was done in wm_file_read_post which was deferred.

This was needed as it left the context in an invalid state
where the window was set but the screen wasn't.

Crashing when setting up keymaps that attempted to access the
scene from the window in the property update function.

Regression in 497bc4d199
2021-08-12 20:43:16 +10:00
Campbell Barton ad2fb92e9c Cleanup: remove redundant variable 2021-08-12 17:42:04 +10:00
Campbell Barton 04ef718226 RNA: include base types in RNA_struct_type_find_property search
Add RNA_struct_type_find_property_no_base for use in the rare situations
when this isn't desired.

Resolves T90617, where sequence strip sub-types weren't detecting
properties that exist in the base "Sequence" types.
2021-08-12 17:14:15 +10:00
Campbell Barton 806bf3f452 datadoc: add newlines to generated source files 2021-08-12 16:23:08 +10:00
Campbell Barton 83603ba26a Cleanup: comments/disabled code
- Remove old comment for editors with weak syntax highlighting.
- Remove disabled code to initialize Blender with a file path.
- Remove file name references to function names since these
  were outdated, modern development environments can look up this info.
2021-08-12 16:15:01 +10:00
Campbell Barton 497bc4d199 Fix T89046: Startup file with Python drivers crashes on load
Resolve order of initialization error reading startup file,
support postponing running wm_file_read_post until Blender
has been initialized.

Deferring updates allows duplicate initialization
to be removed from WM_init.

Reviewed By: mont29

Ref D12184
2021-08-12 14:59:08 +10:00
Campbell Barton 216414c65a Cleanup: use parameters struct for wm_homefile_read
Also add wm_homefile_read_ex which is only needed for the first
execution at startup.
2021-08-12 14:38:58 +10:00
Campbell Barton c741558509 Cleanup: spelling in comments 2021-08-12 14:34:43 +10:00
Campbell Barton 1ef275963d Cleanup: use C++ style comments for disabled code 2021-08-12 14:34:41 +10:00
Campbell Barton 4f61843a7e Cleanup: remove *.orig file from 6a9d7139f7 2021-08-12 14:34:39 +10:00
Ray Molenkamp 45d100208e Makesdna: Fix detecting 32 bit padding issues.
Makesdna fails to detect issues in 32 bit code that can
only be resolved by adding a padding pointer.

We never noticed since we ourselves no longer build for
32 bit, but debian's 32 bit builds got bitten by this

A rather extensive explanation on why this is alignment
requirement is there can be found in this comment:

https://developer.blender.org/D9389#233034

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

Reviewed by: sergey, campbellbarton
2021-08-11 19:20:51 -06:00
Ray Molenkamp 48c8f9fc9a Fix: DNA struct alignment on 32 bit
Some of the dna structs were not properly
aligned for 32 bit builds causing issues
for some of the 32 platforms Debian builds
for.

Reviewed By: sergey, brecht
Differential Revision: https://developer.blender.org/D9389
2021-08-11 16:57:56 -06:00
Harley Acheson cd1bb63159 BLF: Do Not Cache Unused Rendered Glyphs
The loading of a font size or style renders bitmaps of the characters
0-255 and stores them in a cache. But glyphs 128-255 in this cache are
not accessible. What used to be ansi high-bit characters are now multi-
byte UTF-8 sequences.

Therefore this patch reduces the glyph_ascii_table size to 128 and
only caches characters 32-127, the visible portion of ASCII, which
greatly reduces the time to load a font.

See D12189 for more details.

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

Reviewed by Campbell Barton
2021-08-11 13:55:58 -07:00
Jeroen Bakker bb487bc2bc Fix T89984: Improve Icon previews reflective and transmissive materials.
Before this commit rendering material icons the floor will is hidden.
This reduces the readability of reflective/refractive materials.

check patch for additional screenshots and notes.

This patch will switch the floor material that uses ray visibility tricks to render a floor for reflective rays.

Eevee uses screen space reflections that makes this a different problem. There is nothing else drawn in
the scene in screen space so we need a different trick. Using math we convert a reflective ray to UV space
and generate a world that projects a checker pattern to infinity.

As now the floor is in the world it is being reflected via
a cubemap. As the film is transparent the background (including the floor isn't rendered)

In the future when Eevee supports vulkan raytracing we can re-evaluate and perhaps remove this
approximation.

We tried lightprobes but that wasn't able to do the trick.
Using the compositor would lead to more memory usage (render layers and intermediate buffers) and slower performance.
Solution has been validated with Simon

Reviewed By: sybren, Severin

Differential Revision: https://developer.blender.org/D11988
2021-08-11 16:59:57 +02:00
Jeroen Bakker e53afad241 Cleanup: moved keyframe drawing to a draw list.
In preparation to do threaded drawing preparation. There should not be any
functional changes.
2021-08-11 16:47:12 +02:00
Germano Cavalcante c9a9d5332b PyAPI: GPU: Expose builtin shaders
Expose `3D_POLYLINE_SMOOTH_COLOR` and
`3D_POLYLINE_FLAT_COLOR` builtins.

Requested by addon developers.
2021-08-11 11:39:51 -03:00
Pedro A e6bbbd965a Cycles: OSL metadata support for UI labels and checkboxes
To improve the presentation of nodes in the node editor. Recognize the
following metadata from the OSL specification:

* [[ string label = "UI Label" ]]
* [[ string widget = "checkBox" ]]
* [[ string widget = "boolean" ]]

Ref T89741

Differential Revision: https://developer.blender.org/D12074
2021-08-11 16:12:27 +02:00
Brecht Van Lommel 6d24017529 Cleanup: use socket identifier instead of names in Cycles shader export
Will be required when we support setting different names and identifiers
for OSL.

Ref D12074
2021-08-11 16:12:27 +02:00
Bastien Montagne 6a9d7139f7 Cleanup: ID management: remove unused old `BKE_libblock_copy_for_localize` function. 2021-08-11 14:49:56 +02:00
Michael Kowalski bbcb60fb22 Fix T90519: USD Exporter Error
Fixes: `Error: metersPerUnit does not match retrieved type float`
2021-08-11 09:40:27 -03:00
Julian Eisel 62cb5c5c4a Enable Asset Browser by default for poses, rest stays experimental
Idea for 3.0 is to disable all functionality that isn't well polished
and focus on those parts first. Starting with poses.

* Adds a new experimental option "Extended Asset Browser", replacing
  "Asset Browser".
* Unlike the previous option, this isn't enabled by default anymore.
  This didn't work well in practice and caused plenty of confusion.
* "Mark as Asset" and "Clear Asset" are hidden if the option is
  disabled.
* Same for the category selection in the Asset Browser.
* Always show display the "Only Assets" option in the File Browser while
  browing inside .blend files. That way you can hide data-blocks that
  are not pose assets.
* The Asset Library setup UI in the Preferences is always visible now,
  it's needed for pose library access.

Addresses T90181, T90180 and T90300.

Differential Revision: https://developer.blender.org/D12120
2021-08-11 14:32:07 +02:00
Jeroen Bakker 48ba341d15 Cleanup: Keylist Drawing - Split up in multiple functions. 2021-08-11 13:34:11 +02:00
Bastien Montagne 6aae140278 Cleanup: Minor comment update on `LIB_TAG_NEW`. 2021-08-11 11:23:31 +02:00
Campbell Barton f3e26c847b PyAPI: report unreleased ID's with WITH_PYTHON_SAFETY enabled
This would have made T88033 more straightforward to track down.
2021-08-11 17:37:38 +10:00
Campbell Barton cbc671947a Fix T88033: Python reference memory leaks for non main data-blocks
ID data-blocks that could be accessed from Python and weren't freed
using BKE_id_free_ex did not release the Python reference count.

Add BKE_libblock_free_data_py function to clear the Python reference
in this case.

Add asserts to ensure no Python reference is held in situations
when ID's are copied for internal use (not exposed through the RNA API),
to ensure these kinds of leaks don't go by unnoticed again.
2021-08-11 17:10:02 +10:00
Campbell Barton 18fbcaf7b9 Cleanup: rename BKE_collection_{free => free_data}
This function doesn't free the collection, only it's memory.
2021-08-11 16:09:23 +10:00
Henrik Dick 2f39f7f815 Modifier: use high quality normals for vertex offset
Using high quality normals for vertex offset when set
for higher precision offsets.

This was only used for calculating even-offset.

Reviewed By: campbellbarton

Ref D12176
2021-08-11 10:26:49 +10:00
Campbell Barton d480f03952 Cleanup: clang-format 2021-08-11 10:11:12 +10:00
Campbell Barton 55615e2600 Cleanup: trailing space, remove BOM 2021-08-11 10:11:11 +10:00
Germano Cavalcante fcd2d63b64 Fix 'GPU_matrix_unproject_3fv' not working with out-of-bounds points
To solve this, the unproject code was redone in order to simplify and optimize.
2021-08-10 18:06:52 -03:00
Hans Goudey 8652e69d8b Fix T90447: 3D view transform locks do not use driver colors
Caused by rB6942dd9f4900.
2021-08-10 12:33:47 -05:00