1
1

Compare commits

..

512 Commits

Author SHA1 Message Date
206f3352dd fix missing type conversion 2021-06-28 15:46:59 +02:00
dd92220f0b Merge branch 'master' into temp-attribute-processor 2021-06-28 13:32:16 +02:00
7d281a4f7d Functions: improve CPPType
* Reduce code duplication.
* Give methods more standardized names (e.g. `move_to_initialized` -> `move_assign`).
* Support wrapping arbitrary C++ types, even those that e.g. are not copyable.
2021-06-28 13:16:32 +02:00
f7e2559fd6 BLI: improve enum operators
* Use unsigned integer types for bit operations.
* Use 64 bit integer instead of 32 bit.
* Support scoped enumes (aka `enum class`) by adding some more casts.
2021-06-28 13:16:32 +02:00
2dbb492268 Fix T89455: Cycles crash when rendering a Mesh with autosmooth
The crash was caused by a mistake in 5f9677fe0c
where the pointers to the custom data layers would be overwritten with the one
for the first layer, as CustomData_duplicate_referenced_layer is only about the
first layer. customData_duplicate_referenced_layer_index should be used instead
to duplicate the right layer.
2021-06-28 13:12:07 +02:00
1b942ef90c GPU: Refactored +cleanup compilation log parsing.
Old implementation has a single parser of many different
formats. With the introduction of Vulkan this would lead
to another parser in the same function. This patch
separates the log parsing using a visitor pattern so the
log parsing can be configured per GPU backend or even
per driver.

With Vulkan we manage the compiler our self so the parsing
will become more straight forward. The OpenGL part depends
on many factors (OS, Driver) and perhaps even GPU.
2021-06-28 12:23:10 +02:00
dbd4ff4163 GPU: Separate compiler log from shader.
Current compiler log parser is to complex to follow. Moving it to its
own compile unit before refactoring.
2021-06-28 12:23:10 +02:00
c4d56199cc Cleanup: use doxy sections for editcurve_select.c
Signed-off-by: Campbell Barton <ideasman42@gmail.com>
2021-06-28 20:19:47 +10:00
Piotr Makal
98cd0fed36 Fix edit-mesh random select regression in random seed use
Fix regression in 9c20228128
that wasn't using the random seed correctly.
2021-06-28 19:57:46 +10:00
Piotr Makal
1c8c91384c Apply random selection precisely for curves, lattices & objects
This patch is part of: T87228.
Support accurate random selection for:

- CURVE_OT_select_random
- LATTICE_OT_select_random
- OBJECT_OT_select_random

Ref D11685
2021-06-28 19:51:49 +10:00
Piotr Makal
ab31c24322 BLI_rand: support for randomizing bitmaps
Add utility functions:

- BLI_bitmap_randomize
- BLI_rng_shuffle_bitmap

Part of D11685
2021-06-28 19:35:43 +10:00
addb2034a7 Cleanup: Fix const warnings in buttons_context.c 2021-06-28 17:34:15 +08:00
c297769d22 UI: Hide collection tab when scene master collection is active
CollectionLineart does not care about the configurations
in master collection.
Other options are not applicaple for master collection as well.
Hence hiding it.

Reviewed by Dalai Felinto (dfelinto)

Differential Revision: https://developer.blender.org/D11702
2021-06-28 15:51:34 +08:00
bb2648ebf0 Outliner: View Layers filter for View Layer Mode
This option allow users to see the view layer in context to the
others. It is particularly useful to see which view layers have which
collections enabled, and their render settings (holdout, ...).

This option is off by default.

Differential Revision: https://developer.blender.org/D11708
2021-06-28 09:34:44 +02:00
2ff490f9e3 Fix: Crash Requesting GPU_SHADER_GPENCIL_FILL builtin shader.
Shader doesn't have any shader code. Requesting the shader
would crash blender. Solved by removing the enum_value.
2021-06-28 08:55:13 +02:00
b2cd225623 GPU: Testcases for builtin shaders.
Adding compiler test (does it compile?) test for all builtin shaders.
2021-06-28 08:55:13 +02:00
f53bd31690 Cleanup GPU/Draw test cases.
In preparation of supporting vulkan. Draw/GPU tests should use
GPU_TEST or DRAW_TEST macros. These macros will run the test
on available drawing context backends like OpenGL or Vulkan.

As in master there is only an OpenGL backend nothing changed.
2021-06-28 08:55:13 +02:00
e94ec79341 Cleanup: use view3d_navigate prefix for walk/fly operators
Use matching file-name prefix as these operators are closely related.
2021-06-28 16:13:01 +10:00
7beb57f3bd Cleanup: update comments 2021-06-28 16:11:18 +10:00
6f42e69b58 Cleanup: de-duplicate 3D-view depth calculation function 2021-06-28 15:46:16 +10:00
7efc87dcd2 Cleanup: typos in RNA enums 2021-06-28 15:46:16 +10:00
1d8648b13a Cleanup: repeated terms in code comments & error messages 2021-06-28 15:46:08 +10:00
23c4854f45 UI: Cleanup: Phrasing of tooltips in line art modifier
Start the tooltip with a verb instead of a gerund, other small changes
for consistency and readability.
2021-06-27 23:48:46 -05:00
7223a0348f Fix T89330 Exact Boolean fails on a simple model.
The problem was an optimization I put in to triangulate quads.
It was wrong if the quad, after projecting onto a 2d plane, was
not convex. Handling quads the same as other faces fixes the bug.
Unfortunately, this will slow down Exact Boolean when the input has
many quads (the usual case, of course).
Will attempt to fix that with a later change, but for now, this
at least restores correctness.
2021-06-26 17:49:52 -04:00
abc6200331 Cleanup: spelling 2021-06-26 21:50:48 +10:00
46a222afd7 Cleanup: remove redundant/outdated comments 2021-06-26 21:50:48 +10:00
624bce6b4d Cleanup: redundant use of static constant 2021-06-26 21:50:48 +10:00
f1e4903854 Cleanup: full sentences in comments, improve comment formatting 2021-06-26 21:50:48 +10:00
fae5a907d4 GPencil: Duplicate Masks when separate Layer/Strokes
Now, the mask layers are copied and later a cleanup is done in order to verify all mask layer exist in destination object. If the layer mask does not exist, it's removed from the list.

This is related to T89234.
2021-06-26 11:38:37 +02:00
b5542c1ea4 Edit Mesh: optimize common use-cases for partial updates
Skip updating normals & tessellation for contiguous geometry regions
for operations such as translate & uniform scale.

This means when all geometry is selected, no updates are needed
as the relative locations of vertices aren't being modified.

Performance:

As this is skipping a multi-threaded operation,
larger improvements are noticeable on systems with fewer cores.

- ~1.15x to ~1.3x overall gain for 32 cores.
- ~1.7x to ~2.2x overall gain for 1 core (limited using `-t 1` argument).

Details:

- Rotate & non-uniform scale only skip tessellation.

- Proportional editing and axis-mirror have special handling
  ensure geometry is properly grouped before considering
  a face part of a single group that can be skipped.

- Loose vertices always need their normals to be recalculated
  since they're calculated based on the location.

- Non-affine transform operations such as shrink-fatten & bend,
  don't take advantage of this optimization.

- Snap projection also disables the optimization.
2021-06-26 17:07:05 +10:00
c1fe582446 Cleanup: move snap with projection check into a function 2021-06-26 16:57:03 +10:00
a287c8d3c1 BMesh: skip partial updates when there is nothing to do 2021-06-26 16:55:14 +10:00
3826fcf035 Cleanup: RNA warning 2021-06-26 16:53:48 +10:00
5759bbe9f9 Fixes a bug where the instances count in the spreadsheet
editor dataset region always showed 0. This was caused by a conditional
statement that needed a domain to be set, which is not the case for
Instances component type.

Reviewer: Hans Goudey (Hoogly Boogly)

Differential Revision: https://developer.blender.org/D11710
2021-06-25 22:57:47 +02:00
eae7090464 Fixes a warning where dst array size was wrong in the
signiture of BLI_str_format_attribute_domain_size.

Reviewer: Hans Goudey (Hoogly Boogly)

Differential Revision: https://developer.blender.org/D11710
2021-06-25 22:56:50 +02:00
cb548329ea UI: Improved File Browser Preview Image Scaling
This patch enables sample filtering when scaling preview images in File
Browser, improving the result a bit. Reduces blockiness and other
artifacts when enlarging the images.

see D11706 for details and examples.

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

Reviewed by Julian Eisel
2021-06-25 10:37:43 -07:00
9586472b9a Cleanup: Clang format 2021-06-25 12:11:13 -05:00
23042a3fb1 Cycles: add view layer option to disable motion blur, in the Filter panel 2021-06-25 18:47:54 +02:00
f863ef8a34 Cleanup: make format
string.c still needs cleanup, but I will leave to the original
author of the latest chagnes to do it since it needs
some tags to skip formatting.
2021-06-25 18:42:30 +02:00
74450265d0 Fix T87185: value assigned to modal Scale does not work properly
`t->values` does not necessarily represent a final value of the
transformation, as each mode treats this value differently.

So, unfortunately, we cannot have a generic offset solution for modal
transform operations. Offset needs to be handled by each mode.

Note: Currently only, `Move`, `Rotate` and `Resize` support this.
2021-06-25 12:52:27 -03:00
20e68d848e Fix T89430: Realizing NURBS curve instances is broken
The "copy_data" function for nurbs splines was incorrect,
it always set the destination's knots vector as "not dirty,"
even if the source's was.
2021-06-25 08:56:40 -05:00
Mihnea Stoian
5ec6c8d267 Linux: prefer using dedicated GPU when launching Blender
Adds "PrefersNonDefaultGPU" and "X-KDE-RunOnDiscreteGpu" to the .desktop file.
Similar hints for macOS and Windows exist already, to prefer using a dedicated
GPU over a slower integrated GPU.

See: https://gitlab.freedesktop.org/xdg/xdg-specs/-/merge_requests/13

Differential Revision: https://developer.blender.org/D11643
2021-06-25 15:28:19 +02:00
5f9677fe0c Fix T88756: crash when baking with autosmooth
When baking some data, we create a new Mesh with edits and modifiers applied.
However, in some cases (e.g. when there is no modifier), the returned Mesh is
actually referencing the original one and its data layers. When autosmooth is
enabled we also split the Mesh. However, since the new Mesh is referencing the
original one, although `BKE_mesh_split_faces` is creating new vertices and edges,
the reallocation of the custom data layers is preempted because of the
reference, so adding the new vertices and edges overwrites valid data

To fix this we duplicate referenced layers before splitting the faces.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D11703
2021-06-25 14:16:07 +02:00
3558bb8eae LineArt: Filtering feature lines with face mask
User can specify filtering options inside line art modifier,
like inverting selection and including face mark region border.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11307
2021-06-25 18:48:20 +08:00
ae085e301c Spreadsheet: Dataset region for spreadsheet editor
This patch adds a left aligned sidebar to the spreadsheet editor. This
Sidebar can be used to navigate the geometry component types and
attribute domains. It also provides a quick overview of domain sizes.
It replaces the two dropdowns in the regions header.
Next step will be to add the domain cycling shortcut
using the CTRL + mouse wheel.

Reviewer: Dalai Felinto (dfelinto), Julian Eisel (Severin),
Hans Goudey (HooglyBoogly).

Differential Revision: https://developer.blender.org/D11046
2021-06-25 07:57:24 +02:00
841df831e8 LineArt: More type & related chaining improvements
This patch includes: Floating edge type support,
Special chaining option for floating edge,
Chaining option for reducing jagged edges when floating
edges are involved.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11306
2021-06-25 13:15:25 +08:00
3d7021b4ec GHOST/XR: support Wayland via XrGraphicsBindingOpenGLWaylandKHR 2021-06-24 18:40:05 +01:00
b129a0b397 GHOST: remove unused EGL context includes in Win32 and Cocoa 2021-06-24 18:40:05 +01:00
5f27a5fff7 GHOST/EGL: store pointer to GHOST_System for downcast tests 2021-06-24 18:40:05 +01:00
b801db1181 GHOST/Wayland: auto-select highest supported OpenGL version 2021-06-24 18:40:05 +01:00
b5840f9b5b Cleanup: compiler warnings with clang
* Mark either all or no class methods with override
* Don't use zero sized array since it has a different size in C and C++.
  Using a little more memory here is not significant.
* Don't use deprecated mechanism to mark private GSet members in clang
  just like we don't for MSVC, it warns even for simple zero initialization.
2021-06-24 19:35:23 +02:00
Leon Zandman
beb6399ae5 Fix T89129: file dialog displays in-progress Safari downloads as a folder
In-progress Safari download files/packages are now recognized as bundles
and therefore not treated as directories.

Differential Revision: https://developer.blender.org/D11613
2021-06-24 19:05:49 +02:00
Thomas Lachmann
15868b1ff4 Fix wrong default value for RenderEngine.bl_use_image_save
Differential Revision: https://developer.blender.org/D11680
2021-06-24 19:03:07 +02:00
7b524d9b71 Cleanup: move and simplify some draw_cache macros 2021-06-24 10:54:08 -03:00
a13314a03f Fix T89390: crash when join geometry node has only muted inputs 2021-06-24 15:45:43 +02:00
cbdddc5648 Workaround for assert from 27da305a40
This worked for existing scenes but adding new objects was asserting
needs further investigation.
2021-06-24 21:01:48 +10:00
51568030e9 Depsgraph: remove redundant mesh data duplication in edit-mode
This resolves a bottleneck where every update while transforming
copied the entire mesh data-block, which isn't needed as the edit-mesh
is the source of the data being edited.

Testing shows a significant overall speedup when transforming:

- ~1.5x with a subdivided cube 1.5 million vertices.
- ~3.0x with the spring mesh (edit-mode with modifiers disabled,
  duplicated 10x to drop performance).

Reviewed By: sergey

Ref D11337
2021-06-24 20:23:00 +10:00
27da305a40 Depsgraph: support flushing parameters without a full COW update
Avoid computationally expensive copying operations
when only some settings have been modified.

This is done by adding support for updating parameters
without tagging for copy-on-write.

Currently only mesh data blocks are supported,
other data-blocks can be added individually.

This prepares for changing values such as edit-mesh auto-smooth angle
in edit-mode without duplicating all mesh-data.
The benefit will only be seen when the user interface no longer tags
all ID's for copy on write updates.

ID_RECALC_GEOMETRY_ALL_MODES has been added to support situations
where non edit-mode geometry is modified in edit-mode.
While this isn't something user are likely to do,
Python scripts may change the underlying mesh.

Reviewed By: sergey

Ref D11377
2021-06-24 20:23:00 +10:00
67b352f9c5 Fix T87486: Can't open file with modifiers to a grease pencil library override
Very stupid typo in override apply code on GP modifiers (typical
copy/paste mistake from original modifiers code).

@jbakker this should be back-ported to 2.93LTS.
2021-06-24 12:10:38 +02:00
8cdb99d51c Fix linking code after own recent commit.
More stupid mistake in recent enhanced reports for file load code,
rB82c17082ba0e left some read-after-free situations.
2021-06-24 12:10:06 +02:00
3a8347f823 CMake: link bf_blenkernel from bf_depsgraph
Without this tests fail to lknk in D11377. Commit separately as the
depsgraph is using BKE it should link to it.
2021-06-24 19:38:26 +10:00
6570159929 Cleanup: update clang-format so PyObject_HEAD indents properly 2021-06-24 17:12:04 +10:00
1f778dbefc Cleanup: use Blender's code style for doxygen commetns in freestyle 2021-06-24 15:59:34 +10:00
4b9ff3cd42 Cleanup: comment blocks, trailing space in comments 2021-06-24 15:59:34 +10:00
2e99a74df9 Cleanup: use '#if 0' for commented code-block 2021-06-24 15:53:26 +10:00
879b89e967 Cleanup: correct variable name in comments 2021-06-24 15:53:26 +10:00
0469f2392f Cleanup: remove outdated/redundant comments 2021-06-24 15:53:26 +10:00
55bffa82da Cleanup: clang-format, spelling 2021-06-24 15:53:26 +10:00
de6c6501f0 LineArt: Bound box visibility check when loading
This patch enables bound box check when loading geometry
into line art. Works with overscan as well. Will discard
object if its bbox completely lies in one side of the
clipping space frustum.

Reviewed by: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11545
2021-06-24 13:17:29 +08:00
de05e261ec Line Art: Discard out of frame edges.
For scenes that have a lot of edges, this could potentially
save some time generating individual strokes that are outside
camera frustum.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11525
2021-06-24 13:09:25 +08:00
f7fbb518c8 Fix failure when baking actions with Bendy Bones
682a74e090 renamed Bendy Bones properties and replaced existing float
properties with float-vector properties. This updates the property names used
by the action baking operator (`NLA_OT_bake`).
2021-06-24 00:10:11 +02:00
d6212f67a9 Remove window iteration in WM_DISPLAYCHANGE.
Iteration was incorrectly calling the same object. Had it called every
window it would still be unnecessary as WM_DISPLAYCHANGE is sent to all
broadcast receiving windows.
2021-06-23 10:12:21 -07:00
5639dcef62 Fix after merge 2021-06-23 18:54:05 +02:00
ef7fcaf8e6 Voxel Remesher: Make smooth shading output automatic
Previously the smooth shading of the voxel remesher was controlled by a
mesh property. With this change, the output will try to match the
current shading of the object. This only takes into consideration the
shading mode of the first polygon of the model, but it is probably what
most users expect as it works as intended with the shade smooth/flat
object mode options.

Reviewed By: JulienKaspar, JacquesLucke

Differential Revision: https://developer.blender.org/D11626
2021-06-23 18:42:40 +02:00
6e4b9f5836 Fix T89221: Sculpt tools symmetry failing with non symmetrical meshes
SCULPT_nearest_vertex_get expects a distance, not a distance squared.
This should make symmetry work as expected, but it still can fail if the
mesh topology is not completely symmetrical.

Reviewed By: JacquesLucke

Maniphest Tasks: T89221

Differential Revision: https://developer.blender.org/D11642
2021-06-23 18:17:46 +02:00
c9f12b21e2 Compositor: Full frame ID Mask node
Adds full frame implementation to this node operations.
No functional changes.
1.2x faster than tiled fallback.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11638
2021-06-23 17:46:54 +02:00
35db01325f Compositor: Full frame Image node
Adds full frame implementation to Image node operations.
Mostly refactored into buffer utility methods for reuse in other
operations.
No functional changes.
1.8x faster than tiled fallback.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11559
2021-06-23 17:46:53 +02:00
8f4d991594 Cleanup: remove unused parameter 2021-06-23 17:46:53 +02:00
a50a51eef0 Fix T88769: GPencil smooth incorrect behavior in cyclic strokes
When use smooth tool in a cyclic stroke, the smoothing algorithm was not using the adjacent points if these are the end or start of stroke.

Now, the smooth uses the other extreme of the stroke to compute smoothness.
2021-06-23 17:28:01 +02:00
276790cbfa LibOverride: Also override owner collection in Outliner hierarchy override.
This change will ensure at least one 'local' collection can host the new
'local' override of all objects (indirectly) overridden by this
operation, such that no new override of object ends up in master
collection (which can become extremely messy in production files).

In practice, it means often at least one of the linked collection owning
those objects also has to be overridden.

NOTE: This only affect cases where root overridden linked object has
some dependencies outside of its own root linked collection. While this
situation should be avoided, it cannot always be, so we try to support
it as best as we can.
2021-06-23 17:07:35 +02:00
7dd7849ddd Memfile Undo: aslo tag embedded IDs for update.
This is again in the fuzzy area of how embedded IDs are handled
respectively by partial undo code and depsgraph... Should not be
necessary currently, but better be safe and explicit, and also tag
those embeded IDs from re-used owner ID.
2021-06-23 17:00:17 +02:00
7561e3dad0 CMake/win: Fix linker issue with OCIO
In certain CMake configurations it was possible
that OCIO gave linker errors due to it thinking
it was using the shared library rather than the
static library we ship.
2021-06-23 08:45:37 -06:00
354ecc2f1e Fix T89269: Memory corruption during extrusions of overlapping edges
The "extrude" operator with the "use_dissolve_ortho_edges" option assumed
the edges were connected.
2021-06-23 11:37:35 -03:00
157081069d Fix (studio reported) crash on Undo in some cases.
Would crash when adding or removing a collection directly to the master
collection of a scene.

Consequence of change to handle depsgraph-controlled evaluation of some
IDs (like excluded collections which do not get evaluated and do not get
a COW anymore). See rBcf4258673755 and D10907.

Note that this mostly demonstrates once again how weak and flacky our
handling of embedded IDs still remains, with some part of the code
handling them as independent IDs, some as fully local/private data, some
as a mix of both... and lots and lots of custom handling code and corner
cases that are a bottomless pit of issues.

Also quiet incredible that this was not reported already, luckily this
original change did not make it to 2.93 release.
2021-06-23 16:16:29 +02:00
befb9d99f8 Fix T89331: Cycles lights flicker when transformed
The check on the transformation introduced in rBb313525c1bd0 to fix
T88515 would sometimes prevent to update the light if the Blender object
changed. To fix this, reverse the order in which the checks happen so
that we do not shortcuit the object change check.
2021-06-23 16:07:06 +02:00
b964f73e7d Readfile: use CLOG instead of printf's.
Note that this commit uses a second LogRef (`blo.readfile.undo`) for undo
specific meassages. Allows to use `--log "*undo*"` cli option to match
all undo reporting.

Also did some minor tweaks to some reports on the way.
2021-06-23 14:23:54 +02:00
a20e0fd1a5 fix 2021-06-23 14:23:06 +02:00
448710996b Merge branch 'master' into temp-attribute-processor 2021-06-23 14:00:05 +02:00
eed9ac5b6e Fix Scene/MasterCollection handling in BKE_main_collection_sync_remap().
Those were missing proper (explicit) object cache clear, and DEG
tagging.

Note that this was most likely not an common issue in practice (Collection
object cache clearing recursively goes into all parents, so master
collection would only miss it in case they had no child collections at
all, and tagging of those happens almost always at other steps on
remapping). But better to be explicit and consistent here in any case.
2021-06-23 12:15:09 +02:00
e291432f5f Fix T89342: Select mirror with a zero length central edge asserts 2021-06-23 20:07:19 +10:00
635b4db162 Fix T89367: Crash running edit-mesh select_linked_pick from Python 2021-06-23 19:45:48 +10:00
Pratik Borhade
a6f275cad3 Fix T88808: Set Origin missing from Text object in 2.93
Fix T88808.
Caused by {rB5f2c5e5bb8c15bf0d6679351e3482f9c38c00935}

object type for `TEXT object` was missing in following check
that's why `Set Origin` option was lost from object context menu.

Reviewed By: lichtwerk

Maniphest Tasks: T88808

Differential Revision: https://developer.blender.org/D11495
2021-06-23 11:12:13 +02:00
82c17082ba Revert "Revert "Enhanced stats/reports for blendfile reading.""
This reverts commit rB3a48147b8ab92, and fixes the issues with linking
etc.

Change compared to previous buggy commit (rBf8d219dfd4c31) is that
new `BlendFileReadReports` reports are now passed to the lowest level
function generating the `FileData` (`filedata_new()`), which ensures
(and asserts) that all code using it does have a valid non-NULL pointer
to a `BlendFileReadReport` data.

Sorry for the noise, it's always when you think a change is trivial and
do not test it well enough that you end up doing those kind of
mistakes...
2021-06-23 10:37:00 +02:00
3b41749245 initial support for voronoi node
Only 3D in F1 mode with euclidean distance is support right now.
2021-06-23 08:34:54 +02:00
071799d4fc Fix T89265: Crash when tabbing through num inputs
Fix by reverting the part of ec30cf0b74
that assigned `but->editval` in `ui_numedit_begin_set_values`.

Causing access freed memory when using tab to switch
to a numeric input and then leaving the textbox by clicking outside.
This was because `ui_numedit_begin_set_values` shouldn't need to set
`but->editval` and overwrite the pointer.
This would set a pointer that had previously been freed,
causing a `NULL` check to fail later on.

Ref D11679
2021-06-23 14:56:36 +10:00
61b22d27c8 Fix T89249: incorrect mesh validate error with zeroed vertex normals
It's not an error for centered vertices to have a zero normal.
2021-06-23 13:57:23 +10:00
5cc8e7ab53 Cleanup: reformat trailing comments that caused line wrapping 2021-06-23 13:54:12 +10:00
2c916c97ac Cleanup: clang-tidy quiet equals-default, nullptr warnings 2021-06-23 12:04:19 +10:00
0f427f4eb1 Cleanup: suppress clang-tidy warnings 2021-06-23 11:48:08 +10:00
58e58310b7 Cleanup: compiler warning for invalid argument type 2021-06-23 11:44:02 +10:00
a8f37763ca RNA Manual Reference: Update Mapping File 2021-06-22 19:37:45 -04:00
dbc054bb88 Fix T89374: Erasing/cutting in Grease Pencil makes Blender shut down
When cut a stroke of 1 point, the clean up done to avoid keep 1 point strokes removes the memory, but the pointer to the first stroke was not set to NULL. As this pointer is invalid now, any use of this produces a segment fault because the pointer is corrupted..
2021-06-22 23:12:04 +02:00
abb07a38b8 GHOST/XR: fix code format 2021-06-22 22:05:47 +01:00
c88c331384 PyDoc: Update Sphinx and pin dependencies
Sphinx has rather loose dependency requirements which can cause issues if we aren't careful.
As a solution they recommend that you pin sphinx dependency versions
2021-06-22 16:30:07 -04:00
Leon Leno
187e217b5a UI: Fix widget emboss: Also fade on the right side
Currently the emboss is only fading on left side of the widget,
resulting in the emboss extending vertically on the right side
and ending abruptly. This patch fixes this by also fading the
emboss on the right side and making it symmetric.

Differential Revision: https://developer.blender.org/D10810
2021-06-22 15:21:53 -05:00
fa1868ae97 Transform: display units for proportional edit value
This fixes T88346.

The code is also more readable by making a better distinction between
the texts used for Distances, "Proportional Size" and "AutoIK-Len".

And the text used to translate the "Proportional Size" is reused.
2021-06-22 17:17:44 -03:00
c3b641613c Cleanup: deduplicate code and rename variables
This makes it clearer that variables are strings and how they are used
in the Move header code.
2021-06-22 16:51:34 -03:00
0732a9f1b2 GHOST/XR: enable X11-EGL context for OpenXR 2021-06-22 20:00:40 +01:00
87833f8f95 GHOST/EGL: add GHOST_XrGraphicsBindingOpenGL as friend 2021-06-22 20:00:40 +01:00
b35ba22d84 GHOST/EGL: getters for display, config and context 2021-06-22 20:00:40 +01:00
c6e6a9046e GHOST/EGL: ignore unused variables 2021-06-22 20:00:40 +01:00
ee8b284d11 Fix T89327: Cube and ico sphere nodes do not create UVs
It turns out you have to add the UV custom data layer manually before
calling the BMesh primitive operators, even if you pass `calc_uvs=true`.
2021-06-22 13:22:40 -05:00
Leon Zandman
c317f111c1 Cleanup: Spelling Mistakes
This patch fixes many minor spelling mistakes, all in comments or
console output. Mostly contractions like can't, won't, don't, its/it's,
etc.

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

Reviewed by Harley Acheson
2021-06-22 10:54:50 -07:00
2fcd3f0296 Cleanup: Remove extra blank line 2021-06-22 19:52:16 +02:00
1917d0345e Fix T89366: GPencil hide layers above parented layer
The problem was the flag was not reset by layer in the loop.
2021-06-22 19:49:03 +02:00
ebfad93039 Fix T89343: Point cloud instances not transformed when realized
This problem has surprisingly been there for quite a few months.
For point clouds all attributes were handled the same, even "position",
which should be transformed when combining source points into the
destination.
2021-06-22 12:19:34 -05:00
3a48147b8a Revert "Enhanced stats/reports for blendfile reading."
This change crashes library linking operators, related tests and probably more.

This reverts commit f8d219dfd4.

Ref D11583
2021-06-22 19:13:50 +02:00
0b15353baa Geometry Nodes: Join curve attributes when realizing instances
Previously the code assumed that curve instances had no attributes.
This is true when the data came from curve objects, which don't support
attributes currently, but it isn't necessarily true when retrieving curves
from evaluated geometry sets.
2021-06-22 11:35:00 -05:00
f3eecfe386 Cleanup: Refactor spline copying functions
Make the virtual functions protected and simpler, so that the logic is
better contained in the base class's implementation. Also introduce a
`copy_without_attributes` method to be used for realizing instances.
2021-06-22 11:32:50 -05:00
026de343e3 Fix deadlock with shrinkwrap and other modifiers
More code that needs task isolation. Encountered in sprite fright production
file.

Ref D11603
2021-06-22 18:26:58 +02:00
f8d219dfd4 Enhanced stats/reports for blendfile reading.
Add direct user feedback (as a warning report) to user when recursive
resync of overrides was needed.

And some timing (as CLOG logs) about main readfile process steps.

This is essentially adding a new BlendFileReadReport structure that wraps
BKE_reports list, and adds some extra info (some timing, some info about
overrides and (recursive) resync, etc.).
2021-06-22 17:28:19 +02:00
6ff0d59967 Minor cleanup to previous commit introducing BLI_math_time.
Forgot to address latest review comments, sorry for the noise.`:wq
2021-06-22 17:02:45 +02:00
feaf309de7 Add initial BLI_math_time with a 'seconds decompose' function.
Allows to decompose a given amount of seconds into a random set of
days/hours/minutes/seconds/milliseconds values.

Also add matching test.

Differential Revision: https://developer.blender.org/D11581
2021-06-22 17:00:18 +02:00
f4e3b1e573 Fix T89360: Eevee transforms geometry when using "High Quality Normals"
Offset missed in rB44d2479dc36f
2021-06-22 10:14:13 -03:00
e3bdb189a7 Cleanup: split BKE_object_batch_cache_dirty_tag
Create a more specialized function `BKE_object_data_batch_cache_dirty_tag`
2021-06-22 09:06:33 -03:00
ab063db34d Cleanup: deduplicate free code
It is more appropriate that `depths` is freed in `ED_view3d_depths_free`.
2021-06-22 08:25:32 -03:00
3f1111b2a8 Draw: Added testcases for hair refine shaders. 2021-06-22 11:11:31 +02:00
ad9fd47d7b Fix T89347: Edit-mesh make planar faces doesn't update face normals
Invalid face normals were used for tessellation.
2021-06-22 18:32:51 +10:00
01234b430b Fix T89345: Edit-mesh decimate doesn't update face normals
Invalid face normals were used for tessellation.
2021-06-22 18:27:52 +10:00
956c539e59 Fix T89196: Depsgraph use-after-free after scene switching undo
Delay depsgraph visibility update tagging until it is known that
graph relations are up to date, and until it is known that the graph
is actually needed to be evaluated.

Differential Revision: https://developer.blender.org/D11660
2021-06-22 09:52:45 +02:00
d3a792431e Cleanup: Use more clear visibility tag function name
No functional changes. Just makes it clear this is not an immediate
update, and will make an upcoming change more localized.
2021-06-22 09:52:45 +02:00
00944353be cleanup menu 2021-06-22 09:47:28 +02:00
623818f2d5 initial support for noise texture 2021-06-22 09:44:25 +02:00
53ba9f01e2 Fix error in context menu when built without freestyle 2021-06-22 17:19:02 +10:00
1725bfc3cb Cleanup: remove unused menu VIEW3D_MT_edit_mesh_edges_data
8aa17c5b12 missed removing the
menu definition when removing from the UI.
2021-06-22 17:18:28 +10:00
6a3bd04e42 Cleanup: rename playhead in the UI and code
Current convention is not to use this term, use "current frame",
and "timeline frame" in render.c as this is the argument passed in.
2021-06-22 17:03:22 +10:00
8af2c87f7e 3D View: adjust order of planes for occlusion check
Move far plane last since it's the least likely to intersect edges.
2021-06-22 15:59:15 +10:00
cd39e3dec1 OptiX: select BVH build options from Scene params
Currently, the OptiX BVH build options are selected based on whether
we are in background mode (final renders) or not (viewport renders).
In background mode, the BVH is built for fast path tracing and low
memory footprint, while in viewport, it is built for fast updates.

However, on platforms without OpenGL support, the background flag is
always set to true and prevents using fast BVH builds in the viewport.

Now, the BVH options derive from the Scene BVH settings:
* if BVH is static, a fast to trace BVH is built
* if BVH is dynamic, a fast to update BVH is built

Reviewed By: #cycles, brecht

Differential Revision: https://developer.blender.org/D11154
2021-06-22 07:38:28 +02:00
338be95874 Fix bone select failing with end-points outside the view
Apply the same fix for T32214 (edge-select failing) to bones
which also failed when their end-points were outside of the view.

- Add V3D_PROJ_TEST_CLIP_CONTENT support for edit & pose bone iterator
  and use for selection operators.
- Remove unnecessarily complicated checks with pose-mode lasso tagging.
- Correct error in pose-mode LassoSelectUserData.is_changed
  (currently harmless as it's not read back).
2021-06-22 14:23:37 +10:00
9ac56bad4c Cleanup: use early return for selection callbacks 2021-06-22 14:23:37 +10:00
67ee87a6e9 Cleanup: spelling 2021-06-22 14:23:37 +10:00
53e1442ac2 Cleanup: comment use C comment-blocks for GHOST_Types.h
Also use full sentences, and correct typos.
2021-06-22 14:23:37 +10:00
e1d6219731 Cleanup: Use "size" instead of "points_len" in spline code
Previously this was mostly consistent, but not completely. It's helpful
to use the same name for the same meaning everywhere in this area.
2021-06-21 23:07:26 -05:00
dc3b7602ee Cleanup: Rename variables, use shorter names
`src` and `dst` are perfectly clear, and avoid repeating unecessary
characters when writing the variables many times, allowing more space
for everything else.
2021-06-21 23:02:00 -05:00
d086570c7a UI: Sequencer: add refresh_all operator to all sequencer view menus
This commit piggybacks on rB3e695a27cdfad560d0b28e742cfa069d098200d6
2021-06-21 22:29:58 -04:00
4947aa29db CMake: Improve python version mismatch error
When CMake detects and incompatible Python version
it errors out with an error saying at-least python 3.9
is required, but doesn't mention the version it detected.

This makes troubleshooting the problem harder than it
needs to be.

This diff changes the error message to include the python
version CMake detected.

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

Reviewed By: Ray Molenkamp
2021-06-21 18:19:07 -06:00
d443dcc733 Build/Windows: Preliminary VS 2022 support.
This adds preliminary VS 2022 support, since
there currently is no CMake version that
supports the VS2022 IDE only ninja support
was tested.

IDE support should work without any additional
changes as soon as an updated CMake becomes
available.

As VS2022 appears to keep binary compatibility
with earlier MSVC versions, the current SVN
libraries will work for this version.
2021-06-21 18:11:30 -06:00
6f158f834d Refactor of Wintab to use Wintab supplied mouse movement once verified against system input.
Reviewed By: brecht, LazyDodo

Maniphest Tasks: T88852

Differential Revision: https://developer.blender.org/D11508
2021-06-21 14:38:51 -07:00
445d506ac9 Geometry Nodes: Use multithreading for the curve to mesh node
This commit optimizes the node for the case where it works on many
splines by allowing it to generate mesh data from their combinations
in parallel. By itself, this made the node around twice as fast in my
test file with a result of 20 million vertices, around 600ms instead of
1.2s before.

That isn't actually a very good result; it reveals another bottleneck,
a single threaded loop over all face corners in the mesh normal
calculation code. As a simple change that might improve performance
in some situations, this commit moves normal calculation out of this
node, so at least the work isn't wasted if the mesh is changed later
on in the node tree anyway.
2021-06-21 16:17:02 -05:00
Germano Cavalcante
b11a463e4f Refactor: Do not keep a copy of depth buffer in RegionView3D
The depth cache (located in `RegionView3D::depths`) is used for quick
and simple occlusion testing in:
- particle selection,
- "Draw Curve" operator and
- "Interactive Light Track to Cursor" operator,

However, keeping a texture buffer in cache is not a recommended practice.

For displays with high resolution like 8k this represents something
around 132MB.

Also, currently, each call to `ED_view3d_depth_override` invalidates
the depth cache. So that depth is never reused in multiple calls from
an operator (this was not the case in blender 2.79).

This commit allows to create a depth cache and release it in the same
operator. Thus, the buffer is kept in cache for a short time, freeing
up space.

No functional changes.
2021-06-21 16:41:50 -03:00
b665ad8621 Fix T89291: Objects with rotation deltas don't rotate in correct axes
Quaternion correction was not implemented and Euler values were being
incorrectly combined.
2021-06-21 14:31:45 -03:00
41af27c582 Fix deadlocks in mesh modifier evaluation and particles
The recent task isolation changes missed two mutex locks that also need task
isolation.

Ref D11603, T89194
2021-06-21 19:25:12 +02:00
47473bee34 GPencil: Disable Lights when duplicate layer
Missing to disable default light ON when use separate operator.
2021-06-21 16:59:20 +02:00
b9ccfb89ce Performance: Flush selection to edges/faces.
This patch uses threading to flush selection from verts to edges and
from edges to faces. The solution is lockless and should scale well on
modern CPU architectures.

Master:{F10185359}
Patch:{F10185361}

End user performance went from 3.9 to 4.6 FPS (Stanford Dragon) but that
was measured on a Intel Core i7-6700 CPU and AMD RX480 Gpu. The more
cores the better improvements you get.

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D11644
2021-06-21 16:35:28 +02:00
ce64cfd6ed Fix T89306: GPencil selection doesn't work correctly with modifiers
The problem was introduced with Bezier modification because the selection code was using the original stroke and not the evaluated version.
2021-06-21 16:08:26 +02:00
3cf39c09bf Cleanup: improve naming in Compositor 2021-06-21 13:51:51 +02:00
4246898ad3 Cleanup: move function parameter to member
Get current pass only when needed.
2021-06-21 13:51:51 +02:00
2851602052 Add a reason for why an Addon can not be loaded. This change gives a more detailed explanation of the issue and may help the Addon Developer to identify what exactly needs to be changed.
The current message 'addon not loaded' is a bit too sparse.

Differential Revision: https://developer.blender.org/D11655
2021-06-21 12:51:46 +02:00
4968a0bdf9 Fix T89122: crash when multi input is connected to multiple group inputs
The early `return` was wrong when there are multiple origin sockets
that need to be loaded.
2021-06-21 12:15:32 +02:00
Daniel Salazar
f383cad329 Fix T89329: icosphere subdivisions can be set to 0
Differential Revision: https://developer.blender.org/D11658
2021-06-21 11:11:11 +02:00
002d563bbb Cleanup: use doxy sections in view3d iterators 2021-06-21 18:17:02 +10:00
4d91808710 Cleanup: variable naming in view3d_iterators
Consistently use a/b instead of 0/1.
2021-06-21 18:01:12 +10:00
4044c29069 Fix T32214: Wireframe edge select fails with verts behind the view
This resolves a long standing bug in edge selection
(picking, circle, box & lasso).

Now when one of the edges vertices fails to project into screen space,
the edge is clipped by the viewport to calculate an on-screen location
that can be used instead.

This isn't default as it may be important for the on the screen location
not to be clipped by the viewport.
2021-06-21 17:27:56 +10:00
54d651c344 Cleanup: pass objects as const arguments 2021-06-21 17:25:10 +10:00
19df0e3cfd Cleanup: swap top/bottom args to planes_from_projmat
X & Z were ordered min/max, where as Y was max/min.
2021-06-21 17:25:09 +10:00
b2510b9e20 Fix T89271: Selecting all vertices doesn't select all edges.
Mistake in recent commit {rBea4309925f1d2d2a224bd1dce12269a58ade9b62}.
2021-06-21 07:55:49 +02:00
feb6fd632f Cleanup: Rename spline interpolation functions
The names were slightly longer than they needed to be clear,
and when they are shorter they tend to fit on one line better.
2021-06-20 22:05:57 -05:00
a1c3e45100 Geometry Nodes: Multithread curve resample node
Optimize the node for the case of many splines. In a test file with
14000 splines, the node is 3x faster (72ms to 24ms) on an 8 core CPU.
2021-06-20 21:57:47 -05:00
b45cee1aaf Cleanup: use early return in view3d iterator callbacks 2021-06-21 12:52:08 +10:00
5df6b4004c Docs: improve imbuf.write docstring
The file path wasn't documented as being optional.
2021-06-21 12:25:36 +10:00
5f71b1edd5 Delaunay add support for detecting and removing holes from output.
Adds two new output modes to the CDT api which detect and remove
holes. A hole is a face from which a ray shot to the outside
intersects an even number of constraint edges, except we don't
count constraint edges in the same connected region of faces,
where a region is connected via non-constraint edges.

These modes are useful for filling in outlines meant to represent
text characters and the like.

Original patch was from Erik Abrahamsson, modified by me to work
with the "valid Bmesh" output type too. I also added tests
for the new modes.
2021-06-20 20:57:22 -04:00
80083ac773 Fix T89310: Industry Compatible keymap not working
Caused by improper testing on my part, assuming a helper function
existed in the industry compatible keymap file, and also assuming it
also used the N and T keys for the left and right side-regions.
2021-06-20 18:52:01 -05:00
0cd34967c0 Curves: Multithread Curve to CurveEval conversion
A different data structure / implementation is used for curves in the
node tree currently. Converting from the DNA `Curve` structure to this
wasn't slow, but it's nice to decrease overhead. In a test of 14000
splines with 128000 points, this halves the runtime from about 5ms
to about 2.5ms.
2021-06-20 18:42:02 -05:00
6afafc46f6 Fix: Spreadsheet selection filter crash on non-mesh components
The spreadsheet filter tried to apply the mesh selection filter on non-
mesh geometry components. Add a check for the component type,
and also refactor the function to be more easily readable.
2021-06-20 17:39:18 -05:00
2d75b39b64 Fix T89302: Broken normals after mesh to curve node
The normals were broken because the normal calculation mode wasn't set.
This patch adds a default normal mode so all code creating a spline does
not necessarily have to set it manually. In the future there should be a
way to change this value in the node tree.
2021-06-20 13:07:49 -05:00
eee3529eaf Docs: improve poly_to_tri_count doc-string
It wasn't obvious this can be used for calculating the triangle index
from the polygon and loop index.
2021-06-21 00:05:26 +10:00
859b3ff346 Cleanup: remove contents of endif() in cmake
This convention is no longer used for Blender's CMake files.
2021-06-20 23:59:07 +10:00
bce482f476 Cleanup: use eSpace_Type enum type 2021-06-20 23:59:07 +10:00
d9b1592c88 Cleanup: make BKE_mesh_loops_to_tessdata a static function 2021-06-20 17:21:50 +10:00
3462b4c7ae Docs: add additional notes on tessellation, update comments 2021-06-20 17:18:53 +10:00
2d60c496a2 Mesh: minor optimization to concave quad check for tessellation
Use the face normal (when available) for a faster concave quad test.
2021-06-20 14:39:13 +10:00
513f566b40 Mesh: optimize object mode face tessellation
- Multi-thread BKE_mesh_recalc_looptri.

- Add BKE_mesh_recalc_looptri_with_normals,
  this skips having to calculate normals for ngons.

Exact performance depends on number of faces, size of ngons and
available CPU cores.

For high poly meshes the isolated improvement to BKE_mesh_recalc_looptri
in my tests was between 6.7x .. 25.0x, with the largest gains seen in
meshes containing ngons with many sides.

The overall speedup for high poly meshes containing quads and triangles
is only ~20% although ngon heavy meshes can be much faster.
2021-06-20 14:39:13 +10:00
b5e5fbcfc8 Cleanup: clang-format 2021-06-20 13:12:27 +10:00
3da25dc625 Cleanup: use doxy sections 2021-06-19 19:41:44 +10:00
f3c5a84bb9 Cleanup: clang-tidy 2021-06-19 18:42:57 +10:00
033641aa74 VSE: Remove seq->tmp usage
Remove `seq->tmp` usage from transform code. It was used to tag strips
that need to be "shuffled". Pass these strips in `SeqCollection`
instead.

Reviewed By: sergey, mano-wii

Differential Revision: https://developer.blender.org/D11631
2021-06-19 05:07:00 +02:00
f9aea19d98 Spreadsheet Editor: Row Filters
This patch adds support for filtering rows based on rules and values.
Filters will work for any attribute data source, they are a property
of the spreadsheet rather than of the attribute system. The properties
displayed in the row filter can depend on data type of the currently
visible column with that name. If the name is no longer visible, the
row filter filter is grayed out, but it will remember the value until
a column with its name is visible again.

Note: The comments in `screen.c` combined with tagging the sidebar
for redraw after the main region point to a lack of understanding
or technical debt, that is a point to improve in the future.

**Future Improvements**
* T89272: A search menu for visible columns when adding a new filter.
* T89273: Possibly a "Range" operation.

Differential Revision: https://developer.blender.org/D10959
2021-06-18 16:33:02 -05:00
d52b7dbe26 Fix T89261: Crash when calculating bmesh tessellation
Error passing `false` instead of a `BMeshCalcTessellation_Params` struct.
2021-06-18 15:20:36 -03:00
3e6f2c7a99 Cleanup: Remove dead code
This code was disabled in 2.8 and all other associated code/comments 
have been removed/cleared. These rna properties have been replaced with 
`seq_prev_type`
2021-06-18 13:54:00 -04:00
f7022fc73f Fix Build Warning
Removal of unused local variable. Calculation of underline thickness
no longer needed with change to text output of underscore character.

Introduced in aee04d4960

Differential Revision: https://developer.blender.org/D11641
2021-06-18 09:22:52 -07:00
8a048593ca Fix T89259: GPencil Duplicate point doesn't work for last point
The loop was checking the len of the island, but if the island started in the last point the copy was not executed.
2021-06-18 18:16:38 +02:00
b6030711a2 Armature: add automatic B-Bone Scale toggles.
Currently B-Bone scaling can only be controlled via their
properties, thus requiring up to 8 drivers per joint between
B-Bones to transfer scaling factors from the handle bone.

A Scale Easing option is added to multiply the easing value
by the Y scale channels to synchronize them - this produces a
natural scaling effect where both the shape of the curve and
the scale is affected.

In addition, four toggles are added for each handle, which
multiply each of the X, Y, Z and Ease values by the matching
Local Scale channel of the handle bone, thus replacing trivial
drivers. The Scale Easing option has no effect on this process
since it's easy to just enable both Length and Ease buttons.

Differential Revision: https://developer.blender.org/D9870
2021-06-18 18:56:04 +03:00
638c16f410 Armature: implement lengthwise scaling of B-Bone segments.
Implement actual behavior for the B-Bone Y Scale channels added
to DNA and UI in the previous commit in addition to the existing
X and Z Scale inputs.

The two length scale inputs control the ratio between the lengths
of the start and end segments of the bone: although for convenience
two inputs are provided, the whole chain is still uniformly scaled
to fit the curve.

Differential Revision: https://developer.blender.org/D9870
2021-06-18 18:56:03 +03:00
682a74e090 Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.

First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.

Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.

Finally, the Z channels are confusingly called Y.

This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.

Functionality is not changed, so the new fields are not used
until the following commits.

Differential Revision: https://developer.blender.org/D9870
2021-06-18 18:56:03 +03:00
aee04d4960 Fix T89246: No Mnemonic Underlines in Dialogs
When drawing mnemonic underlines for hotkeys, use text output of
underscore character instead of direct drawing a line. Otherwise these
are not visible in dialog buttons.

Introduced in 0fcc063fd9

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

Reviewed by Campbell Barton
2021-06-18 08:32:07 -07:00
4c19fe4707 UI: Sequencer: Use ampersand instead of slash for "Sequencer/Preview"
Using an ampersand here is more semantically correct. A slash indicates "or" while an ampersand indicates "and".
An ampersand here is best because the view type shows both the Sequencer and the Preview.
2021-06-18 11:13:00 -04:00
4998ceebfc GPencil: Missed flag in previous Copy Settings commit 2021-06-18 16:47:08 +02:00
408726000a GPencil: Move copy layer settings to function
Better to have a function that can be reused to duplicate the settings that need to be copied.
2021-06-18 16:40:44 +02:00
Jeroen Bakker
e0f2f07d1e DrawManager: Multithreaded counting of material buckets.
When having multiple materials in a mesh the triangles are sorted based
on material index. This sorting is done single threaded, but needs two
loops over the data. One to count the bucket size and the second one to
add the triangles to the right position in the buckets.

This patch will do the counting in a multithreaded approach that would
speed up the cache creation. It has been measured that this part is the
most blocking part of the cache creation.

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D11615
2021-06-18 16:10:28 +02:00
Jeroen Bakker
6d73d98fb6 BMesh: use threading to count total selection.
During selections the total selection is refreshed at the end. This
process was done single threaded. This patch will do a parallel iter
approach.

Master: 0.043612s Threaded 0.017964s.

Master: {F10179586}
This patch: {F10179587}

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D11622
2021-06-18 16:06:36 +02:00
03a83b4eb5 Fix T89262: Crash in regular FileBrowser ID listing of 'asset' .blend files.
`ED_fileselect_get_asset_params` would only return actual data pointer
when file browser is in ASSET mode.

Calling that whole section only makes sense if filebrowser is in asset
mode anyway.

Regression introduced in rBf6c5af3d4753 I think.

@Severin committing this fix now as this is a fairly critical bug for
the studio, feel free to revert and do proper fix if this one is not the
best solution.
2021-06-18 15:49:50 +02:00
Jeroen Bakker
ea4309925f Performance: Limit recounting during selection mode flushing.
This patch ensures that selection mode flushing updates total selection
counts internally. This reduces recounting when we are sure that the
input total selection counts were up to date.

For example for circle selection the total selection counts were
correct. But during flushing the selection could have been changed and
therefore the selection was always recounted.

This increased the performance on selected system from 6.90 FPS to 8.25
FPS during circle selection operations.

Before: {F10179981}
After: {F10179982}

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D11647
2021-06-18 15:44:08 +02:00
a9d5c8f97f Fix error passing in false as instead of a struct
Error in 8a1860bd9a.
2021-06-18 23:40:28 +10:00
847b66e81d Fix T88394: crash when editing animated Alembic properties
When an object, whose mesh gets loaded from Alembic, gets animated in
Blender and the Alembic CacheFile datablock also gets animated, editing
keyframes causes both datablock to be re-copied for evaluation. This
caused a threading issue and a double-free of some memory. This is fixed
by expanding the scope of the spin lock in
`BKE_cachefile_reader_free()`.
2021-06-18 13:57:46 +02:00
b8cf8e0bc2 Fix T89240: Crash when moving vertices on a linked duplicate
There is an attempt to free an illegal pointer in `extract_edge_fac_finish`.
2021-06-18 08:25:51 -03:00
80bc819d50 Fluid: Clang-format cleanup
Updated fluid source files in extern with clang-format.
2021-06-18 12:28:17 +02:00
adefdbc9df Fluid: Optimization for FLIP neighbor search radius
Contributed by @erik85 in D11400. The idea from this patch was placed in
a more generic context: A new FOR macro has been added that loops
over the neighbors of a cell within a given radius.
2021-06-18 12:18:21 +02:00
7c68147709 Fix T88605: Alembic import crashes when missing arbGeomParams
Add check for the `arbGeomParams` property being valid, before attempting
to access a sub-property from it.
2021-06-18 11:21:13 +02:00
060d668ae6 Cleanup: clang format 2021-06-18 10:50:19 +02:00
6c1fdd52c1 Fix invalid polygon normal array access building bake data
Pre computed normals index wasn't properly aligned.
Regression from 2ec00ea0c1.
2021-06-18 18:00:47 +10:00
3caafd24a9 Cleanup: use 'bmesh' prefix for BMesh tessellation utilities 2021-06-18 16:37:43 +10:00
c4958bc540 Cleanup: rename test_index_face -> BKE_mesh_mface_index_validate 2021-06-18 15:13:52 +10:00
2e8d7fa7ee Cleanup: remove unused MFace custom-data utilities
Remove:

- BKE_mesh_loops_to_mface_corners
- BKE_mesh_tangent_loops_to_tessdata
2021-06-18 15:08:23 +10:00
253c5d25f7 Cleanup: move mesh tessellation into it's own file
This matches BMesh which also has tessellation in it's own file.

Using a separate file helps with organization when
extracting code into smaller functions.
2021-06-18 15:03:31 +10:00
c290ac2ab1 CMake: remove workaround for version that's no longer supported 2021-06-18 14:41:24 +10:00
af4167441b Cleanup: clang-tidy 2021-06-18 14:41:24 +10:00
50a4b9d502 Cleanup: replace 'unsigned in' with 'uint' 2021-06-18 14:27:41 +10:00
5f0d4fef91 Cleanup: use standard identifier for uint64_t string formatting 2021-06-18 14:27:39 +10:00
68b06208d2 Fix undefs from previous commit 2021-06-17 22:27:09 -03:00
f3c88f8ba5 Fix T89210: Box selection can fail in graphics editor
Test the intersection of segment instead of point.
2021-06-17 22:20:50 -03:00
Fen
e178a273fa Fix T89247: Dereference arguments to comparison function correctly
`bm_face_len_cmp` incorrectly interpreted its arguments as `BMFace *`
instead of `BMFace **`, causing an out-of-bounds read.

Ref D11637
2021-06-18 11:13:09 +10:00
94c4a9995e Fix T89233: Incorrect attribute remove warning for curves
The curve attribute delete function didn't return whether it was
successful or not.
2021-06-17 17:22:09 -05:00
4b673ebb99 Raycast geometry node.
The //Raycast// node intersects rays from one geometry onto another.
It computes hit points on the target mesh and returns normals, distances
and any surface attribute specified by the user.

A ray starts on each point of the input //Geometry//. Rays continue
in the //Ray Direction// until they either hit the //Target Geometry//
or reach the //Ray Length// limit. If the target is hit, the value of the
//Is Hit// attribute in the output mesh will be true. //Hit Position//,
//Hit Normal//, //Hit Distance// and //Hit Index// are the properties of the
target mesh at the intersection point. In addition, a //Target Attribute//
can be specified that is interpolated at the hit point and the result
stored in //Hit Attribute//.

Docs: D11620

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D11619
2021-06-17 21:11:32 +01:00
577d6d3f87 Fix T89234: Gpencil Separate doesn't copy settings in Stroke/Point mode
Some values were not copied from the old layer to the new one as Tint or Opacity factor.

The error affected to Strokes and Point mode
2021-06-17 20:41:53 +02:00
ed4222258e Geometry Nodes: Add Curve Subdivision Node
This node creates splines with more control points in between the
existing control points. The point is to give the splines more
definition for further tweaking like randomization with white noise,
instead of deforming a resampled poly spline with a noise texture.

For poly splines and NURBS, the node simply interpolates new values
between the existing control points. However, for Bezier splines,
the result follows the existing evaluated shape of the curve, changing
the handle positions and handle types to make that possible.

The number of "cuts" can be controlled by an integer input, or an
attribute can be used. Both spline and point domain attributes are
supported, so the number of cuts can vary using the value from the
point at the start of each segment.

Dynamic curve attributes are interpolated to the result with linear
interpolation.

Differential Revision: https://developer.blender.org/D11421
2021-06-17 11:39:23 -05:00
7c1bb239be Geometry Nodes: support minimum twist normal mode
The minimum twist mode is important because it allows creating
normals without sudden changes in direction. The disadvantage
of minimum twist normals is that the normals depend on all control
points. So changing one control point can change the normals
everywhere. The computed normals do not match the existing
code exactly, although they do match quite well on non-cyclic and
on some cyclic curves. I also noticed that the existing implementation
has some fairly simple failure cases that I haven't found in the new
implementation so far.

Differential Revision: https://developer.blender.org/D11621
2021-06-17 15:23:01 +02:00
56db09e2fd Geometry Nodes: fix ownership issue in spline to points conversion
Previously, `VArray_For_SplineToPoint` did not take ownership of the
virtual array leading to use-after-free errors.
2021-06-17 13:40:08 +02:00
1388e9de8a Geometry Nodes: improve node locking in evaluator
This makes the parts where a node is locked more explicit. Also, now the thread
is isolated when the node is locked. This prevents some kinds of deadlocks
(which haven't happened in practice yet).
2021-06-17 10:43:39 +02:00
a971409d5a Cleanup: use doxy sections for rna_mesh.c 2021-06-17 16:44:43 +10:00
ccd5f80550 Cleanup: rename rna_Mesh_update_data to rna_Mesh_update_data_deg_all
It's ambiguous what rna_Mesh_update_data does compared with functions
that use `rna_Mesh_update_data_*` as a prefix.

Noticed by @sybren D11377 review.
2021-06-17 16:38:19 +10:00
8ff6322152 Cleanup: improved comment for skipping updated with zero user meshes
Noticed by @sybren D11377 review.
2021-06-17 16:32:08 +10:00
6db290641e Cleanup: split BKE_mesh_copy_settings into two functions
- BKE_mesh_copy_parameters_for_eval to be used for evaluated meshes only
  as it doesn't handle ID user-counts.

- BKE_mesh_copy_parameters is a general function for copying parameters
  between meshes.
2021-06-17 15:08:19 +10:00
286bd87445 Cleanup: spelling 2021-06-17 14:43:25 +10:00
eb85de027c Cleanup: unused argument, function & shadow variable warning 2021-06-17 14:43:13 +10:00
78693d524c VSE: Refactor transform operator code
Refactor function `freeSeqData` so it is readable.

One strip can have multiple transform operations defined. To prevent
processing strip multiple times, build `SeqCollection` and use
sequencer iterator instead of iterating `TransData` directly.

No functional changes.

Differential Revision: https://developer.blender.org/D11618
2021-06-17 04:04:01 +02:00
e7003bc965 VSE: Reduce transform code complexity
Reduce complexity of sequencer transform code by removing recursivity.
This is possible by treating meta strips (mostly) as any other strip and
containing all transform code within SEQ_ functions.

Unfortunately internally meta strips still require special treatment,
but all complexity from code all over transform code seems to be
possible to contain within one function.

Functional change:
Previously adjusting handle of single image strip moved animation.
Now animation is not moved, which is behavior for all other strips.

Reviewed By: sergey, mano-wii

Differential Revision: https://developer.blender.org/D11493
2021-06-17 03:42:04 +02:00
c73be23e17 Revert "Fix T89204: slow repeated rendering with GPUOffscreen.draw_view3d"
This reverts commit d03b26edbd. There is some
refresh issue that needs to be solved before this can be enabled.
2021-06-17 02:06:26 +02:00
845f4cebad Fix T88342: 'To Sphere' and 'Push/Pull' not working in Pose mode
Some modes don't take into account that `TransData` may be in data space.
2021-06-16 16:47:46 -03:00
d03b26edbd Fix T89204: slow repeated rendering with GPUOffscreen.draw_view3d
Cache the GPUViewport so the framebuffers and associated textures are not
reallocated each time.
2021-06-16 20:19:34 +02:00
a1cc7042a7 Edge-scrolling for node editor
Starts scrolling when dragging a node or node link and going outside the current window.
Largely copied from the VIEW2D_OT_edge_pan operator.

Edge panning operator customdata and supporting functions now in
UI_view2d.h, so they could be used by operators in other editor
libraries. The VIEW2D_OT_edge_pan operator also uses this customdata and
shared functions now. Operators properties can be used to configure
edge panning margins and speed for each use case, rather than using
hardcoded values.

The speed function for edge panning has been tweaked somewhat:
* "Speed per pixel" has been replaced with a "speed ramp" distance.
  This is more intuitive and also creates an upper bound for the speed,
  which can otherwise become extreme with large cursor distance.
* "Max speed" is reached at the end of the speed ramp.
* Padding the region inside and outside is applied as before, but both
  values are operator properties now.

Node transform operator also supports edge panning. This requires
an offset for changes in the view2d rect, otherwise nodes are "stuck"
to the original view.

Transform operator had cursor wrapping categorically enabled, but this
gets quite confusing with the edge scrolling mechanism. A new TransInfo
option T_NO_CURSOR_WRAP has been introduced to disable this behavior.
The double negative is a bit annoying, but want to avoid affecting the
existing transform modes, so by default it should still set the
OP_IS_MODAL_GRAB_CURSOR flag (which then sets the WM_CURSOR_WRAP_XY
flag during modal execution).

Reviewed By: HooglyBoogly, JacquesLucke

Differential Revision: https://developer.blender.org/D11073
2021-06-16 18:35:52 +01:00
247abdbf41 LineArt: Cached calculation for modifiers in the same stack.
This allows line art to run only once for each modifier stacks,
with an option to toggle a specific line art modifier should
use cache or re-do their own calculations.

Reviewed By: Sebastian Parborg (zeddb), Hans Goudey (HooglyBoogly)

Differential Revision: https://developer.blender.org/D11291
2021-06-16 22:38:47 +08:00
b37093de7b BLI: add C++ wrapper for task isolation
This makes it easier to use task isolation in c++ code.
Previously, one either had to check `WITH_TBB` (possibly indirectly
through `WITH_OPENVDB`) or one had to use the C function which
is less convenient.
2021-06-16 16:29:21 +02:00
45d59e0df5 BLI: add threading namespace
This namespace groups threading related functions/classes. This avoids
adding more threading related stuff to the blender namespace. Also it
makes naming a bit easier, e.g. the c++ version of BLI_task_isolate could
become blender::threading::isolate_task or something similar.

Differential Revision: https://developer.blender.org/D11624
2021-06-16 16:14:02 +02:00
0cebe554d1 ShaderFX operators: Tweak a bit poll functions, forbid in liboverride cases.
Similar to what we do for constraints and modifiers, except that
currently adding or editing shaderfx in liboverride objects is
completely unsuported.

Fix T88974.
2021-06-16 16:09:28 +02:00
af3d7123c9 ShaderFX/LibOverride: Add BKE_shaderfx_is_nonlocal_in_liboverride util.
Used to detect if a shaderfx is purely local, or comes from linked data,
in case of a liboverride.

Not actually used yet since we do not currently support adding
shaderfx's to overrides, but will be in the future, and matches
constraints and modifiers code.
2021-06-16 16:09:28 +02:00
3953b82030 Tweaks to Constraints operators poll functions.
Mainly:
* Make `ED_operator_object_active_editable_ex` properly report poll
  messages on failure.
* Add `ED_operator_object_active_local_editable_posemode_exclusive` for
  bone constraints requiring pure local Object (non-override one).
* General cleanup and adding more poll messages on failures.
2021-06-16 16:09:28 +02:00
4b7eae5cd3 Merge branch 'master' into temp-attribute-processor 2021-06-16 15:16:04 +02:00
88aa056d1a Fix: Image node alpha socket converted to operations twice
On selecting a multi-layer image with a combined pass, a "Combined"
socket is created and default combined pass socket "Image" is
disabled by setting `SOCK_UNAVAIL` flag. When converting into
operations, `ImageNode` converts alpha socket on finding any socket with
a combined pass without checking the flag.

Since commit rB93e2491ee724 an assertion fails when mapping sockets
twice because now map `add_new` is used.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11566
2021-06-16 14:04:24 +02:00
b66600b9f3 Compositor: Full frame Value node
Adds full frame implementation to Value node operation.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11594
2021-06-16 14:02:08 +02:00
b406b6717f Compositor: Full frame RGB node
Adds full frame implementation to RGB node operation.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11593
2021-06-16 14:00:05 +02:00
94084b2d3c Geometry Nodes: fix z-up spline normal calculation
Previously it didn't work when the tangents were collinear to the z axis.
2021-06-16 12:20:28 +02:00
00fc110d3f Alembic procedural: support reading per-vertex UV sets
This adds support for importing UV sets which are defined per vertex,
instead of per face corners. Such UV sets can be generated when the
mesh is split according to UV islands, or when there is only one UV
island, in which cases only a single UV value can be stored per
vertex since vertices will never be on a seam.
2021-06-16 09:39:39 +02:00
1c0a490d0e Cleanup: minor simplification to status allocation 2021-06-16 17:17:15 +10:00
c3fa7b7e4f Fix pose-mode statistics with multi-object editing
- Include all objects in pose mode.
- Show the number of objects in pose mode.
- Show the number of objects in edit mode for all types of objects
  (not just meshes).
2021-06-16 17:17:15 +10:00
4b36c5b1a7 Cleanup: sculpt mode checks when calculating stats
Sculpting dynamic topology used to code-path for counting object
then never used the result.

Match object mode checks in string access & drawing.
2021-06-16 17:17:15 +10:00
3385c04598 Alembic: support reading per-vertex UV sets
This adds support for importing UV sets which are defined per vertex,
instead of per face corners. Such UV sets can be generated when the
mesh is split according to UV islands, or when there is only one UV
island, in which cases only a single UV value can be stored per
vertex since vertices will never be on a seam.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D11584
2021-06-16 08:22:10 +02:00
9fed00341e Cleanup: reduce warnings when compiling release builds. 2021-06-16 08:00:52 +02:00
Johnny Matthews
ed4b2ba75a Geometry Nodes: Separate Components Node
Implementation of T86970. This node takes a geometry input with
multiple components and outputs them by component type. Meshes,
Curves, and Point Clouds support combining multiple input instances,
while volumes will only output the first volume component input until
suitable instance realization for multiple volumes is finished.

When direct geometry instancing is implemented it will be possible to
avoid realizing instances in this node.

Differential Revision: https://developer.blender.org/D11577
2021-06-15 22:31:57 -05:00
2209321f78 Screen: simplify internal logic for new full-screen areas
Creating a new full screen area had it's area initialized as empty,
updating the screen then set the area to a 3D view (as a fallback),
before the actual area type was set.

This made setting the intended space-type run the 3D views exit callback
on a 3D view without a View3D struct allocated, which the exit callback
needed to account for.

Resolve by calling ED_screen_change after the area type has been set.
2021-06-16 12:50:00 +10:00
be8a201a16 Cleanup: unused warning 2021-06-16 12:29:44 +10:00
0b0c7ca017 Cleanup: Fix inconsistent parameter name warning 2021-06-15 21:11:18 -05:00
c8e331f450 UI - LOCAL View3D overlay stats
This patch improves the 3DView statistics overlay to show LOCAL stats
while in local view. This means the stats can vary between 3DViews and
the statusbar when views are in local view, but this gives a much more
accurate count of the objects, and their components, that you are
directly working with rather than just scene values.

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

Reviewed by Campbell Barton
2021-06-15 19:01:53 -07:00
4891da8ae2 Fix T88263: Incorrect image offset from old file
Versioning code for converting strip offset property doesn't work, when
property was animated and disabled or when crop was used.

When offset property is animated and offset is enabled, animation is
converted to be used with new transform design. When offset is disabled,
animation is left untouched. New transform design doesn't have option
to disable offset, and therefore old unconverted animation is used
instead of converted static value.

Remove animation from propery if it was unused.

Another issue was that both X and Y offset animation was being corrected
by factor caluclated for X channel.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11370
2021-06-16 00:44:37 +02:00
1a5fa2b319 VSE: Improve animation evaluation performance
Use lookup string callback function for `sequences_all` RNA property
`rna_SequenceEditor_sequences_all_lookup_string` using a GHash for faster lookups.

When names are changed or strips are added/removed the lookup is tagged invalid.
The next time the lookup is used it will rebuild it.

Reviewed By: sergey, jbakker

Differential Revision: https://developer.blender.org/D11544
2021-06-16 00:29:17 +02:00
143a81ccce Geometry Nodes: Allow int attribute input fields with single value
Just like the way we often have a choice between an attribute input and
a single float, this adds the ability to choose between attribute and
integer input sockets, useful for D11421.
2021-06-15 16:38:28 -05:00
c29afa5156 Cleanup: Expose function publicly, rename
There is no particular reason these two functions shouldn't be used
outside of the bezier spline implementation since they don't do anything
particularly controversial.
2021-06-15 16:31:08 -05:00
732e8c723e Splines: Add resize method to CurveEval
This helps when adding splines to a new curve in parallel.
2021-06-15 16:24:11 -05:00
Germano Cavalcante
6bb980b0f4 DRW: sanitize 'DRW_mesh_batch_cache_dirty_tag'
Create maps that specify which batches have vbo or ibo as a reference
and use these maps to discard batches along with buffers.

Differential Revision: https://developer.blender.org/D11588
2021-06-15 17:03:19 -03:00
8e84938dd0 Cleanup: Add files for version independent versioning helpers
Adds `source/blender/blendloader/intern/versioning_common.cc` and
`versioning_common.h` for version independent versioning functions.

I only placed `do_versions_add_region_if_not_found()` in there for now.
`blo_do_version_old_trackto_to_constraints()` could also be added, but
that's so old, I prefer keeping that in `versioning_legacy.c`.
2021-06-15 19:33:00 +02:00
a4f840e15b UI: Support right aligned non-shortcut hints in widgets
Widget drawing code already supported drawing right-aligned, grayed out
shortcut strings. This patch generalizes things a bit so this can also
be used to draw other hints in the same way. There have been a few
instances in the past where this would've been useful, D11046 being the
latest one.

Note that besides some manual regression testing, I didn't check if this
works yet, as there is no code actually using it (other than the
shortcuts). Can be checked as part of further development for D11046.

A possible further improvement would be providing a way to define how
clipping should be done. E.g. sometimes the right-aligned text should be
clipped first (because it's just a hint), in other cases it should be
left untouched (like current code explicitly does it for shortcuts).

Removes the `UI_BUT_HAS_SHORTCUT` flag, which isn't needed anymore.
2021-06-15 19:13:09 +02:00
fcc844f8fb BLI: use explicit task isolation, no longer part of parallel operations
After looking into task isolation issues with Sergey, we couldn't find the
reason behind the deadlocks that we are getting in T87938 and a Sprite Fright
file involving motion blur renders.

There is no apparent place where we adding or waiting on tasks in a task group
from different isolation regions, which is what is known to cause problems. Yet
it still hangs. Either we do not understand some limitation of TBB isolation,
or there is a bug in TBB, but we could not figure it out.

Instead the idea is to use isolation only where we know we need it: when
holding a mutex lock and then doing some multithreaded operation within that
locked region. Three places where we do this now:
* Generated images
* Cached BVH tree building
* OpenVDB lazy grid loading

Compared to the more automatic approach previously used, there is the downside
that it is easy to miss places where we need isolation. Yet doing it more
automatically is also causing unexpected issue and bugs that we found no
solution for, so this seems better.

Patch implemented by Sergey and me.

Differential Revision: https://developer.blender.org/D11603
2021-06-15 17:28:44 +02:00
Germano Cavalcante
b3f0dc2907 Draw Cache: avoid recalculating 'poly_normals'
Call `BKE_mesh_ensure_normals_for_display` to avoid recalculating
poly_normals.

**Benchmark**
||master:|PATCH:
|---|---|---|
|looptris_test:|Average: 3.995076 FPS|Average: 4.047470 FPS
||rdata 11ms iter 91ms (frame 235ms)|rdata 11ms iter 86ms (frame 233ms)
|subdiv_mesh_cage_and_final:|Average: 1.884492 FPS|Average: 1.900114 FPS
||rdata 7ms iter 42ms (frame 268ms)|rdata 7ms iter 39ms (frame 265ms)
||rdata 7ms iter 44ms (frame 259ms)|rdata 7ms iter 42ms (frame 257ms)
|subdiv_mesh_final_only:|Average: 6.245944 FPS|Average: 6.289000 FPS
||rdata 3ms iter 23ms (frame 153ms)|rdata 3ms iter 21ms (frame 154ms)
|subdiv_mesh_final_only_ledge:|Average: 6.263482 FPS|Average: 6.187218 FPS
||rdata 3ms iter 23ms (frame 156ms)|rdata 3ms iter 22ms (frame 154ms)

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11527
2021-06-15 11:45:39 -03:00
71997921c4 Cleanup: use back-slash for doxygen comments 2021-06-16 00:08:34 +10:00
0c75a98561 CMake: disable TBB when not found 2021-06-16 00:08:34 +10:00
Jeroen Bakker
174ed69c1b DrawManager: Cache material offsets.
When using multiple materials in a single mesh the most time is spend in
counting the offsets of each material for the sorting.

This patch moves the counting of the offsets to render mesh data and
caches it as long as the geometry doesn't change.

This patch doesn't include multithreading of this code.

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D11612
2021-06-15 15:31:34 +02:00
1172c0ae44 Merge branch 'master' into temp-attribute-processor 2021-06-15 15:22:10 +02:00
7c8b9c7a9a Fix warning treated as an error
"void' function returning a value".
2021-06-15 09:57:57 -03:00
62906cdbea Cleanup: Added hierarchy in MeshBufferExtractionCache. 2021-06-15 12:34:13 +02:00
7f570a7174 Cleanup: Split mesh_render_data_loose_geom into multiple functions. 2021-06-15 11:39:36 +02:00
9cd2e80d5d Fix: wrong size check
This fixes a bad mistake by myself. Thanks Lukas Tönne for telling me.
2021-06-15 10:26:31 +02:00
462bd81399 Fix: Sequencer backdrop not updated during playback.
Caused by recent optimization in {7b76a160a4}.
2021-06-15 09:31:03 +02:00
819152527f BMesh: assert that face normals have been updated for tessellation
This catches missing normal updates that may cause invalid tessellation.
2021-06-15 14:54:34 +10:00
89e2b441ed Cleanup: remove return value from face normal calculation
This value is always 'sides - 2', no need to return this value.
2021-06-15 14:38:10 +10:00
ae34808114 Fix missing normal update in edit-mesh blend-from shape operator 2021-06-15 14:35:43 +10:00
fdad77d73d BMesh: use faster normal update method for edit-mesh coordinates
This wasn't included in the previous fix so it'd be 2.93 compatible.
2021-06-15 13:52:00 +10:00
0a361eb5ec Fix outdated face tessellation use when editing edit-mesh coodinates 2021-06-15 13:31:33 +10:00
2ba804d7b7 Screen: clear runtime structures on file-read & data-copy
Clear the runtime data structs instead of individual members,
this simplifies adding new runtime members as there are at least
two places they would need to be cleared.

Resolves error in D8883.
2021-06-15 12:52:59 +10:00
5dc0fd08a7 Cleanup: correct incomplete comment 2021-06-15 10:59:57 +10:00
2053e1f533 Fix image space missing mask display panel 2021-06-15 10:50:48 +10:00
4ae06b6123 Cleanup: remove "_" prefix for used arguments 2021-06-15 10:50:43 +10:00
013fc69ea8 Cleanup: unused argument & variable warnings 2021-06-15 10:50:43 +10:00
3bf98d1cec Cleanup: use private methods for internal operator utilities
Also remove unused argument.
2021-06-15 10:08:57 +10:00
9ce49af32e Cleanup: use doxygen comments for DNA_color_types
Also use enum instead of defines for Scopes.wavefrm_mode
2021-06-15 09:34:58 +10:00
1f251b7a27 Win8 cleanup, remove dead function pointer and macro. 2021-06-14 14:41:58 -07:00
61fdc45034 Geometry Nodes: Join dynamic curve attributes in the join geometry node
This commit lets the join geometry node transfer dynamic attributes
to the result, the same way that point cloud and mesh attributes are
joined. The implementation is different though, because of an
optimization implemented for curves to avoid copying splines.

The result attribute is added with the highest priority domain (points
over splines), and the highest complexity data type. If one curve had
the attribute on the spline domain but not others, the point domain
values will be used.

Generally this is a bit lower level than I would have liked this code
to be, but should be efficient, and it's really not too complicated.

Differential Revision: https://developer.blender.org/D11491
2021-06-14 15:13:43 -05:00
bf7f918a0e Geometry Nodes: Parallelize curve reverse node
Each spline can be handled separately here. This gives approximately a
2x speedup on my 8 core processor on an input of 80000 2 point splines.
2021-06-14 14:28:57 -05:00
fe0fa7cec6 Cleanup: Refactor join geometry node attribute gathering
Instead of building a set and then determining the final domain and
type for every attribute separately in the loop, construct a map with
the necessary data in the first place. This is simpler and should be
slightly more efficient.

Split from D11491
2021-06-14 13:58:11 -05:00
Johnny Matthews
4a540b9b48 Geometry Nodes: Curve Reverse Node
This is an implementation of T88722. It accepts a curve object and
for each spline, reverses the order of the points and all attributes.
This is more of a foundational node to support other nodes in the
future (like curve deform)

Selection takes spline domain attributes to determine which splines
are selected. If no selection is present all splines are reversed.

Differential Revision: https://developer.blender.org/D11538
2021-06-14 13:28:38 -05:00
fcbb20286a Geometry Nodes: Curve to Points Node for Evaluated Data
This node implements the second option of T87429, creating points
along the input splines with the necessary evaluated information
for instancing: `tangent`, `normal`, and `rotation` attributes.
All generic curve point and spline attributes are copied to the
result points as well.

The "Count" and "Length" methods are just like the current options
in the resample node, but the output is points instead of a curve.
The "Evaluated" method uses the points you see on the curve directly,
and therefore should be the fastest.

The rotation data is retrieved from a transform matrix built with the
same method that the curve to mesh node uses. The radius attribute is
divided by 10 so the points don't look absurdly huge in the viewport.
In the future that could be an option.

For the implementation, one thing that could use an improvement
is the amount of temporary allocations while resampling to evaluated
points before the final points. I expect that reusing a buffer for
each thread would give a nice improvement.

Differential Revision: https://developer.blender.org/D11539
2021-06-14 12:52:08 -05:00
d08e925ef1 Fix Build Warning
Marking unused function argument.

Introduced in bcff0ef9ca

Differential Revision: https://developer.blender.org/D10887
2021-06-14 10:42:28 -07:00
bcff0ef9ca UI: Windows Blend File Association
This patch allows Windows users to specify that their current blender
installation should be used to create thumbnails and be associated
with ".blend" files. This is done from Preferences / System. The only
way to do this currently is from the command-line and this is sometimes
inconvenient.

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

Reviewed by Brecht Van Lommel
2021-06-14 10:22:03 -07:00
2e5671a959 Fix: VSE seeking with proxy strips would fail on certain frames
If the last decoded frame had the same timestamp as the GOP current
packet, then we would skip over this frame when fast forwarding and we
would seek until the end of the file.

This would could only be triggered reliably in single threaded mode.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11601
2021-06-14 19:08:51 +02:00
aadd355028 Fix possible C-linkage warning on Clang
The warning would appear when using the `ENUM_OPERATORS()` macro inside
of an `extern "C"` block.
Didn't cause a warning in master currently, but in the
`asset-browser-poselib` branch.

After macro expansion, there would be C++ code in code with C linkage
(`extern "C"`). So make sure the expanded C++ code always uses C++
linkage.
The syntax used is totally C++ compliant: the C++ standard requires that
in such nested linkage specifications, the innermost one determines the
linking language (e.g. see
https://timsong-cpp.github.io/cppwp/n4659/dcl.link#4).
2021-06-14 19:00:13 +02:00
3de6fe0b3e Error Messages Creating Thumbnail Folders
On the Windows platform there will be some errors printed to the
console if the user's thumbnail cache folder doesn't already exist.
While creating those folders there is an attempt to do so multiple
times and so we get errors when trying to create when exists. This
is caused by paths that have hard-coded forward slashes, which causes
our path processing routines to not work correctly. This patch defines
those paths using platform-varying separator characters.

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

Reviewed by Brecht Van Lommel
2021-06-14 09:17:27 -07:00
e9b4de43d8 Cleanup: rename id to owner_id for python id properties
This is consistent with the naming in `PointerRNA`.
2021-06-14 18:13:27 +02:00
90b0fb135f PyAPI: remove deprecated bpy.app.binary_path_python 2021-06-14 23:52:08 +10:00
8a1860bd9a BMesh: support face-normal calculation in normal & looptri functions
Support calculating face normals when tessellating. When this is done
before updating vertex normals it gives ~20% performance improvement.

Now vertex normal calculation only needs to perform a single pass on the
mesh vertices when called after tessellation.

Extended versions of normal & looptri update functions have been added:

- BM_mesh_calc_tessellation_ex
- BM_mesh_normals_update_ex

Most callers don't need to be aware of this detail by using:

- BKE_editmesh_looptri_and_normals_calc
- BKE_editmesh_looptri_and_normals_calc_with_partial

- EDBM_update also takes advantage of this,
  where calling EDBM_update with calc_looptri & calc_normals
  enabled uses the faster normal updating logic.
2021-06-14 23:01:19 +10:00
6bef255904 BMesh: remove unit-length edge-vector cache from normal calculation
Bypass stored edge-vectors for ~16% performance gains.

While this increases unit-length edge-vector calculations by around ~4x
the overhead of a parallel loop over all edges makes it worthwhile.

Note that caching edge-vectors per-vertex performs better and may be
worth investigating further, although in my tests this increases code
complexity with barley measurable benefits over not using cache at all.

Details about performance and possible optimizations are noted in
bm_vert_calc_normals_impl.
2021-06-14 22:56:02 +10:00
8083527f90 Edit Mesh: use params arg for update function, add calc_normals arg
Rename function EDBM_update_generic to EDBM_update, use a parameters
argument for better readability.

Also add calc_normals argument, which will have benefits when
calculating normals and tessellation together is optimized.
2021-06-14 22:56:01 +10:00
1d2eb461b5 Cleanup: clang-format 2021-06-14 22:56:00 +10:00
Thomas Lachmann
b84707df17 Python API: option for render engines to disable image file saving
For some custom rendering engines it's advantageous not to write the image files to disk.
An example would be a network rendering engine which does it's own image writing.

This feature is only supported when bl_use_postprocess is also disabled, since render
engines can't influence the saving behavior of the sequencer or compositor.

Differential Revision: https://developer.blender.org/D11512
2021-06-14 14:20:04 +02:00
ada47c4772 Fix build error in release builds after recent changes 2021-06-14 13:22:11 +02:00
748475b943 BLI_math: Cleanup: Use mul_/madd_ functions.
Better to avoid explicit vectors components direct manipulation when a
generic operation for whole vector exists, if nothing else it avoids
potential mistakes in indices.
2021-06-14 12:32:38 +02:00
b21db5e698 BLI_math: Fix several division-by-zero cases.
Those were caused by various tools used on degenerate geometry, see
T79775.

Note that fixes are as low-level as possible, to ensure they cover as
much as possible of unreported issues too.

We still probably have many more of those hidden in BLI_math though.
2021-06-14 12:32:38 +02:00
Leon Zandman
5add6f2ed9 Fix T87867: file open dialog triggers OneDrive file downloads on macOS
Until OneDrive supports macOS's native placeholder file implementation, detect
the com.microsoft.OneDrive.RecallOnOpen extended file attribute.

Differential Revision: https://developer.blender.org/D11466
2021-06-14 12:26:07 +02:00
c9dc55301c Fix T88494: add missing depsgraph relation update tags
Adding e.g. a Collection Info node creates a new depsgraph relation.
Therefore the relations should be updated.
2021-06-14 11:35:36 +02:00
a19c9e9351 Fix T88947: invalid normals when converting point cloud to mesh 2021-06-14 11:07:42 +02:00
Campbell Barton
2db09f67a4 Nodes: remove redundant increment node tree current socket index
`ntree->cur_index` was being incremented twice in make_socket_interface.

Reviewed By: JacquesLucke

Ref D11590
2021-06-14 18:46:39 +10:00
03544ed54f Fix T88807: crash when there are multiple links between the same sockets
This commit does two things:

* Disallows creating more than one link from one socket to a multi socket input.
* Properly count links if there happen to be more than one link between the same sockets.

The new link counting should also be more efficient asymptotically.

Differential Revision: https://developer.blender.org/D11570
2021-06-14 10:04:52 +02:00
54a03d4247 Cleanup: Reduce indentation from redundant check 2021-06-13 18:56:52 -05:00
84adc23941 Cleanup: Order return argument last 2021-06-13 18:22:31 -05:00
0f68e5c30a Fix libmv new[]/delete[] mismatch 2021-06-13 15:13:08 +10:00
5181bc46b3 Cleanup: allocation size mismatch warning
While harmless, use fixed size int type for pixel data.
2021-06-13 14:54:54 +10:00
452590571c Cleanup: rename 'unsigned int' -> 'uint' 2021-06-13 14:54:54 +10:00
ab38223047 Cleanup: redundant initialization
These were limited to obvious cases. Some less obvious cases
were kept as refactoring might make them necessary in future.
2021-06-13 14:54:54 +10:00
f731bce6cd Cleanup: use ATTR_RETURNS_NONNULL function attribute 2021-06-13 14:47:19 +10:00
4c3bb60d0f Cleanup: use return arg prefix for ED_object_add_generic_get_opts 2021-06-13 14:47:18 +10:00
9ff4e0068f Cleanup: avoid the possibility of 'enter_editmode' being left unset
While in practice this isn't an issue currently, always set
'enter_editmode' in ED_object_add_generic_get_opts
to avoid problems in the future.
2021-06-13 14:47:07 +10:00
84e98ba182 Cleanup: misleading return argument for hair_create_input_mesh
- The argument with named with an `r_` prefix when it was in fact
  also read from.
- The argument passed in had to be 'psys->clmd->hairdata',
  if it was not - the function would not worked.
2021-06-13 14:47:04 +10:00
8e58f93215 Cleanup: remove redundant NULL check, reduce scope 2021-06-13 14:47:03 +10:00
aab4794512 Cleanup: missing include 2021-06-13 14:47:01 +10:00
952d6663e0 Fix modifier deform by armature check ignoring virtual modifiers
Regression in f00cb93dbe (fix for T63125)
2021-06-13 14:46:59 +10:00
7b0c8097a7 Fix missing directory in CMakeLists.txt 2021-06-12 00:00:29 -03:00
b313525c1b Fix T88515: Cycles does not update light transform from linked collections
When moving a linked collection, we seem to only receive a depsgraph update
for an empty object so the Blender synchronization cannot discriminate it
and tag the object(s) (light or geometry) for an update through
id_map.set_recalc.

This missing transform update only affects lights since we do not check
manually if the transformations were modified like we do for objects.

To fix this, add a check to see if the transformation is different provided
that a light was already created.

Reviewed By: brecht

Maniphest Tasks: T88515

Differential Revision: https://developer.blender.org/D11574
2021-06-12 04:13:43 +02:00
d75e45d10c Fix T88812: Child Windows on Vertical Monitors
This patch improves the positioning of child windows when on monitors
that are arranged vertically (any above any other). When calculating a
window position in Ghost coordinates from GL coordinates we were using
monitor height, which can give incorrect values when desktop is taller
than any single monitor. So use desktop height instead.

See D10637 for more details and examples.

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

Reviewed by Brecht Van Lommel
2021-06-11 14:39:19 -07:00
bd87ba90e6 Render Window as Non-Child on Win32 platform
This patch makes the "Render" window a top-level window, not a child of
the main window, which was the case in blender versions prior to 2.93.
This means it is no longer "on top", nor is the icon grouped on the
taskbar in the same way, but you can Alt-Tab between it and the main
window. This change only affects the Windows platform as the other
platforms behave this way.

See D11576 for links to negative feedback that prompts this change.

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

Reviewed by Brecht Van Lommel
2021-06-11 13:07:30 -07:00
Pablo Dobarro
7bc5246156 Overlays: Make flash on mode transfer an operator property
This moves the flash on mode transfer effect option from the overlays to
an operator property of the mode transfer operator.

- This effect is intended to show the target object when no overlays or
a minimal set of overlays is enabled. Making it part of the whole set of
overlays invalidates this use case.

- The effect is not intended to be configurable per viewport, it should
be a global option.

The effect is still implemented using the overlay engine (instead of a
draw modal callback) due to performance and drawing artifacts. Having it
implemented as an overlay with runtime timer data in the objects makes
also possible to run multiple animations at the same time without any
visual glitches.

Reviewed By: campbellbarton, JulienKaspar

Differential Revision: https://developer.blender.org/D11519
2021-06-11 21:48:59 +02:00
f6c5af3d47 Add option to link assets on drag & drop
Note: Linking in this case as in link vs. append. Easily confused with linking
a data-block to multiple usages (e.g. single material used by multiple
objects).

Adds a drop-down to the Asset Browser header to choose between Link and Append.
This is probably gonna be a temporary place, T54642 shows where this could be
placed eventually.

Linking support is crucial for usage of the asset browser in production
environments. It just wasn't enabled yet because a) the asset project currently
focuses on single user, not production assets, and b) because there were many
unkowns still for the workflow that have big impact on production use as well.
With the recently held asset workshop I'm more confident with enabling linking,
as design ideas relevant to production use were confirmed.

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

Reviewed by: Bastien Montagne
2021-06-11 16:46:20 +02:00
c8fcea0c33 Fix object assets getting duplicated after dropping
The operator run when dropping objects would duplicate the dropped object and
place that in the scene, even though that was just appended. Addressed by
making the duplication optional for the operator. If the duplication is not
requested, the object is just added to the scene (if needed), repositioned
based on the drop location and selected (deselecting other objects).
This makes the operator work as expected when using it to drop assets.

Reviewed as part of https://developer.blender.org/D11536.

Reviewed by: Bastien Montagne
2021-06-11 16:46:20 +02:00
20ece8736f Fix T89001: node search not working anymore 2021-06-11 16:27:56 +02:00
Maxime Casas
b4adb85933 Fix T89033: segfault reordering animation channels
Fix segmentation fault that can occur when reordering animation
channels.

Under some specific conditions, the list "act->curves" is empty in the
"join_groups_action_temp" function. In particular, this happens when a
scene contains an action that has not been pushed down, and with no
keyframe in it.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D11569
2021-06-11 16:27:04 +02:00
605ce623be Nodes: cache socket identifier to index mapping
While this preprocessing does take some time upfront,
it avoids longer lookup later on, especially as nodes get
more sockets.

It's probably possible to make this more efficient in some cases
but this is good enough for now.
2021-06-11 16:21:23 +02:00
Jeroen Bakker
7b30a3e98d Performance: Use parallel range for ImBuf scanline processor.
Scanline processor did its own heurestic what didn't scale well when
having a multiple cores. In stead of using our own code this patch will
leave it to TBB to determine how to split the scanlines over the
available threads.

Performance of the IMB_transform before this change was 0.002123s, with
this change 0.001601s. This change increases performance in other areas
as well including color management conversions.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D11578
2021-06-11 15:55:22 +02:00
Jeroen Bakker
7b76a160a4 Sequencer: Do not redraw during playback.
When using large sequences including audio the drawing of the audio on
top of the strip takes a lot of time. This effects the playback
performance heavily.

During the animation playback performance there was a solution for this
by only drawing the playhead overlay. This was reverted for the sequence
editor as it didn't update the color strips when they were animated.

This patch checks if there are animated color strips if so the full
screen is redrawn, otherwise only the playhead is redrawn.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D11580
2021-06-11 15:51:26 +02:00
0eb9351296 Refactor: use 'BLI_task_parallel_range' in Draw Cache
One drawback to trying to predict the number of threads that will be
used in the `task_graph` is that we are only sure of the number when the
threads are running.

Using `BLI_task_parallel_range` allows the driver to
choose the best thread distribution through `parallel_reduce`.

The benefit is most evident on hardware with fewer cores.

This is the result on an 4-core laptop:
||before:|after:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)

Differential Revision: https://developer.blender.org/D11558
2021-06-11 10:49:50 -03:00
Germano Cavalcante
2330cec2c6 Refactor: Draw Cache: use 'BLI_task_parallel_range'
This is an adaptation of {D11488}.

A disadvantage of manually setting the iter ranges per thread is that
we don't know how many threads are running in the background and so we
don't know how to best distribute the ranges.

To solve this limitation we can use `parallel_reduce` and thus let the
driver choose the best distribution of ranges among the threads.

This proved to be especially beneficial for computers with few cores.

**Benchmarking:**
Here's the result on an 4-core laptop:
||master:|PATCH:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)

Here's the result on an 8-core PC:
||master:|PATCH:
|---|---|---|
|large_mesh_editing:|Average: 15.267482 FPS|Average: 15.906881 FPS
||rdata 9ms iter 28ms (frame 65ms)|rdata 9ms iter 25ms (frame 63ms)
|large_mesh_editing_ledge: |Average: 15.145966 FPS|Average: 15.520474 FPS
||rdata 9ms iter 29ms (frame 65ms)|rdata 9ms iter 25ms (frame 64ms)
|looptris_test:|Average: 4.001917 FPS|Average: 4.061105 FPS
||rdata 12ms iter 90ms (frame 236ms)|rdata 12ms iter 87ms (frame 230ms)
|subdiv_mesh_cage_and_final:|Average: 1.917769 FPS|Average: 1.971790 FPS
||rdata 7ms iter 37ms (frame 261ms)|rdata 7ms iter 31ms (frame 258ms)
||rdata 7ms iter 38ms (frame 252ms)|rdata 7ms iter 33ms (frame 249ms)
|subdiv_mesh_final_only:|Average: 6.387240 FPS|Average: 6.591251 FPS
||rdata 3ms iter 25ms (frame 151ms)|rdata 3ms iter 16ms (frame 145ms)
|subdiv_mesh_final_only_ledge:|Average: 6.247393 FPS|Average: 6.596024 FPS
||rdata 3ms iter 26ms (frame 158ms)|rdata 3ms iter 16ms (frame 148ms)

**Notes:**
- The improvement can only be noticed if all extracts are multithreaded.
- This patch touches different areas of the code, so it can be split into another patch if the idea is accepted.

These screenshots show how threads behave in a quadcore:
Master:
{F10164664}
Patch:
{F10164666}

Differential Revision: https://developer.blender.org/D11558
2021-06-11 10:45:12 -03:00
fe22635bf6 Nodes: add utilities to check if there are undefined nodes/sockets 2021-06-11 14:55:10 +02:00
c0367b19e2 Fix: VSE search in mpegts files would fail
ffmpeg_generic_seek_workaround did work properly and our start pts
calculation was wrong.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11562
2021-06-11 14:05:07 +02:00
4adbe31e2f Fix: VSE indexer seeking not working correctly
Because of the added sanity checks in rB14508ef100c9 (D11492), seeking
in proxies would not work correctly any more. This is because it wasn't
working as intended before, but in most cases this wouldn't be
noticeable. However now when the sanity checks are tripped it is very
noticeable that something is wrong

The indexer tried to use dts values for time stamps when we used pts in
our decode functions to get the time positions. This would make it
start in the wrong GOP frames when searching. Now that we enforce no
crossing of GOP frames when decoding after seek, this would lead to
issues.

Now we correctly use pts (or dts if pts is not available) and thus we
don't have any seeking issues because of time stamp format missmatch.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11561
2021-06-11 14:04:48 +02:00
1fb2eaf1c5 Fix: VSE timecodes being used even when turned off.
Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11567
2021-06-11 14:04:35 +02:00
2f280d4b92 LineArt: Fix crash due to empty duplicollection. 2021-06-11 17:55:33 +08:00
e9c8ae767a Performance: Split ImBuf sampling.
When sampling ImBuf can be a char or a float buffer. Current sampling
functions added overhead by checking which kind of buffer was passed
every pixel that was sampled. When performing image processing this
check can be removed outside the inner loop adding 5% of performance
increase in the `IMB_transform` operator.
2021-06-11 11:37:39 +02:00
Xing Liu
7fc220517f Fix T88068: Alt+I now respects keying set
Remap {key Alt I} from `anim.delete_key_v3d` to `anim.delete_key`. This
makes it keyframe removal symmetrical with keyframe insertion ({key I}).

Both the default keymap {key Alt I} and the Industry Compatible keymap
{key Alt S} have been updated.

Reviewed By: sybren, #animation_rigging

Maniphest Tasks: T88068

Differential Revision: https://developer.blender.org/D11528
2021-06-11 11:13:20 +02:00
Jeroen Bakker
28617bb167 Sequencer: Transform ImBuf Processor.
Inside the sequencer the cropping and transform of images/buffers were
implemented locally. This reduced the optimizations that a compiler
could do and added confusing code styles. This patch adds
`IMB_transform` to reduce the confusion and increases compiler
optimizations as more code can be inlined and we can keep track of
indices inside the inner loop.

This increases end-user performance by 30% when playing back aa video
in VSE.

Reviewed By: ISS, zeddb

Differential Revision: https://developer.blender.org/D11549
2021-06-11 09:34:44 +02:00
84f025c6fd Cleanup: use sentences for pose slide comments 2021-06-11 16:27:55 +10:00
Christoph Lendenfeld
066f5a4469 Cleanup: pose slider rename region to region_header
Reviewed By: sybren, campbellbarton

Ref D11365
2021-06-11 15:53:34 +10:00
Christoph Lendenfeld
d07cc5e680 Cleanup: pose slider use enum types
use enum types in `tPoseSlideOp` instead of `short`

Reviewed By: sybren, campbellbarton

Ref D11364
2021-06-11 15:40:07 +10:00
Christoph Lendenfeld
162cf8e81d Cleanup: pose slider use strncpy
use `STRNCPY` instead of `BLI_strncpy`

Reviewed By: sybren, campbellbarton

Ref D11363
2021-06-11 15:38:27 +10:00
Christoph Lendenfeld
fd5c94c48a Cleanup: pose slider data types
- change vec2f to float[2]
- pass rctf as pointer
- change `const struct rctf` to `const rctf`
2021-06-11 15:36:41 +10:00
Christoph Lendenfeld
2724d08cf5 Cleanup: pose slider rename "percentage" to "factor"
This patch changes occurrences of percentage to factor.

There are some usages of percentage left in there on purpose.
They are distinguished as follows:

- factor is 0-1 float
- percentage is 0-100 int

Ref D11361

Reviewed by: sybren, campbellbarton
2021-06-11 15:29:52 +10:00
Charlie Jolly
461ba4438f Nodes: move mix rgb node to C++
Prepare node for conversion to Geometry Nodes.

There should be no functional changes.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D11506
2021-06-11 00:01:13 +01:00
d581c1b304 UI: Correct label naming mistake for VSE text strip box background
Seems to be a copy/paste error from 
rB235c309e5f86e84fb08e1ff2c5c11eb0b775c388
2021-06-10 17:45:16 -04:00
e8a4bddef4 deps/windows: add missing tbbmalloc_debug.lib
This file is being linked by blender without
it existing causing issues for debug builds.
2021-06-10 12:03:12 -06:00
fbd889ec28 Fix T86544: better cleanup of path given as command line argument.
When using non-default system separator in filename path, code would end up
with an absolute path mixing regular and alternative separator,
confusing the rest of the path manipulations later on.

So this commit add proper replacements of alternative separators, and
path normalization.
2021-06-10 18:37:46 +02:00
509e0c5b76 Cleanup: BLI_path_slash_native: use separator defines instead of literal values.
Even though this function is alredy using system-specific code, it's
still cleaner to use `SEP` and `ALTSEP` here.
2021-06-10 18:35:35 +02:00
7b62a54230 Fix T88578: crash when loading value from group output node
It remembered the wrong origin socket and couldn't find the value
anymore later on.
2021-06-10 17:24:53 +02:00
Eitan
53c98e45cf Geometry Nodes: Add Texture and Material options to switch node
These new socket types can be supported in the switch node
along with the others.

Differential Revision: https://developer.blender.org/D11560
2021-06-10 10:16:37 -05:00
bcefce33f2 BLI_mempool: split thread-safe iteration into the private API
Splitting out thread safe iteration logic means regular iteration
isn't checking for the thread-safe pointer each step.

This gives a small but measurable overall performance gain of 2-3%
when redrawing a high-poly mesh.

Ref D11564

Reviewed By: mont29
2021-06-11 00:31:16 +10:00
7f17d15125 fix bugs 2021-06-10 14:56:30 +02:00
b33fd7e89e add Position Input/Output and Attribute Input node 2021-06-10 12:52:45 +02:00
10b78013eb support default mode again and have separate default attribute name 2021-06-10 12:07:37 +02:00
3d057de976 Merge branch 'master' into temp-attribute-processor 2021-06-10 09:35:41 +02:00
3817b408e0 fix crash when creating group 2021-06-09 14:01:03 +02:00
b8d3ad515a fix copying default value from node group inputs 2021-06-09 12:50:44 +02:00
022b541cb3 node group fixes 2021-06-09 12:44:33 +02:00
e294e7a99c fixes 2021-06-09 12:26:29 +02:00
7928578f18 support Set Attribute node 2021-06-09 12:13:44 +02:00
369aa3a8a0 improve Set Attribute node 2021-06-09 11:41:25 +02:00
243b5ac98c add initial Set Attribute node 2021-06-09 11:19:05 +02:00
b63483baec cleanup 2021-06-09 11:08:07 +02:00
4ee0e62986 cleanup 2021-06-09 10:54:59 +02:00
b2184402ae support selection 2021-06-09 10:52:13 +02:00
028777bdba cleanup 2021-06-09 10:41:50 +02:00
e43c171455 Cleanup 2021-06-09 10:37:02 +02:00
e433e4ae42 cleanup 2021-06-09 10:18:47 +02:00
f22aa19845 cleanup 2021-06-09 10:17:56 +02:00
3391649edd cleanup 2021-06-09 10:17:21 +02:00
9e95222cb7 Geometry Nodes: New Attribute Processor.
Differential Revision: https://developer.blender.org/D11547
2021-06-09 10:14:55 +02:00
ef07d5a297 fix 2021-06-08 16:42:41 +02:00
09ec88413b fix 2021-06-08 16:36:11 +02:00
b9c8bb4254 Merge branch 'master' into temp-attribute-processor 2021-06-08 16:32:51 +02:00
64eb1df4b3 move Index node to input category 2021-06-07 16:59:08 +02:00
9a9b87d9c5 support attribute node 2021-06-07 16:59:08 +02:00
257b6bcc61 move operator from python to c++ 2021-06-07 16:59:08 +02:00
b53babaae7 update socket names 2021-06-07 16:59:08 +02:00
aa9efbedf1 remove default modes 2021-06-07 16:59:08 +02:00
93a5fe3a37 use enum for socket types 2021-06-07 16:59:08 +02:00
90de4edc06 improve add node group interface operator 2021-06-07 16:59:08 +02:00
138a0c8109 make attribute processor more prominent in the menu 2021-06-07 16:59:08 +02:00
3a06d098da Fix T88899: __file__ not set for text.as_module() 2021-06-07 16:59:08 +02:00
10636857f8 Event Simulate: and a --keep-open command line argument
It can be useful to investigate the state of the file
after event simulation runs.
2021-06-07 16:59:08 +02:00
e69f9fe0ca Cleanup: unused argument 2021-06-07 16:59:08 +02:00
3b39482e2c LineArt: Fix edge clipping index error.
Small bug that's causing edge count to be incorrect in
final culled list, just being offset exactly 1 entry.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11513
2021-06-07 16:59:08 +02:00
82c72ccdbc VSE: Remove seq->tmp usage from transform code
This field was used for extend feature to get handle position of
metastrip children. Since D9972 extend feature works only on meta
strip itself, not it's children.
So `SEQ_transform_get_left_handle_frame()` second argument is always
false and can be removed.

Another instance of `seq->tmp usage` is hack to distinguish strips to be
shuffled, which is not covered by this patch.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D10321
2021-06-07 16:59:08 +02:00
6ea2f106a0 Exact Boolean: fix last commit: pass an arg by reference instead of value. 2021-06-07 16:59:08 +02:00
c9d4f5d625 Exact Boolean: speed up when there are many separate components.
Use bounding box tests quickly tell that two components cannot
have a containment relation between each other. This change
cut about 0.6s off a test with 25 big icospheres.
2021-06-07 16:59:08 +02:00
22c7967205 Limit Rotation: explicitly orthogonalize the matrix before processing.
Add a call to orthogonalize the matrix before processing for the
same reasons as D8915, and an early exit in case no limits are
enabled for a bit of extra efficiency.

Since the constraint goes through Euler decomposition, it would
in fact remove shear even before this change, but the resulting
rotation won't make much sense.

This change allows using the constraint without any enabled limits
purely for the purpose of efficiently removing shear.

Differential Revision: https://developer.blender.org/D9626
2021-06-07 16:59:08 +02:00
56088650be Limit Rotation: add an Euler Order option.
Since Limit Rotation is based on Euler decomposition, it should allow
specifying the order to use for the same reasons as Copy Rotation does,
namely, if the bone uses Quaternion rotation for its animation channels,
there is no way to choose the order for the constraint.

Ref D9626
2021-06-07 16:59:08 +02:00
14ec1f4e13 Fix T88859: Assert when changing view modes
The `loose_lines`' ibo was not being initialized.
2021-06-07 16:59:08 +02:00
33d262a7c8 BMesh: avoid extra faces-of-edges loop building partial update data 2021-06-07 16:59:08 +02:00
ec04ff8a33 Fix assert check in BLI_polyfill_beautify 2021-06-07 16:59:08 +02:00
c5c607bdaa Fix assert in gpencil_batches_ensure 2021-06-07 16:59:08 +02:00
f4392d1423 Cleanup: use ternary operator for icon argument 2021-06-07 16:59:08 +02:00
005f7318b2 Fix T88828: View/Navigation(Walk/Fly) disappeared from keymap
This was unintentionally removed in
f92f5d1ac6.
2021-06-07 16:59:08 +02:00
93e08fdf90 Cleanup: indentation 2021-06-07 16:59:08 +02:00
92e16e35dc Cleanup: spelling in comments
Also remove reference to function that never existed for adding `bNode`.
2021-06-07 16:59:08 +02:00
2abb09aa2b FFmpeg: Fix seeking not returning the correct frame when not using TC index
Fixed the logic for seeking in ffmpeg video files.
The main fix is that we now apply a small offset in ffmpeg_get_seek_pos
to make sure we don't get the frame in front of the seek position when
seeking backward.

The rest of the changes is general cleanup and untangling code.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11492
2021-06-07 16:59:07 +02:00
a371d4bb2b Fix T88813: Scalable allocator not used on win10
Due to the way we ship the CRT on windows TBB's
malloc proxy was unable to attach it self to
the memory management functions on windows 10.

This change moves ucrtbase.dll out of the blender.crt
folder and back into the main blender folder to side
step some undesirable behaviour on win10 making TBB
once more able to attach it self.

Having this work again, should give a speed
boost in memory allocation heavy workloads
such as mantaflow.

For details on how this only failed on Win10
see T88813
2021-06-07 16:59:07 +02:00
03f9dba616 Edit Mesh: partial updates for normal and face tessellation
This patch exposes functionality for performing partial mesh updates
for normal calculation and face tessellation while transforming a mesh.

The partial update data only needs to be generated once,
afterwards the cached connectivity information can be reused
(with the exception of changing proportional editing radius).

Currently this is only used for transform, in the future it could be
used for other operators as well as the transform panel.

The best-case overall speedup while transforming geometry is about
1.45x since the time to update a small number of normals and faces is
negligible.

For an additional speedup partial face tessellation is multi-threaded,
this gives ~15x speedup on my system (timing tessellation alone).
Exact results depend on the number of CPU cores available.

Ref D11494

Reviewed By: mano-wii
2021-06-07 16:59:07 +02:00
Charlie Jolly
5f2ad6751c Nodes: Add Multiply Add to Vector Math nodes
Cycles, Eevee, OSL, Geo, Attribute

This operator provides consistency with the standard math node. Allows users to use a single node instead of two nodes for this common operation.

Reviewed By: HooglyBoogly, brecht

Differential Revision: https://developer.blender.org/D10808
2021-06-07 16:59:07 +02:00
04e6656ff1 windows/deps: Fix TBB build issues.
rB847579b42250 updated the TBB build script
which had some unintended consequences for
windows as the directory layout slightly
changed.

This change adjusts the builder to the new
structure, there are no version/functional
changes.
2021-06-07 16:59:07 +02:00
Philipp Oeser
0ed005d48a Texture Paint: changing paint slots and viewport could go out of sync
When changing to another texture paint slot, the texture displayed in
the viewport should change accordingly (as well as the image displayed
in the Image Editor).

The procedure to find the texture to display in the viewport
(BKE_texpaint_slot_material_find_node) could fail
though because it assumed iterating nodes would always happen in the
same order (it was index based). This is not the case though, nodes can
get sorted differently based on selection (see ED_node_sort).

Now check the actual image being referenced in the paint slot for
comparison.

ref T88788 (probably enough to call this a fix, the other issue(s)
mentioned in the report are more likely a feature request)

Reviewed By: mano-wii

Maniphest Tasks: T88788

Differential Revision: https://developer.blender.org/D11496
2021-06-07 16:59:07 +02:00
1f33e20f55 LibOverride: Fix early break in some of the resync code.
This `break` moved out of its braces at some point in the previous
fixes/refctors... :(
2021-06-07 16:59:07 +02:00
946f53d86e GPencil: Change Fill Boundary icon
The icon has been changed to `eye` because is more consistent with other areas.
2021-06-07 16:59:07 +02:00
7ab79ac6ba GPencil: Change Fill extend lines icon
The icon has been changed to `eye` because is more consistent with other areas.
2021-06-07 16:59:07 +02:00
Fynn Grotehans
049924c240 Update Camera presets
The (tracking) camera presets have not been updated in the last 7 or
more years, so they are very outdated. I found it pointless to have a
few specific camera models in the list and instead add the most commonly
used sensor sizes/film sizes. This way the list is shorter, easier to
maintain/becomes later outdated, and is more user friendly for most people
who don't own any of the specific cameras. I added the Crop Factor to the
Beginning of the name, so it gets sortet in the correct order and presets
are easier to find based on the size.

Reviewed By: #render_cycles, #motion_tracking, brecht, sergey

Differential Revision: https://developer.blender.org/D10739
2021-06-07 16:59:07 +02:00
6118cbb78e Greasepencil: show pressure curve widgets in the sidebar
These were only showing in the Properties Editor, but there is no reason
to have the panels be different in the sidebar (they should not show in
the top bar though).

agreed upon by both @anoniov and @mendio

ref T88787
2021-06-07 16:59:07 +02:00
bb2e2ad3ff BlenLoad: Ensure linked IDs are properly sorted.
So far, linked IDs were not properly sorted at all, only the ones
explicitely linked from WM code would be, but any indirectly linked
data-blocks would end up in some random order in their lists.

While not ideal, this is not a huge issue in itself, but it had bad
side-effects, e.g. causing (recursive) resync of overrides to happen in
random order, leading to mismatches between name indices of newly-generated
override IDs and the one existings e.g.

And in general, it is much better to be consistent here.

Note that the file sub-version is bumped for this commit, since some
sorting (the directly linked IDs which we keep a reference to) should
never need to be re-done after relevant doversion process.
2021-06-07 16:59:07 +02:00
467f97fb57 GPencil: Cleanup unneeded variable assign
The variable is assigned below again and the initial value is not used.
2021-06-07 16:59:07 +02:00
236ff239bb Fix T88803: GPencil Thickness modifier produces thicker lines
There was a double apply of the thickness due a bug in the fading new parameter.

Differential Revision: https://developer.blender.org/D11483
2021-06-07 16:59:07 +02:00
5e0068f3f7 Math: Added max_uu/min_uu variations. 2021-06-07 16:59:07 +02:00
Johnny Matthews
dfcb4abd4c Geometry Nodes: Curve Length Node
This commit adds a node that outputs the total length of all
evalauted curve splines in a geometry set as a float value.

Differential Revision: https://developer.blender.org/D11459
2021-06-07 16:59:04 +02:00
60bd05f920 Geometry Nodes: Support curve data in the geometry delete node
This commit implements support for deleting curve data in the geometry
delete node. Spline domain and point domain attributes are supported.

Differential Revision: https://developer.blender.org/D11464
2021-06-07 16:58:32 +02:00
688671b9d7 Cleanup: Add comment explaining assert
This triggers fairly often during development, so it might save some
frustration at some point to have a comment here.
2021-06-07 16:58:32 +02:00
07961e5358 Overlay: Flash on Mode Transfer overlay
This implements T87633

This overlay renders a flash animation on the target object when
transfering the mode to it using the mode transfer operator.
This provides visual feedback when switching between objects without
extra overlays that affect the general color and lighting in the scene.

Differences with the design task:

- This uses just a fade out animation instead of a fade in/out animation.
The code is ready for fade in/out, but as the rest of the overlays
(face sets, masks...) change instantly without animation, having a fade
in/out effect gives the impression that the object flashes twice (once
for the face sets, twice for the peak alpha of the flash animation).

- The rendering uses a flat color without fresnel for now, but this can
be improved in the future to make it look more like the shader in the
prototype.

- Not enabled by default (can be enabled in the overlays panel), maybe
the defaults can change for 3.0 to disable fade inactive and enable this
instead.

Reviewed By: jbakker, JulienKaspar

Differential Revision: https://developer.blender.org/D11055
2021-06-07 16:58:32 +02:00
01f2dad596 VSE: Add refresh_all operator to all sequencer regions
This operator is needed in some cases to update image preview.
In workspaces with smaller timelines this is limiting, because users
need to first check that mouse cursor is in correct place, then press
CTRL+R shortcut.
2021-06-07 16:58:32 +02:00
ffa4c53d10 VSE: Remove JPEG reference from proxy panel
Proxies doesn't use MJPEG codec anymore, but text still referenced it.
2021-06-07 16:58:32 +02:00
88c16c4e7a GHOST/wayland: fix restoring hidden cursor 2021-06-07 16:58:32 +02:00
fed3c58f92 GHOST/wayland: fix non-moving normal cursor 2021-06-07 16:58:32 +02:00
77f3b9ea9f GHOST/wayland: add 'xdg-decoration' support 2021-06-07 16:58:32 +02:00
1dd65919e5 GHOST/wayland: adapt window and cursor surface scale to support HiDPI screens 2021-06-07 16:58:32 +02:00
bdada925e3 GHOST/wayland: handle return values for data sources 2021-06-07 16:58:32 +02:00
89602a8366 GHOST/wayland: set parent relation only for dialogs to mimic X11 behaviour 2021-06-07 16:58:32 +02:00
96a8189d74 GHOST/wayland: handle missing relative-pointer and pointer-constraints support 2021-06-07 16:58:32 +02:00
8f18d076e9 GHOST/wayland: get cursor settings via D-Bus 2021-06-07 16:58:32 +02:00
1077c37f1b GHOST/wayland: inhibit warning 2021-06-07 16:58:32 +02:00
f54fc8ac6e cmake: use absolute path for Wayland libraries 2021-06-07 16:58:32 +02:00
a7e337957d GHOST/wayland: set swap interval to 0
The Wayland server will not update hidden surfaces. This will block the
main event loop and thus also block updates to visible windows in a multi-
window setup.
2021-06-07 16:58:32 +02:00
d6a773345b WM: only use the tablet drag threshold for mouse button events
Keyboard click-drag events now use the "Drag Threshold".
This resolves a problem where keyboard click drag events
used a much smaller threshold when using a tablet.
2021-06-07 16:58:32 +02:00
ff0259de92 LibOverride: fix previous commit (rB826bed4349fa). 2021-06-07 16:58:32 +02:00
6dac1211b1 LibOverride: Fix some fail cases with auto-resync.
In some cases e.g. only objects would actually need resync, so
collections on the override character would not be resynced, and if some
objects were sharing relationships with others those could be
lost/destroyed.
2021-06-07 16:58:32 +02:00
7568501934 Fix missing updates in RNA override create functions. 2021-06-07 16:58:32 +02:00
2200c5f761 LibOverride: Add override_hierarchy_createto ID's RNA API. 2021-06-07 16:58:32 +02:00
f11182b1be Fix T88762: UI using tab to enter next button could clamp the hard min/
max unneccessarily

Since rB298d5eb66916 [which was needed to update buttons with custom
property range functions correctly], using tab would always clamp
(hardmin/hardmax) properties which were using FLT_MAX / INT_MAX as range
in their property definitions.

The clamping of rB298d5eb66916 was copied over from rB9b7f44ceb56c
[where it was used for the softmin/softmax], and while the re-evaluation
of hardmin/hardmax is needed for custom property range functions, the
clamping should actually not take place.

There are many properties using FLT_MAX / INT_MAX etc. and while it
probably would be good to update these with ranges that make more sense
-- not using FLT_MAX / INT_MAX would not have done the clamping here --
there should not be an arbitrary limit to these and they should stay as
they are.

Maniphest Tasks: T88762

Differential Revision: https://developer.blender.org/D11473
2021-06-07 16:58:32 +02:00
a069bd219c Cleanup: make format 2021-06-07 16:58:32 +02:00
3d1a0f97f7 LibOverride: ensure proper indirect tag for 'virtual' linked IDs.
Ensure 'virtual' linked override IDs generated by the recursive resync
process are tagged as indirectly linked data.

This is needed to avoid the 'missing data' messages on those virtual
data-blocks after saving and reloading.
2021-06-07 16:58:32 +02:00
2d37e469a2 IDManagement: Collection: Fix several issues in relationships building code.
`BKE_main_collections_parent_relations_rebuild`,
`BKE_collection_parent_relations_rebuild` anf their internal
dependencies had two issues fixed by this commit:

* Main one was that a same collection could be processed several times,
  sometimes even in an infinite loop (in some rare corner cases), by
  `collection_parents_rebuild_recursive`.
* More exotic, code here would not ensure that the collections it was
  processing were actually in Main (or a master one from a scene in
  Main), which became an issue with some advanced ID management
  processes involving partially out-of-main remapping, like liboverride
  resync.
2021-06-07 16:58:32 +02:00
20b0de7db1 Cleanup: use ascii characters instead of unicode where possible
Follow own code style docs.
2021-06-07 16:58:32 +02:00
1b5288b87f Cleanup: spelling in comments, correct outdated comments 2021-06-07 16:58:32 +02:00
e83d96753c Cleanup: use doxy sections for node_relationships.cc 2021-06-07 16:58:32 +02:00
de5e3ef8e5 Fix invalid return values from file_execute
Error in 6c8c30d865
2021-06-07 16:58:32 +02:00
91544db137 Draw Mesh Extractor: Fix used thread count
Some threads were always idle because of this.
2021-06-07 16:58:32 +02:00
2cc7f32f18 Cleanup: Remove unused 'ExtractTaskData's members 2021-06-07 16:58:32 +02:00
9e16740ca1 Cleanup: Fix build warnings 2021-06-07 16:58:32 +02:00
fc94932596 VSE: Add strip-time intersection test function
Use SEQ_time_strip_intersects_frame function to test if strip intersects with frame.

Note: There are cases where this function should not be used. For example splitting
strips require at least 1 frame "inside" strip. Another example is drawing, where
playhead technically doesn't intersect strip, but it is rendered, because current
frame has "duration" or "thickness" of 1 frame.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11320
2021-06-07 16:58:32 +02:00
97e363a06a Cleanup: Strip duplication code
Remove unused flag `SEQ_DUPE_ANIM` and code used by this flag.
Remove flag `SEQ_DUPE_CONTEXT` and refactor code, to split operator
logic from duplication code.
Reduce indentation level in for loop.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11318
2021-06-07 16:58:32 +02:00
7d47eea06d Fix T57397: Movies are blurred after sws_scale
Images with 4:2:2 and 4:4:4 chroma subsampling were blurred when
`SWS_FAST_BILINEAR` interpolation is set for `anim->img_convert_ctx`.

Use `SWS_BILINEAR` interpolation for all movies, as performance is
not impacted by this change.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11457
2021-06-07 16:58:32 +02:00
5dbe82f129 FFmpeg: Update proxy settings
Changes in rBce649c73446e, affected established proxy codec preset.
Presets were not working and all presets were similar to `veryfast`.
Tunes are now working too, so `fastdecode` tune can be used. I have
measured little improvement, but I tested this only on 2 machines and
I have been informed that `fastdecode` tune does influence decoding
performance for some users.

Change preset from `slow` to `veryfast` and add tune `fastdecode`

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11454
2021-06-07 16:58:32 +02:00
9bd5dff790 FFmpeg: Fix H264 lossless render not lossless
While encoder parameters for lossless encoding are set correctly,
output is not lossless due to pixel format being set to
`AV_PIX_FMT_YUV420P` which is inherently lossy due to chroma subsampling.

This was reported in T61569 and was merged to T57397, but there were
2 bugs - one for encoding and one for decoding.

Set pixel format to `AV_PIX_FMT_YUV444P` when rendering lossless H264
files. This format isn't available in `codec->pix_fmts[0]` and it looks,
that it has to be hard-coded.

Reviewed By: sergey

Differential Revision: D11458
2021-06-07 16:58:32 +02:00
c3427196c2 Boolean exact: speedup by parallelizing a plane calculation.
This patch is from erik85, who says:
This patch makes populate_plane inside polymesh_from_trimesh_with_dissolve run in parallel.
On a test file with a boolean between two subdivided cubes (~6 million verts) this gives a 10% speed increase (49.5s to 45s) on my 6 core CPU.

Also there is an optimization of other_tri_if_manifold to skip the contains-call and get the pointer directly.
This reduces CPU time for find_patches from 5s to 2.2s on the same test file.
2021-06-07 16:58:32 +02:00
21c61092f0 Boolean exact: speedup when there are many components.
When there are many components (separate pieces of connected mesh),
a part of the algorithm to determine component containment was slow.
Using a float version of finding the nearest point on a triangle
as a prefilter sped this up enormously. A case of 25 icospheres
subdivided twice goes 11 seconds faster on my Macbook pro with this
change.
2021-06-07 16:58:32 +02:00
59ffc4945a Nodes: move some files to C++
This just moves a couple of files in `space_node` to C++ and fixes
related errors.

The goal is to be able to use C++ data structures to simplify the code.

Differential Revision: https://developer.blender.org/D11451
2021-06-07 16:58:32 +02:00
07b7158c29 Cleanup: unused variable 2021-06-07 16:58:32 +02:00
1b29d18790 Fix swapped x/y in event simulation script
Incorrect area center calculation, also correct comments.
2021-06-07 16:58:31 +02:00
f68eac3945 Fix T88732: Curve to mesh node crash with empty input curve
The mesh to curve node generated an empty curve because no edges were
selected. This commit changes that node to not add a curve in that case.

This also changes the curve to mesh node to not add a material when
no mesh was created. Even though we don't expect null curves or meshes
in this case, the change is harmless.
2021-06-07 16:58:31 +02:00
e99d523901 EEVEE: AOVs not same as cycles.
EEVEE uses hashing to sync aov names and types with the gpu.
For the type a hashed value was overridden making `decalA`
and `decalB` choose the same hash. This patches fixes this
by removing the most significant bit.
2021-06-07 16:58:31 +02:00
aa46b36a3f Revert "EEVEE: AOVs not same as cycles."
This reverts commit 730a46e87d.
2021-06-07 16:58:31 +02:00
cf84056954 EEVEE: AOVs not same as cycles.
EEVEE uses hashing to sync aov names and types with the gpu. For the type a hashed value was overridden making `decalA` and `decalB` choose the same hash. This patches fixes this by removing the most significant bit.
2021-06-07 16:58:31 +02:00
47d90d9a96 GPencil: New operator to Normalize strokes
Sometimes is required to reset the thickness or the opacity of the strokes. Actually this was done using a modifier, but this operators solves this.

Reviewed By: mendio, filedescriptor

Maniphest Tasks: T87427

Differential Revision: https://developer.blender.org/D11453
2021-06-07 16:58:31 +02:00
bbf78af3c5 Merge branch 'master' into temp-attribute-processor 2021-06-02 10:11:28 -04:00
3da0ad6bb2 add node to access iteration index 2021-05-31 11:41:51 +02:00
002e75fa24 Merge branch 'master' into temp-attribute-processor 2021-05-31 11:13:42 +02:00
427ea6e4ec create attribute node group in attribute tree 2021-05-28 12:16:59 +02:00
c1e587bc46 add initial attribute group 2021-05-28 11:28:05 +02:00
0a082f9ccd Merge branch 'master' into temp-attribute-processor 2021-05-28 10:55:42 +02:00
01321c7825 support other component types 2021-05-27 13:30:13 +02:00
abbd01aff0 support other input modes 2021-05-27 12:39:40 +02:00
40cbdf56fd fix socket recreation 2021-05-27 12:03:34 +02:00
29e5a8b200 cleanup 2021-05-27 11:27:46 +02:00
aa363a71cd improve naming 2021-05-27 11:27:30 +02:00
d42a2cfef4 Merge branch 'master' into temp-attribute-processor 2021-05-27 10:47:05 +02:00
1564743475 Merge branch 'master' into temp-attribute-processor 2021-05-27 10:42:04 +02:00
d932728ac1 initial working version 2021-05-25 18:41:45 +02:00
dcc7786f14 Merge branch 'master' into temp-attribute-processor 2021-05-25 16:58:15 +02:00
27fc7ca66c start creating network 2021-05-25 16:40:37 +02:00
9807cb0eef Merge branch 'master' into temp-attribute-processor 2021-05-25 16:30:02 +02:00
1f25ab4bb9 Merge branch 'master' into temp-attribute-processor 2021-05-25 11:38:01 +02:00
cadfba7aad support changing sockets 2021-05-25 11:13:20 +02:00
be5f911e2a add rna for group inputs 2021-05-25 09:52:57 +02:00
c37de30fdb add initial info for inputs and outputs 2021-05-24 17:53:58 +02:00
95d64038f4 show domain 2021-05-24 17:22:10 +02:00
7f32a3ddd3 start creating correct sockets 2021-05-24 17:13:20 +02:00
fcba670314 create nodes in new group 2021-05-24 17:07:18 +02:00
4fe0ef5eab fix showing menu items of wrong tree type 2021-05-24 16:57:31 +02:00
4a6a755afd support tab on attribute processor 2021-05-24 16:50:32 +02:00
64b4e66afb cleanup 2021-05-24 16:39:15 +02:00
ec77f2d11d support creating attribute processor 2021-05-24 16:36:00 +02:00
e36fe7b78f initial sockets on attribute processor 2021-05-24 16:13:50 +02:00
a795d243cb reference group in attribute processor 2021-05-24 16:07:24 +02:00
4c322f3fba initial attribute processor geometry node 2021-05-24 15:51:26 +02:00
03d31e568f add initial nodes to menu 2021-05-24 15:37:16 +02:00
1291e369f9 initial attribute nodes 2021-05-24 15:29:27 +02:00
1512 changed files with 27381 additions and 13500 deletions

View File

@@ -265,4 +265,5 @@ ForEachMacros:
- VECTOR_SET_SLOT_PROBING_BEGIN
StatementMacros:
- PyObject_HEAD
- PyObject_VAR_HEAD

View File

@@ -836,7 +836,7 @@ if(WITH_PYTHON)
# because UNIX will search for the old Python paths which may not exist.
# giving errors about missing paths before this case is met.
if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.9")
message(FATAL_ERROR "At least Python 3.9 is required to build")
message(FATAL_ERROR "At least Python 3.9 is required to build, but found Python ${PYTHON_VERSION}")
endif()
file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons")

View File

@@ -79,6 +79,7 @@ if(WIN32)
# Normal collection of build artifacts
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_debug.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbb_debug.dll ${HARVEST_TARGET}/tbb/bin/tbb_debug.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy_debug.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc_debug.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc_proxy_debug.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy_debug.dll

View File

@@ -472,8 +472,7 @@ if(NOT GFLAGS_FOUND)
gflags_report_not_found(
"Could not find gflags include directory, set GFLAGS_INCLUDE_DIR "
"to directory containing gflags/gflags.h")
endif(NOT GFLAGS_INCLUDE_DIR OR
NOT EXISTS ${GFLAGS_INCLUDE_DIR})
endif()
find_library(GFLAGS_LIBRARY NAMES gflags
PATHS ${GFLAGS_LIBRARY_DIR_HINTS}
@@ -484,8 +483,7 @@ if(NOT GFLAGS_FOUND)
gflags_report_not_found(
"Could not find gflags library, set GFLAGS_LIBRARY "
"to full path to libgflags.")
endif(NOT GFLAGS_LIBRARY OR
NOT EXISTS ${GFLAGS_LIBRARY})
endif()
# gflags typically requires a threading library (which is OS dependent), note
# that this defines the CMAKE_THREAD_LIBS_INIT variable. If we are able to
@@ -560,8 +558,7 @@ if(NOT GFLAGS_FOUND)
gflags_report_not_found(
"Caller defined GFLAGS_INCLUDE_DIR:"
" ${GFLAGS_INCLUDE_DIR} does not contain gflags/gflags.h header.")
endif(GFLAGS_INCLUDE_DIR AND
NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
endif()
# TODO: This regex for gflags library is pretty primitive, we use lowercase
# for comparison to handle Windows using CamelCase library names, could
# this check be better?
@@ -571,8 +568,7 @@ if(NOT GFLAGS_FOUND)
gflags_report_not_found(
"Caller defined GFLAGS_LIBRARY: "
"${GFLAGS_LIBRARY} does not match gflags.")
endif(GFLAGS_LIBRARY AND
NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*")
endif()
gflags_reset_find_library_prefix()

View File

@@ -40,7 +40,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(NanoVDB DEFAULT_MSG
IF(NANOVDB_FOUND)
SET(NANOVDB_INCLUDE_DIRS ${NANOVDB_INCLUDE_DIR})
ENDIF(NANOVDB_FOUND)
ENDIF()
MARK_AS_ADVANCED(
NANOVDB_INCLUDE_DIR

View File

@@ -46,7 +46,7 @@ SET(_opencollada_FIND_COMPONENTS
)
# Fedora openCOLLADA package links these statically
# note that order is important here ot it wont link
# note that order is important here or it won't link
SET(_opencollada_FIND_STATIC_COMPONENTS
buffer
ftoa

View File

@@ -44,7 +44,7 @@ SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic" CACHE STRING "Linker flags for p
MARK_AS_ADVANCED(PYTHON_LINKFLAGS)
# if the user passes these defines as args, we dont want to overwrite
# if the user passes these defines as args, we don't want to overwrite
SET(_IS_INC_DEF OFF)
SET(_IS_INC_CONF_DEF OFF)
SET(_IS_LIB_DEF OFF)
@@ -143,7 +143,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
SET(_PYTHON_ABI_FLAGS "${_CURRENT_ABI_FLAGS}")
break()
ELSE()
# ensure we dont find values from 2 different ABI versions
# ensure we don't find values from 2 different ABI versions
IF(NOT _IS_INC_DEF)
UNSET(PYTHON_INCLUDE_DIR CACHE)
ENDIF()

View File

@@ -40,7 +40,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(sse2neon DEFAULT_MSG
IF(SSE2NEON_FOUND)
SET(SSE2NEON_INCLUDE_DIRS ${SSE2NEON_INCLUDE_DIR})
ENDIF(SSE2NEON_FOUND)
ENDIF()
MARK_AS_ADVANCED(
SSE2NEON_INCLUDE_DIR

View File

@@ -305,7 +305,7 @@ def file_check_arg_sizes(tu):
for i, node_child in enumerate(children):
children = list(node_child.get_children())
# skip if we dont have an index...
# skip if we don't have an index...
size_def = args_size_definition.get(i, -1)
if size_def == -1:
@@ -354,7 +354,7 @@ def file_check_arg_sizes(tu):
filepath # always the same but useful when running threaded
))
# we dont really care what we are looking at, just scan entire file for
# we don't really care what we are looking at, just scan entire file for
# function calls.
def recursive_func_call_check(node):

View File

@@ -694,7 +694,7 @@ macro(message_first_run)
endmacro()
# when we have warnings as errors applied globally this
# needs to be removed for some external libs which we dont maintain.
# needs to be removed for some external libs which we don't maintain.
# utility macro
macro(remove_cc_flag
@@ -794,7 +794,7 @@ macro(remove_extra_strict_flags)
endmacro()
# note, we can only append flags on a single file so we need to negate the options.
# at the moment we cant shut up ffmpeg deprecations, so use this, but will
# at the moment we can't shut up ffmpeg deprecations, so use this, but will
# probably add more removals here.
macro(remove_strict_c_flags_file
filenames)
@@ -963,14 +963,6 @@ macro(blender_project_hack_post)
unset(_reset_standard_cflags_rel)
unset(_reset_standard_cxxflags_rel)
# ------------------------------------------------------------------
# workaround for omission in cmake 2.8.4's GNU.cmake, fixed in 2.8.5
if(CMAKE_COMPILER_IS_GNUCC)
if(NOT DARWIN)
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
endif()
endif()
endmacro()
# pair of macros to allow libraries to be specify files to install, but to

View File

@@ -388,6 +388,10 @@ endif()
if(WITH_TBB)
find_package(TBB)
if(NOT TBB_FOUND)
message(WARNING "TBB not found, disabling WITH_TBB")
set(WITH_TBB OFF)
endif()
endif()
if(WITH_POTRACE)

View File

@@ -457,6 +457,10 @@ endif()
if(WITH_TBB)
find_package_wrapper(TBB)
if(NOT TBB_FOUND)
message(WARNING "TBB not found, disabling WITH_TBB")
set(WITH_TBB OFF)
endif()
endif()
if(WITH_XR_OPENXR)

View File

@@ -261,8 +261,10 @@ if(NOT DEFINED LIBDIR)
else()
message(FATAL_ERROR "32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder")
endif()
# Can be 1910..1912
if(MSVC_VERSION GREATER 1919)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30130)
message(STATUS "Visual Studio 2022 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
elseif(MSVC_VERSION GREATER 1919)
message(STATUS "Visual Studio 2019 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
elseif(MSVC_VERSION GREATER 1909)
@@ -548,7 +550,6 @@ if(WITH_OPENIMAGEIO)
set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
set(OPENCOLORIO_DEFINITIONS "-DDOpenColorIO_SKIP_IMPORTS")
set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
add_definitions(-DOIIO_STATIC_DEFINE)
add_definitions(-DOIIO_NO_SSE=1)
@@ -594,7 +595,7 @@ if(WITH_OPENCOLORIO)
debug ${OPENCOLORIO_LIBPATH}/libexpatdMD.lib
debug ${OPENCOLORIO_LIBPATH}/pystring_d.lib
)
set(OPENCOLORIO_DEFINITIONS)
set(OPENCOLORIO_DEFINITIONS "-DOpenColorIO_SKIP_IMPORTS")
endif()
if(WITH_OPENVDB)

View File

@@ -6,6 +6,9 @@ if %ERRORLEVEL% EQU 0 goto DetectionComplete
call "%~dp0\detect_msvc2019.cmd"
if %ERRORLEVEL% EQU 0 goto DetectionComplete
call "%~dp0\detect_msvc2022.cmd"
if %ERRORLEVEL% EQU 0 goto DetectionComplete
echo Compiler Detection failed. Use verbose switch for more information.
exit /b 1

View File

@@ -1,5 +1,6 @@
if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc15
if "%BUILD_VS_YEAR%"=="2019" set BUILD_VS_LIBDIRPOST=vc15
if "%BUILD_VS_YEAR%"=="2022" set BUILD_VS_LIBDIRPOST=vc15
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"

View File

@@ -19,10 +19,10 @@ if "%WITH_PYDEBUG%"=="1" (
set PYDEBUG_CMAKE_ARGS=-DWINDOWS_PYTHON_DEBUG=On
)
if "%BUILD_VS_YEAR%"=="2019" (
set BUILD_PLATFORM_SELECT=-A %MSBUILD_PLATFORM%
) else (
if "%BUILD_VS_YEAR%"=="2017" (
set BUILD_GENERATOR_POST=%WINDOWS_ARCH%
) else (
set BUILD_PLATFORM_SELECT=-A %MSBUILD_PLATFORM%
)
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%BUILD_GENERATOR_POST%" %BUILD_PLATFORM_SELECT% %TESTS_CMAKE_ARGS% %CLANG_CMAKE_ARGS% %ASAN_CMAKE_ARGS% %PYDEBUG_CMAKE_ARGS%

View File

@@ -0,0 +1,3 @@
set BUILD_VS_VER=17
set BUILD_VS_YEAR=2022
call "%~dp0\detect_msvc_vswhere.cmd"

View File

@@ -66,6 +66,14 @@ if NOT "%1" == "" (
) else if "%1" == "2019b" (
set BUILD_VS_YEAR=2019
set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools
) else if "%1" == "2022" (
set BUILD_VS_YEAR=2022
) else if "%1" == "2022pre" (
set BUILD_VS_YEAR=2022
set VSWHERE_ARGS=-prerelease
) else if "%1" == "2022b" (
set BUILD_VS_YEAR=2022
set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools
) else if "%1" == "packagename" (
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
shift /1

View File

@@ -1,2 +1,13 @@
Sphinx==3.5.3
sphinx==3.5.4
# Sphinx dependencies that are important
Jinja2==2.11.3
Pygments==2.9.0
docutils==0.16
snowballstemmer==2.1.0
babel==2.9.1
requests==2.25.1
# Only needed to match the theme used for the official documentation.
# Without this theme, the default theme will be used.
sphinx_rtd_theme==0.5.2

View File

@@ -1,3 +1,3 @@
#define MANTA_GIT_VERSION "commit 9c505cd22e289b98c9aa717efba8ef3201c7e458"
#define MANTA_GIT_VERSION "commit 8fbebe02459b7f72575872c20961f7cb757db408"

View File

@@ -71,6 +71,19 @@ class ParticleBase;
for (int j = bnd; j < (grid).getSizeY() - bnd; ++j) \
for (int i = bnd; i < (grid).getSizeX() - bnd; ++i)
#define FOR_NEIGHBORS_BND(grid, radius, bnd) \
for (int zj = ((grid).is3D() ? std::max(bnd, k - radius) : 0); \
zj <= ((grid).is3D() ? std::min(k + radius, (grid).getSizeZ() - 1 - bnd) : 0); \
zj++) \
for (int yj = std::max(bnd, j - radius); \
yj <= std::min(j + radius, (grid).getSizeY() - 1 - bnd); \
yj++) \
for (int xj = std::max(bnd, i - radius); \
xj <= std::min(i + radius, (grid).getSizeX() - 1 - bnd); \
xj++)
#define FOR_NEIGHBORS(grid, radius) FOR_NEIGHBORS_BND(grid, radius, 0)
//! Basic data structure for kernel data, initialized based on kernel type (e.g. single, idx, etc).
struct KernelBase {
int maxX, maxY, maxZ, minZ, maxT, minT;

View File

@@ -822,33 +822,29 @@ struct ComputeUnionLevelsetPindex : public KernelBase {
{
const Vec3 gridPos = Vec3(i, j, k) + Vec3(0.5); // shifted by half cell
Real phiv = radius * 1.0; // outside
const int r = int(radius) + 1;
int r = int(radius) + 1;
int rZ = phi.is3D() ? r : 0;
for (int zj = k - rZ; zj <= k + rZ; zj++)
for (int yj = j - r; yj <= j + r; yj++)
for (int xj = i - r; xj <= i + r; xj++) {
if (!phi.isInBounds(Vec3i(xj, yj, zj)))
continue;
FOR_NEIGHBORS(phi, r)
{
// note, for the particle indices in indexSys the access is periodic (ie, dont skip for
// eg inBounds(sx,10,10)
IndexInt isysIdxS = index.index(xj, yj, zj);
IndexInt pStart = index(isysIdxS), pEnd = 0;
if (phi.isInBounds(isysIdxS + 1))
pEnd = index(isysIdxS + 1);
else
pEnd = indexSys.size();
// note, for the particle indices in indexSys the access is periodic (ie, dont skip for eg
// inBounds(sx,10,10)
IndexInt isysIdxS = index.index(xj, yj, zj);
IndexInt pStart = index(isysIdxS), pEnd = 0;
if (phi.isInBounds(isysIdxS + 1))
pEnd = index(isysIdxS + 1);
else
pEnd = indexSys.size();
// now loop over particles in cell
for (IndexInt p = pStart; p < pEnd; ++p) {
const int psrc = indexSys[p].sourceIndex;
if (ptype && ((*ptype)[psrc] & exclude))
continue;
const Vec3 pos = parts[psrc].pos;
phiv = std::min(phiv, fabs(norm(gridPos - pos)) - radius);
}
}
// now loop over particles in cell
for (IndexInt p = pStart; p < pEnd; ++p) {
const int psrc = indexSys[p].sourceIndex;
if (ptype && ((*ptype)[psrc] & exclude))
continue;
const Vec3 pos = parts[psrc].pos;
phiv = std::min(phiv, fabs(norm(gridPos - pos)) - radius);
}
}
phi(i, j, k) = phiv;
}
inline const Grid<int> &getArg0()
@@ -1026,39 +1022,35 @@ struct ComputeAveragedLevelsetWeight : public KernelBase {
// loop over neighborhood, similar to ComputeUnionLevelsetPindex
const Real sradiusInv = 1. / (4. * radius * radius);
int r = int(1. * radius) + 1;
int rZ = phi.is3D() ? r : 0;
const int r = int(radius) + 1;
// accumulators
Real wacc = 0.;
Vec3 pacc = Vec3(0.);
Real racc = 0.;
for (int zj = k - rZ; zj <= k + rZ; zj++)
for (int yj = j - r; yj <= j + r; yj++)
for (int xj = i - r; xj <= i + r; xj++) {
if (!phi.isInBounds(Vec3i(xj, yj, zj)))
continue;
FOR_NEIGHBORS(phi, r)
{
IndexInt isysIdxS = index.index(xj, yj, zj);
IndexInt pStart = index(isysIdxS), pEnd = 0;
if (phi.isInBounds(isysIdxS + 1))
pEnd = index(isysIdxS + 1);
else
pEnd = indexSys.size();
for (IndexInt p = pStart; p < pEnd; ++p) {
IndexInt psrc = indexSys[p].sourceIndex;
if (ptype && ((*ptype)[psrc] & exclude))
continue;
IndexInt isysIdxS = index.index(xj, yj, zj);
IndexInt pStart = index(isysIdxS), pEnd = 0;
if (phi.isInBounds(isysIdxS + 1))
pEnd = index(isysIdxS + 1);
else
pEnd = indexSys.size();
for (IndexInt p = pStart; p < pEnd; ++p) {
IndexInt psrc = indexSys[p].sourceIndex;
if (ptype && ((*ptype)[psrc] & exclude))
continue;
Vec3 pos = parts[psrc].pos;
Real s = normSquare(gridPos - pos) * sradiusInv;
// Real w = std::max(0., cubed(1.-s) );
Real w = std::max(0., (1. - s)); // a bit smoother
wacc += w;
racc += radius * w;
pacc += pos * w;
}
}
Vec3 pos = parts[psrc].pos;
Real s = normSquare(gridPos - pos) * sradiusInv;
// Real w = std::max(0., cubed(1.-s) );
Real w = std::max(0., (1. - s)); // a bit smoother
wacc += w;
racc += radius * w;
pacc += pos * w;
}
}
if (wacc > VECTOR_EPSILON) {
racc /= wacc;

View File

@@ -234,10 +234,10 @@ void subdivideMesh(
normalize(ne2);
// Real thisArea = sqrMag(cross(-e2,e0));
// small angle approximation says sin(x) = arcsin(x) = x,
// arccos(x) = pi/2 - arcsin(x),
// cos(x) = dot(A,B),
// so angle is approximately 1 - dot(A,B).
// small angle approximation says sin(x) = arcsin(x) = x,
// arccos(x) = pi/2 - arcsin(x),
// cos(x) = dot(A,B),
// so angle is approximately 1 - dot(A,B).
Real angle[3];
angle[0] = 1.0 - dot(ne0, -ne2);
angle[1] = 1.0 - dot(ne1, -ne0);

View File

@@ -2287,10 +2287,9 @@ struct knFlipComputePotentialTrappedAir : public KernelBase {
const Vec3 &vj = scaleFromManta * v.getCentered(x, y, z);
const Vec3 xij = xi - xj;
const Vec3 vij = vi - vj;
Real h = !pot.is3D() ?
1.414 * radius :
1.732 * radius; // estimate sqrt(2)*radius resp. sqrt(3)*radius for h, due
// to squared resp. cubic neighbor area
Real h = !pot.is3D() ? 1.414 * radius :
1.732 * radius; // estimate sqrt(2)*radius resp. sqrt(3)*radius
// for h, due to squared resp. cubic neighbor area
vdiff += norm(vij) * (1 - dot(getNormalized(vij), getNormalized(xij))) *
(1 - norm(xij) / h);
}

View File

@@ -79,15 +79,15 @@ typedef struct CLG_IDFilter {
} CLG_IDFilter;
typedef struct CLogContext {
/** Single linked list of types. */
/** Single linked list of types. */
CLG_LogType *types;
/** Single linked list of references. */
/** Single linked list of references. */
CLG_LogRef *refs;
#ifdef WITH_CLOG_PTHREADS
pthread_mutex_t types_lock;
#endif
/* exclude, include filters. */
/* exclude, include filters. */
CLG_IDFilter *filters[2];
bool use_color;
bool use_basename;

View File

@@ -51,12 +51,12 @@ CCL_NAMESPACE_BEGIN
/* XML reading state */
struct XMLReadState : public XMLReader {
Scene *scene; /* scene pointer */
Transform tfm; /* current transform state */
bool smooth; /* smooth normal state */
Shader *shader; /* current shader */
string base; /* base path to current file*/
float dicing_rate; /* current dicing rate */
Scene *scene; /* Scene pointer. */
Transform tfm; /* Current transform state. */
bool smooth; /* Smooth normal state. */
Shader *shader; /* Current shader. */
string base; /* Base path to current file. */
float dicing_rate; /* Current dicing rate. */
XMLReadState() : scene(NULL), smooth(false), shader(NULL), dicing_rate(1.0f)
{
@@ -385,7 +385,7 @@ static Mesh *xml_add_mesh(Scene *scene, const Transform &tfm)
Mesh *mesh = new Mesh();
scene->geometry.push_back(mesh);
/* create object*/
/* Create object. */
Object *object = new Object();
object->set_geometry(mesh);
object->set_tfm(tfm);

View File

@@ -821,6 +821,11 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_strand", text="Hair")
col.prop(view_layer, "use_volumes", text="Volumes")
col = layout.column(heading="Use")
sub = col.row()
sub.prop(view_layer, "use_motion_blur", text="Motion Blur")
sub.active = rd.use_motion_blur
class CYCLES_RENDER_PT_override(CyclesButtonsPanel, Panel):
bl_label = "Override"

View File

@@ -533,7 +533,7 @@ void BlenderSync::sync_particle_hair(
return;
}
/* extract particle hair data - should be combined with connecting to mesh later*/
/* Extract particle hair data - should be combined with connecting to mesh later. */
ParticleCurveData CData;

View File

@@ -34,12 +34,17 @@ void BlenderSync::sync_light(BL::Object &b_parent,
bool *use_portal)
{
/* test if we need to sync */
Light *light;
ObjectKey key(b_parent, persistent_id, b_ob_instance, false);
BL::Light b_light(b_ob.data());
Light *light = light_map.find(key);
/* Check if the transform was modified, in case a linked collection is moved we do not get a
* specific depsgraph update (T88515). This also mimics the behavior for Objects. */
const bool tfm_updated = (light && light->get_tfm() != tfm);
/* Update if either object or light data changed. */
if (!light_map.add_or_update(&light, b_ob, b_parent, key)) {
if (!light_map.add_or_update(&light, b_ob, b_parent, key) && !tfm_updated) {
Shader *shader;
if (!shader_map.add_or_update(&shader, b_light)) {
if (light->get_is_portal())

View File

@@ -289,11 +289,10 @@ static PyObject *render_func(PyObject * /*self*/, PyObject *args)
RNA_pointer_create(NULL, &RNA_Depsgraph, (ID *)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
BL::Depsgraph b_depsgraph(depsgraphptr);
/* Allow Blender to execute other Python scripts, and isolate TBB tasks so we
* don't get deadlocks with Blender threads accessing shared data like images. */
/* Allow Blender to execute other Python scripts. */
python_thread_state_save(&session->python_thread_state);
tbb::this_task_arena::isolate([&] { session->render(b_depsgraph); });
session->render(b_depsgraph);
python_thread_state_restore(&session->python_thread_state);
@@ -330,8 +329,7 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
python_thread_state_save(&session->python_thread_state);
tbb::this_task_arena::isolate(
[&] { session->bake(b_depsgraph, b_object, pass_type, pass_filter, width, height); });
session->bake(b_depsgraph, b_object, pass_type, pass_filter, width, height);
python_thread_state_restore(&session->python_thread_state);
@@ -377,7 +375,7 @@ static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
python_thread_state_save(&session->python_thread_state);
tbb::this_task_arena::isolate([&] { session->reset_session(b_data, b_depsgraph); });
session->reset_session(b_data, b_depsgraph);
python_thread_state_restore(&session->python_thread_state);
@@ -399,7 +397,7 @@ static PyObject *sync_func(PyObject * /*self*/, PyObject *args)
python_thread_state_save(&session->python_thread_state);
tbb::this_task_arena::isolate([&] { session->synchronize(b_depsgraph); });
session->synchronize(b_depsgraph);
python_thread_state_restore(&session->python_thread_state);

View File

@@ -281,7 +281,6 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
void BlenderSync::sync_integrator()
{
BL::RenderSettings r = b_scene.render();
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
experimental = (get_enum(cscene, "feature_set") != 0);
@@ -325,7 +324,7 @@ void BlenderSync::sync_integrator()
integrator->set_sample_clamp_direct(get_float(cscene, "sample_clamp_direct"));
integrator->set_sample_clamp_indirect(get_float(cscene, "sample_clamp_indirect"));
if (!preview) {
integrator->set_motion_blur(r.use_motion_blur());
integrator->set_motion_blur(view_layer.use_motion_blur);
}
integrator->set_method((Integrator::Method)get_enum(
@@ -456,6 +455,8 @@ void BlenderSync::sync_view_layer(BL::ViewLayer &b_view_layer)
view_layer.use_surfaces = b_view_layer.use_solid() || scene->bake_manager->get_baking();
view_layer.use_hair = b_view_layer.use_strand();
view_layer.use_volumes = b_view_layer.use_volumes();
view_layer.use_motion_blur = b_view_layer.use_motion_blur() &&
b_scene.render().use_motion_blur();
/* Material override. */
view_layer.material_override = b_view_layer.material_override();
@@ -602,7 +603,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::Scene &b_scene,
for (BL::RenderPass &b_pass : b_rlay.passes) {
PassType pass_type = get_pass_type(b_pass);
if (pass_type == PASS_MOTION && b_scene.render().use_motion_blur())
if (pass_type == PASS_MOTION && view_layer.use_motion_blur)
continue;
if (pass_type != PASS_NONE)
Pass::add(pass_type, passes, b_pass.name().c_str());

View File

@@ -246,6 +246,7 @@ class BlenderSync {
use_surfaces(true),
use_hair(true),
use_volumes(true),
use_motion_blur(true),
samples(0),
bound_samples(false)
{
@@ -258,6 +259,7 @@ class BlenderSync {
bool use_surfaces;
bool use_hair;
bool use_volumes;
bool use_motion_blur;
int samples;
bool bound_samples;
} view_layer;

View File

@@ -181,7 +181,7 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args)
/* record intersection */
ctx->local_isect->hits[hit_idx] = current_isect;
ctx->local_isect->Ng[hit_idx] = normalize(make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z));
/* This tells Embree to continue tracing .*/
/* This tells Embree to continue tracing. */
*args->valid = 0;
break;
}

View File

@@ -179,7 +179,7 @@ class InnerNode : public BVHNode {
}
/* NOTE: This function is only used during binary BVH builder, and it
* supposed to be configured to have 2 children which will be filled in in a
* supposed to be configured to have 2 children which will be filled-in in a
* bit. But this is important to have children reset to NULL. */
explicit InnerNode(const BoundBox &bounds) : BVHNode(bounds), num_children_(0)
{

View File

@@ -297,7 +297,7 @@ struct BVHSpatialBin {
*/
struct BVHSpatialStorage {
/* Accumulated bounds when sweeping from right to left. */
/* Accumulated bounds when sweeping from right to left. */
vector<BoundBox> right_bounds;
/* Bins used for histogram when selecting best split plane. */

View File

@@ -388,7 +388,7 @@ void BVHSpatialSplit::split_curve_primitive(const Hair *hair,
BoundBox &left_bounds,
BoundBox &right_bounds)
{
/* curve split: NOTE - Currently ignores curve width and needs to be fixed.*/
/* curve split: NOTE - Currently ignores curve width and needs to be fixed. */
Hair::Curve curve = hair->get_curve(prim_index);
const int k0 = curve.first_key + segment_index;
const int k1 = k0 + 1;

View File

@@ -1196,16 +1196,18 @@ class OptiXDevice : public CUDADevice {
const CUDAContextScope scope(cuContext);
const bool use_fast_trace_bvh = (bvh->params.bvh_type == SceneParams::BVH_STATIC);
// Compute memory usage
OptixAccelBufferSizes sizes = {};
OptixAccelBuildOptions options = {};
options.operation = operation;
if (background) {
// Prefer best performance and lowest memory consumption in background
if (use_fast_trace_bvh) {
VLOG(2) << "Using fast to trace OptiX BVH";
options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE | OPTIX_BUILD_FLAG_ALLOW_COMPACTION;
}
else {
// Prefer fast updates in viewport
VLOG(2) << "Using fast to update OptiX BVH";
options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_BUILD | OPTIX_BUILD_FLAG_ALLOW_UPDATE;
}
@@ -1253,15 +1255,16 @@ class OptiXDevice : public CUDADevice {
out_data.device_pointer,
sizes.outputSizeInBytes,
&out_handle,
background ? &compacted_size_prop : NULL,
background ? 1 : 0));
use_fast_trace_bvh ? &compacted_size_prop : NULL,
use_fast_trace_bvh ? 1 : 0));
bvh->traversable_handle = static_cast<uint64_t>(out_handle);
// Wait for all operations to finish
check_result_cuda_ret(cuStreamSynchronize(NULL));
// Compact acceleration structure to save memory (do not do this in viewport for faster builds)
if (background) {
// Compact acceleration structure to save memory (only if using fast trace as the
// OPTIX_BUILD_FLAG_ALLOW_COMPACTION flag is only set in this case).
if (use_fast_trace_bvh) {
uint64_t compacted_size = sizes.outputSizeInBytes;
check_result_cuda_ret(
cuMemcpyDtoH(&compacted_size, compacted_size_prop.result, sizeof(compacted_size)));
@@ -1306,6 +1309,8 @@ class OptiXDevice : public CUDADevice {
return;
}
const bool use_fast_trace_bvh = (bvh->params.bvh_type == SceneParams::BVH_STATIC);
free_bvh_memory_delayed();
BVHOptiX *const bvh_optix = static_cast<BVHOptiX *>(bvh);
@@ -1315,10 +1320,10 @@ class OptiXDevice : public CUDADevice {
if (!bvh->params.top_level) {
assert(bvh->objects.size() == 1 && bvh->geometry.size() == 1);
// Refit is only possible in viewport for now (because AS is built with
// OPTIX_BUILD_FLAG_ALLOW_UPDATE only there, see above)
OptixBuildOperation operation = OPTIX_BUILD_OPERATION_BUILD;
if (refit && !background) {
/* Refit is only possible when using fast to trace BVH (because AS is built with
* OPTIX_BUILD_FLAG_ALLOW_UPDATE only there, see above). */
if (refit && !use_fast_trace_bvh) {
assert(bvh_optix->traversable_handle != 0);
operation = OPTIX_BUILD_OPERATION_UPDATE;
}

View File

@@ -65,7 +65,7 @@ class DenoiseParams {
/* Viewport start sample. */
int start_sample;
/** Native Denoiser **/
/** Native Denoiser. */
/* Pixel radius for neighboring pixels to take into account. */
int radius;
@@ -81,7 +81,7 @@ class DenoiseParams {
/* Clamp the input to the range of +-1e8. Should be enough for any legitimate data. */
bool clamp_input;
/** OIDN/Optix Denoiser **/
/** OIDN/Optix Denoiser. */
/* Passes handed over to the OIDN/OptiX denoiser (default to color + albedo). */
DenoiserInput input_passes;

View File

@@ -1186,7 +1186,7 @@ bool OpenCLInfo::get_device_extensions(cl_device_id device_id,
{
size_t extension_length = 0;
cl_int err;
/* Determine the size of the extension string*/
/* Determine the size of the extension string. */
if ((err = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, 0, 0, &extension_length)) !=
CL_SUCCESS) {
if (error != NULL) {

View File

@@ -116,7 +116,7 @@ CCL_NAMESPACE_BEGIN
# endif
# endif /* __SHADOW_RECORD_ALL__ */
/* Record all intersections - Volume BVH traversal */
/* Record all intersections - Volume BVH traversal. */
# if defined(__VOLUME_RECORD_ALL__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_all

View File

@@ -61,8 +61,8 @@ ccl_device_forceinline float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderCl
const MicrofacetBsdf *bsdf = (const MicrofacetBsdf *)sc;
float3 N = bsdf->N;
float NdotI = dot(N, I); /* in Cycles/OSL convention I is omega_out */
float NdotO = dot(N, omega_in); /* and consequently we use for O omaga_in ;) */
float NdotI = dot(N, I); /* in Cycles/OSL convention I is omega_out */
float NdotO = dot(N, omega_in); /* and consequently we use for O omaga_in ;) */
float out = 0.0f;

View File

@@ -66,7 +66,7 @@ ccl_device_noinline void motion_triangle_shader_setup(
sd->P = motion_triangle_refine_local(kg, sd, isect, ray, verts);
}
else
#endif /* __BVH_LOCAL__*/
#endif /* __BVH_LOCAL__*/
{
sd->P = motion_triangle_refine(kg, sd, isect, ray, verts);
}

View File

@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN
/* normal on triangle */
/* Normal on triangle. */
ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
{
/* load triangle vertices */
@@ -40,7 +40,7 @@ ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
}
}
/* point and normal on triangle */
/* Point and normal on triangle. */
ccl_device_inline void triangle_point_normal(
KernelGlobals *kg, int object, int prim, float u, float v, float3 *P, float3 *Ng, int *shader)
{

View File

@@ -64,7 +64,7 @@ typedef struct KernelGlobals {
OSLThreadData *osl_tdata;
# endif
/* **** Run-time data **** */
/* **** Run-time data **** */
/* Heap-allocated storage for transparent shadows intersections. */
Intersection *transparent_shadow_intersections;

View File

@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
/* Spherical coordinates <-> Cartesian direction */
/* Spherical coordinates <-> Cartesian direction. */
ccl_device float2 direction_to_spherical(float3 dir)
{

View File

@@ -79,7 +79,7 @@ ccl_device void enqueue_ray_index_local(
{
int lidx = ccl_local_id(1) * ccl_local_size(0) + ccl_local_id(0);
/* Get local queue id .*/
/* Get local queue id. */
unsigned int lqidx;
if (enqueue_flag) {
lqidx = atomic_fetch_and_inc_uint32(local_queue_atomics);

View File

@@ -274,7 +274,7 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
/* primitive */
sd->object = object;
sd->lamp = LAMP_NONE;
/* currently no access to bvh prim index for strand sd->prim*/
/* Currently no access to bvh prim index for strand sd->prim. */
sd->prim = prim;
sd->u = u;
sd->v = v;

View File

@@ -409,7 +409,7 @@ ccl_device void subsurface_random_walk_coefficients(const ShaderClosure *sc,
ccl_device_forceinline float eval_phase_dwivedi(float v, float phase_log, float cos_theta)
{
/* Eq. 9 from [2] using precomputed log((v + 1) / (v - 1))*/
/* Eq. 9 from [2] using precomputed log((v + 1) / (v - 1)) */
return 1.0f / ((v - cos_theta) * phase_log);
}

View File

@@ -302,7 +302,7 @@ enum PathRayFlag {
PATH_RAY_DIFFUSE_ANCESTOR = (1 << 15),
/* Single pass has been written. */
PATH_RAY_SINGLE_PASS_DONE = (1 << 16),
/* Ray is behind a shadow catcher .*/
/* Ray is behind a shadow catcher. */
PATH_RAY_SHADOW_CATCHER = (1 << 17),
/* Store shadow data for shadow catcher or denoising. */
PATH_RAY_STORE_SHADOW_INFO = (1 << 18),

View File

@@ -317,4 +317,4 @@ class OSLRenderServices : public OSL::RendererServices {
CCL_NAMESPACE_END
#endif /* __OSL_SERVICES_H__ */
#endif /* __OSL_SERVICES_H__ */

View File

@@ -49,7 +49,7 @@ void OSLShader::thread_init(KernelGlobals *kg,
return;
}
/* per thread kernel data init*/
/* Per thread kernel data init. */
kg->osl = osl_globals;
OSL::ShadingSystem *ss = kg->osl->ss;

View File

@@ -68,7 +68,7 @@ typedef ccl_global struct SplitBranchedState {
uint lcg_state;
LocalIntersection ss_isect;
# endif /*__SUBSURFACE__ */
# endif /* __SUBSURFACE__ */
int shared_sample_count; /* number of branched samples shared with other threads */
int original_ray; /* index of original ray when sharing branched samples */

View File

@@ -803,7 +803,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg,
float melanin_redness = stack_load_float_default(
stack, melanin_redness_ofs, data_node2.w);
/* Randomize melanin. */
/* Randomize melanin. */
float random_color = stack_load_float_default(stack, random_color_ofs, data_node3.z);
random_color = clamp(random_color, 0.0f, 1.0f);
float factor_random_color = 1.0f + 2.0f * (random - 0.5f) * random_color;

View File

@@ -220,11 +220,13 @@ ccl_device void svm_node_hair_info(
stack_store_float(stack, out_offset, data);
break;
}
/*case NODE_INFO_CURVE_FADE: {
# if 0
case NODE_INFO_CURVE_FADE: {
data = sd->curve_transparency;
stack_store_float(stack, out_offset, data);
break;
}*/
}
# endif
case NODE_INFO_CURVE_TANGENT_NORMAL: {
data3 = curve_tangent_normal(kg, sd);
stack_store_float3(stack, out_offset, data3);

View File

@@ -182,7 +182,7 @@ ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float
}
}
else {
/* Desperate mode, no valid choice anyway, fallback to one side.*/
/* Desperate mode, no valid choice anyway, fallback to one side. */
weight.x = 1.0f;
}

View File

@@ -333,7 +333,7 @@ static M44d get_interpolated_matrix_for_time(const MatrixSampleMap &samples, chr
chrono_t t = (time - prev_time) / (next_time - prev_time);
/* ensure rotation around the shortest angle */
/* Ensure rotation around the shortest angle. */
if ((prev_rotation ^ next_rotation) < 0) {
next_rotation = -next_rotation;
}

View File

@@ -736,13 +736,14 @@ static void process_uvs(CachedData &cache,
const IV2fGeomParam::Sample &sample,
double time)
{
if (scope != kFacevaryingScope) {
if (scope != kFacevaryingScope && scope != kVaryingScope && scope != kVertexScope) {
return;
}
const array<int> *uv_loops = cache.uv_loops.data_for_time_no_check(time).get_data_or_null();
if (!uv_loops) {
/* It's ok to not have loop indices, as long as the scope is not face-varying. */
if (!uv_loops && scope == kFacevaryingScope) {
return;
}
@@ -766,9 +767,27 @@ static void process_uvs(CachedData &cache,
const uint32_t *indices = sample.getIndices()->get();
const V2f *values = sample.getVals()->get();
for (const int uv_loop_index : *uv_loops) {
const uint32_t index = indices[uv_loop_index];
*data_float2++ = make_float2(values[index][0], values[index][1]);
if (scope == kFacevaryingScope) {
for (const int uv_loop_index : *uv_loops) {
const uint32_t index = indices[uv_loop_index];
*data_float2++ = make_float2(values[index][0], values[index][1]);
}
}
else if (scope == kVaryingScope || scope == kVertexScope) {
if (triangles) {
for (size_t i = 0; i < triangles->size(); i++) {
const int3 t = (*triangles)[i];
*data_float2++ = make_float2(values[t.x][0], values[t.x][1]);
*data_float2++ = make_float2(values[t.y][0], values[t.y][1]);
*data_float2++ = make_float2(values[t.z][0], values[t.z][1]);
}
}
else if (corners) {
for (size_t i = 0; i < corners->size(); i++) {
const int c = (*corners)[i];
*data_float2++ = make_float2(values[c][0], values[c][1]);
}
}
}
attribute.data.add_data(data, time);

View File

@@ -676,8 +676,8 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom,
Mesh *mesh = static_cast<Mesh *>(geom);
if (mesh->subdivision_type == Mesh::SUBDIVISION_CATMULL_CLARK &&
desc.flags & ATTR_SUBDIVIDED) {
/* indices for subdivided attributes are retrieved
* from patch table so no need for correction here*/
/* Indices for subdivided attributes are retrieved
* from patch table so no need for correction here. */
}
else if (element == ATTR_ELEMENT_VERTEX)
offset -= mesh->vert_offset;

View File

@@ -4374,7 +4374,7 @@ NODE_DEFINE(HairInfoNode)
SOCKET_OUT_FLOAT(intercept, "Intercept");
SOCKET_OUT_FLOAT(thickness, "Thickness");
SOCKET_OUT_NORMAL(tangent_normal, "Tangent Normal");
#if 0 /*output for minimum hair width transparency - deactivated */
#if 0 /* Output for minimum hair width transparency - deactivated. */
SOCKET_OUT_FLOAT(fade, "Fade");
#endif
SOCKET_OUT_FLOAT(index, "Random");
@@ -4425,12 +4425,12 @@ void HairInfoNode::compile(SVMCompiler &compiler)
if (!out->links.empty()) {
compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_TANGENT_NORMAL, compiler.stack_assign(out));
}
/*out = output("Fade");
#if 0
out = output("Fade");
if(!out->links.empty()) {
compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_FADE, compiler.stack_assign(out));
}*/
}
#endif
out = output("Random");
if (!out->links.empty()) {
int attr = compiler.attribute(ATTR_STD_CURVE_RANDOM);

View File

@@ -195,4 +195,4 @@ class OSLCompiler {
CCL_NAMESPACE_END
#endif /* __OSL_H__ */
#endif /* __OSL_H__ */

View File

@@ -1252,7 +1252,7 @@ bool Session::update_progressive_refine(bool cancel)
double current_time = time_dt();
if (current_time - last_update_time < params.progressive_update_timeout) {
/* if last sample was processed, we need to write buffers anyway */
/* If last sample was processed, we need to write buffers anyway. */
if (!write && sample != 1)
return false;
}

View File

@@ -15,7 +15,7 @@
if(WITH_GTESTS)
Include(GTestTesting)
# Otherwise we get warnings here that we cant fix in external projects
# Otherwise we get warnings here that we can't fix in external projects
remove_strict_flags()
endif()

View File

@@ -223,12 +223,14 @@ ccl_device_inline ssef fastpow24(const ssef &arg)
ssef x = fastpow<0x3F4CCCCD, 0x4F55A7FB>(arg); // error max = 0.17 avg = 0.0018 |avg| = 0.05
ssef arg2 = arg * arg;
ssef arg4 = arg2 * arg2;
x = improve_5throot_solution(x,
arg4); /* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
x = improve_5throot_solution(x,
arg4); /* error max = 0.00021 avg = 1.6e-05 |avg| = 1.6e-05 */
x = improve_5throot_solution(x,
arg4); /* error max = 6.1e-07 avg = 5.2e-08 |avg| = 1.1e-07 */
/* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
x = improve_5throot_solution(x, arg4);
/* error max = 0.00021 avg = 1.6e-05 |avg| = 1.6e-05 */
x = improve_5throot_solution(x, arg4);
/* error max = 6.1e-07 avg = 5.2e-08 |avg| = 1.1e-07 */
x = improve_5throot_solution(x, arg4);
return x * (x * x);
}

View File

@@ -129,7 +129,7 @@ class DebugFlags {
DEVICE_NONE,
/* All OpenCL devices will be used. */
DEVICE_ALL,
/* Default system OpenCL device will be used. */
/* Default system OpenCL device will be used. */
DEVICE_DEFAULT,
/* Host processor will be used. */
DEVICE_CPU,

View File

@@ -243,7 +243,7 @@ ccl_device float fast_sinpif(float x)
const float P = 3.584135056f; /* P = 16-4*Q */
return y * (Q + P * fabsf(y));
/* The original article used used inferior constants for Q and P and
/* The original article used inferior constants for Q and P and
* so had max error 1.091e-3.
*
* The optimal value for Q was determined by exhaustive search, minimizing

View File

@@ -282,8 +282,8 @@ static CPUCapabilities &system_cpu_capabilities()
/* actual opcode for xgetbv */
__asm__(".byte 0x0f, 0x01, 0xd0" : "=a"(xcr_feature_mask), "=d"(edx) : "c"(0));
# elif defined(_MSC_VER) && defined(_XCR_XFEATURE_ENABLED_MASK)
xcr_feature_mask = (uint32_t)_xgetbv(
_XCR_XFEATURE_ENABLED_MASK); /* min VS2010 SP1 compiler is required */
/* Minimum VS2010 SP1 compiler is required. */
xcr_feature_mask = (uint32_t)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
# else
xcr_feature_mask = 0;
# endif

View File

@@ -68,7 +68,7 @@ class TaskPool {
/* ** Statistics ** */
/* Time time stamp of first task pushed. */
/* Time stamp of first task pushed. */
double start_time;
/* Number of all tasks pushed to the pool. Cleared after wait_work() and cancel(). */
@@ -88,7 +88,7 @@ class TaskScheduler {
/* Approximate number of threads that will work on task, which may be lower
* or higher than the actual number of threads. Use as little as possible and
* leave splitting up tasks to the scheduler.. */
* leave splitting up tasks to the scheduler. */
static int num_threads();
protected:

View File

@@ -93,42 +93,23 @@ void my_guess_pkt_duration(AVFormatContext *s, AVStream *st, AVPacket *pkt)
#endif
FFMPEG_INLINE
void my_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
int64_t timestamp_from_pts_or_dts(int64_t pts, int64_t dts)
{
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
st->cur_dts = av_rescale(timestamp,
st->time_base.den * (int64_t)ref_st->time_base.num,
st->time_base.num * (int64_t)ref_st->time_base.den);
}
}
FFMPEG_INLINE
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
{
my_update_cur_dts(s, ref_st, timestamp);
}
FFMPEG_INLINE
int64_t av_get_pts_from_frame(AVFormatContext *avctx, AVFrame *picture)
{
int64_t pts;
pts = picture->pts;
/* Some videos do not have any pts values, use dts instead in those cases if
* possible. Usually when this happens dts can act as pts because as all frames
* should then be presented in their decoded in order. IE pts == dts. */
if (pts == AV_NOPTS_VALUE) {
pts = picture->pkt_dts;
return dts;
}
if (pts == AV_NOPTS_VALUE) {
pts = 0;
}
(void)avctx;
return pts;
}
FFMPEG_INLINE
int64_t av_get_pts_from_frame(AVFrame *picture)
{
return timestamp_from_pts_or_dts(picture->pts, picture->pkt_dts);
}
/* -------------------------------------------------------------------- */
/** \name Deinterlace code block
*

View File

@@ -370,6 +370,7 @@ elseif(WIN32)
intern/GHOST_DropTargetWin32.cpp
intern/GHOST_SystemWin32.cpp
intern/GHOST_WindowWin32.cpp
intern/GHOST_Wintab.cpp
intern/GHOST_ContextD3D.h
intern/GHOST_DisplayManagerWin32.h
@@ -377,6 +378,7 @@ elseif(WIN32)
intern/GHOST_SystemWin32.h
intern/GHOST_TaskbarWin32.h
intern/GHOST_WindowWin32.h
intern/GHOST_Wintab.h
)
if(NOT WITH_GL_EGL)
@@ -481,10 +483,17 @@ if(WITH_XR_OPENXR)
shlwapi
)
elseif(UNIX AND NOT APPLE)
list(APPEND XR_PLATFORM_DEFINES
-DXR_OS_LINUX
-DXR_USE_PLATFORM_XLIB
)
list(APPEND XR_PLATFORM_DEFINES -DXR_OS_LINUX)
if (WITH_GHOST_WAYLAND)
list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_WAYLAND)
endif()
if (WITH_GHOST_X11)
if (WITH_GL_EGL)
list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_EGL)
else()
list(APPEND XR_PLATFORM_DEFINES -DXR_USE_PLATFORM_XLIB)
endif()
endif()
endif()
add_definitions(-DWITH_XR_OPENXR ${XR_PLATFORM_DEFINES})

View File

@@ -95,7 +95,7 @@ class GHOST_ISystemPaths {
virtual void addToSystemRecentFiles(const char *filename) const = 0;
private:
/** The one and only system paths*/
/** The one and only system paths. */
static GHOST_ISystemPaths *m_systemPaths;
#ifdef WITH_CXX_GUARDEDALLOC

View File

@@ -105,7 +105,9 @@ typedef enum {
typedef enum {
GHOST_kTabletAutomatic = 0,
GHOST_kTabletNative,
/* Show as Windows Ink to users to match "Use Windows Ink" in tablet utilities,
* but we use the dependent Windows Pointer API. */
GHOST_kTabletWinPointer,
GHOST_kTabletWintab,
} GHOST_TTabletAPI;
@@ -168,7 +170,7 @@ typedef enum {
GHOST_kButtonMaskRight,
GHOST_kButtonMaskButton4,
GHOST_kButtonMaskButton5,
/* Trackballs and programmable buttons */
/* Trackballs and programmable buttons. */
GHOST_kButtonMaskButton6,
GHOST_kButtonMaskButton7,
GHOST_kButtonNumMasks
@@ -177,15 +179,15 @@ typedef enum {
typedef enum {
GHOST_kEventUnknown = 0,
GHOST_kEventCursorMove, /// Mouse move event
GHOST_kEventButtonDown, /// Mouse button event
GHOST_kEventButtonUp, /// Mouse button event
GHOST_kEventWheel, /// Mouse wheel event
GHOST_kEventTrackpad, /// Trackpad event
GHOST_kEventCursorMove, /* Mouse move event. */
GHOST_kEventButtonDown, /* Mouse button event. */
GHOST_kEventButtonUp, /* Mouse button event. */
GHOST_kEventWheel, /* Mouse wheel event. */
GHOST_kEventTrackpad, /* Trackpad event. */
#ifdef WITH_INPUT_NDOF
GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
GHOST_kEventNDOFButton, /// N degree of freedom device button event
GHOST_kEventNDOFMotion, /* N degree of freedom device motion event. */
GHOST_kEventNDOFButton, /* N degree of freedom device button event. */
#endif
GHOST_kEventKeyDown,
@@ -207,8 +209,8 @@ typedef enum {
GHOST_kEventDraggingExited,
GHOST_kEventDraggingDropDone,
GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup
GHOST_kEventNativeResolutionChange, // Needed for Cocoa when window moves to other display
GHOST_kEventOpenMainFile, /* Needed for Cocoa to open double-clicked .blend file at startup. */
GHOST_kEventNativeResolutionChange, /* Needed for Cocoa when window moves to other display. */
GHOST_kEventTimer,
@@ -281,7 +283,7 @@ typedef enum {
GHOST_kKeyPeriod = '.',
GHOST_kKeySlash = '/',
// Number keys
/* Number keys. */
GHOST_kKey0 = '0',
GHOST_kKey1,
GHOST_kKey2,
@@ -296,7 +298,7 @@ typedef enum {
GHOST_kKeySemicolon = ';',
GHOST_kKeyEqual = '=',
// Character keys
/* Character keys. */
GHOST_kKeyA = 'A',
GHOST_kKeyB,
GHOST_kKeyC,
@@ -335,9 +337,9 @@ typedef enum {
GHOST_kKeyRightControl,
GHOST_kKeyLeftAlt,
GHOST_kKeyRightAlt,
GHOST_kKeyOS, // Command key on Apple, Windows key(s) on Windows
GHOST_kKeyGrLess, // German PC only!
GHOST_kKeyApp, /* Also known as menu key. */
GHOST_kKeyOS, /* Command key on Apple, Windows key(s) on Windows. */
GHOST_kKeyGrLess, /* German PC only! */
GHOST_kKeyApp, /* Also known as menu key. */
GHOST_kKeyCapsLock,
GHOST_kKeyNumLock,
@@ -358,7 +360,7 @@ typedef enum {
GHOST_kKeyUpPage,
GHOST_kKeyDownPage,
// Numpad keys
/* Numpad keys. */
GHOST_kKeyNumpad0,
GHOST_kKeyNumpad1,
GHOST_kKeyNumpad2,
@@ -376,7 +378,7 @@ typedef enum {
GHOST_kKeyNumpadAsterisk,
GHOST_kKeyNumpadSlash,
// Function keys
/* Function keys. */
GHOST_kKeyF1,
GHOST_kKeyF2,
GHOST_kKeyF3,
@@ -402,7 +404,7 @@ typedef enum {
GHOST_kKeyF23,
GHOST_kKeyF24,
// Multimedia keypad buttons
/* Multimedia keypad buttons. */
GHOST_kKeyMediaPlay,
GHOST_kKeyMediaStop,
GHOST_kKeyMediaFirst,
@@ -479,9 +481,9 @@ typedef struct {
typedef enum {
GHOST_kDragnDropTypeUnknown = 0,
GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */
GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */
GHOST_kDragnDropTypeBitmap /*Bitmap image data */
GHOST_kDragnDropTypeFilenames, /* Array of strings representing file names (full path). */
GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string. */
GHOST_kDragnDropTypeBitmap /* Bitmap image data. */
} GHOST_TDragnDropTypes;
typedef struct {
@@ -527,18 +529,23 @@ typedef enum {
#ifdef WITH_INPUT_NDOF
typedef struct {
/** N-degree of freedom device data v3 [GSoC 2010] */
// Each component normally ranges from -1 to +1, but can exceed that.
// These use blender standard view coordinates, with positive rotations being CCW about the axis.
float tx, ty, tz; // translation
float rx, ry, rz; // rotation:
// axis = (rx,ry,rz).normalized
// amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg]
float dt; // time since previous NDOF Motion event
GHOST_TProgress progress; // Starting, InProgress or Finishing (for modal handlers)
/* Each component normally ranges from -1 to +1, but can exceed that.
* These use blender standard view coordinates,
* with positive rotations being CCW about the axis. */
/* translation: */
float tx, ty, tz;
/* rotation:
* - `axis = (rx,ry,rz).normalized`
* - `amount = (rx,ry,rz).magnitude` [in revolutions, 1.0 = 360 deg]. */
float rx, ry, rz;
/** Time since previous NDOF Motion event */
float dt;
/** Starting, #GHOST_kInProgress or #GHOST_kFinishing (for modal handlers) */
GHOST_TProgress progress;
} GHOST_TEventNDOFMotionData;
typedef enum { GHOST_kPress, GHOST_kRelease } GHOST_TButtonAction;
// good for mouse or other buttons too, hmmm?
/* Good for mouse or other buttons too, hmmm? */
typedef struct {
GHOST_TButtonAction action;
@@ -561,7 +568,7 @@ typedef struct {
*/
/** The ascii code for the key event ('\0' if none). */
char ascii;
/** The unicode character. if the length is 6, not NULL terminated if all 6 are set */
/** The unicode character. if the length is 6, not NULL terminated if all 6 are set. */
char utf8_buf[6];
/** Generated by auto-repeat. */
@@ -594,7 +601,8 @@ typedef void *GHOST_TEmbedderWindowID;
#endif // _WIN32
#ifndef _WIN32
// I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
/* I can't use "Window" from `X11/Xlib.h`
* because it conflicts with Window defined in `winlay.h`. */
typedef int GHOST_TEmbedderWindowID;
#endif // _WIN32
@@ -642,8 +650,10 @@ typedef void *(*GHOST_XrGraphicsContextBindFn)(void);
typedef void (*GHOST_XrGraphicsContextUnbindFn)(GHOST_ContextHandle graphics_context);
typedef void (*GHOST_XrDrawViewFn)(const struct GHOST_XrDrawViewInfo *draw_view, void *customdata);
/* An array of GHOST_TXrGraphicsBinding items defining the candidate bindings to use. The first
* available candidate will be chosen, so order defines priority. */
/**
* An array of #GHOST_TXrGraphicsBinding items defining the candidate bindings to use.
* The first available candidate will be chosen, so order defines priority.
*/
typedef const GHOST_TXrGraphicsBinding *GHOST_XrGraphicsBindingCandidates;
typedef struct {
@@ -684,7 +694,7 @@ typedef struct GHOST_XrDrawViewInfo {
float angle_up, angle_down;
} fov;
/** Set if the buffer should be submitted with a srgb transfer applied. */
/** Set if the buffer should be submitted with a SRGB transfer applied. */
char expects_srgb_buffer;
} GHOST_XrDrawViewInfo;
@@ -734,7 +744,7 @@ typedef struct GHOST_XrActionSpaceInfo {
typedef struct GHOST_XrActionBindingInfo {
const char *action_name;
GHOST_TUns32 count_interaction_paths;
/** Interaction path: User (subaction) path + component path. */
/** Interaction path: User (sub-action) path + component path. */
const char **interaction_paths;
} GHOST_XrActionBindingInfo;

View File

@@ -149,6 +149,9 @@ static bool egl_chk(bool result, const char *file = NULL, int line = 0, const ch
static_cast<unsigned int>(error),
code ? code : "<Unknown>",
msg ? msg : "<Unknown>");
(void)(file);
(void)(line);
(void)(text);
#endif
}
@@ -199,7 +202,8 @@ template<typename T> T &choose_api(EGLenum api, T &a, T &b, T &c)
}
}
GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
GHOST_ContextEGL::GHOST_ContextEGL(const GHOST_System *const system,
bool stereoVisual,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@@ -209,6 +213,7 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
EGLint contextResetNotificationStrategy,
EGLenum api)
: GHOST_Context(stereoVisual),
m_system(system),
m_nativeDisplay(nativeDisplay),
m_nativeWindow(nativeWindow),
m_contextProfileMask(contextProfileMask),
@@ -285,6 +290,21 @@ GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut)
return GHOST_kSuccess;
}
EGLDisplay GHOST_ContextEGL::getDisplay() const
{
return m_display;
}
EGLConfig GHOST_ContextEGL::getConfig() const
{
return m_config;
}
EGLContext GHOST_ContextEGL::getContext() const
{
return m_context;
}
GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext()
{
if (m_display) {
@@ -456,9 +476,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
attrib_list.push_back(EGL_NONE);
EGLConfig config;
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config)))
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config)))
goto error;
// A common error is to assume that ChooseConfig worked because it returned EGL_TRUE
@@ -466,7 +484,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
goto error;
if (m_nativeWindow != 0) {
m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
m_surface = ::eglCreateWindowSurface(m_display, m_config, m_nativeWindow, NULL);
}
else {
static const EGLint pb_attrib_list[] = {
@@ -476,7 +494,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
1,
EGL_NONE,
};
m_surface = ::eglCreatePbufferSurface(m_display, config, pb_attrib_list);
m_surface = ::eglCreatePbufferSurface(m_display, m_config, pb_attrib_list);
}
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
@@ -577,7 +595,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
attrib_list.push_back(EGL_NONE);
m_context = ::eglCreateContext(m_display, config, m_sharedContext, &(attrib_list[0]));
m_context = ::eglCreateContext(m_display, m_config, m_sharedContext, &(attrib_list[0]));
if (!EGL_CHK(m_context != EGL_NO_CONTEXT))
goto error;

View File

@@ -24,6 +24,7 @@
#pragma once
#include "GHOST_Context.h"
#include "GHOST_System.h"
#include <GL/eglew.h>
@@ -36,11 +37,15 @@
#endif
class GHOST_ContextEGL : public GHOST_Context {
/* XR code needs low level graphics data to send to OpenXR. */
friend class GHOST_XrGraphicsBindingOpenGL;
public:
/**
* Constructor.
*/
GHOST_ContextEGL(bool stereoVisual,
GHOST_ContextEGL(const GHOST_System *const system,
bool stereoVisual,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
@@ -100,9 +105,17 @@ class GHOST_ContextEGL : public GHOST_Context {
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
EGLDisplay getDisplay() const;
EGLConfig getConfig() const;
EGLContext getContext() const;
private:
bool initContextEGLEW();
const GHOST_System *const m_system;
EGLNativeDisplayType m_nativeDisplay;
EGLNativeWindowType m_nativeWindow;
@@ -117,6 +130,7 @@ class GHOST_ContextEGL : public GHOST_Context {
EGLContext m_context;
EGLSurface m_surface;
EGLDisplay m_display;
EGLConfig m_config;
EGLint m_swap_interval;

View File

@@ -124,7 +124,7 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
GHOST_X11_ERROR_HANDLERS_OVERRIDE(handler_store);
/* -------------------------------------------------------------------- */
/* Begin Inline Glew */
/* Begin Inline Glew */
#ifdef USE_GLXEW_INIT_WORKAROUND
const GLubyte *extStart = (GLubyte *)"";

View File

@@ -161,5 +161,5 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(
// CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
return /*err == CGDisplayNoErr ?*/ GHOST_kSuccess /*: GHOST_kFailure*/;
return /* err == CGDisplayNoErr ? */ GHOST_kSuccess /* : GHOST_kFailure */;
}

View File

@@ -160,7 +160,7 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
else {
/* this is a problem for the BGE player :S, perhaps SDL2 will resolve at some point.
* we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell */
printf("no windows available, cant fullscreen\n");
printf("no windows available, can't fullscreen\n");
/* do not fail, we will try again later when the window is created - wander */
return GHOST_kSuccess;

View File

@@ -31,10 +31,17 @@ class GHOST_IXrGraphicsBinding {
public:
union {
#if defined(WITH_GHOST_X11)
# if defined(WITH_GL_EGL)
XrGraphicsBindingEGLMNDX egl;
# else
XrGraphicsBindingOpenGLXlibKHR glx;
# endif
#elif defined(WIN32)
XrGraphicsBindingOpenGLWin32KHR wgl;
XrGraphicsBindingD3D11KHR d3d11;
#endif
#if defined(WITH_GHOST_WAYLAND)
XrGraphicsBindingOpenGLWaylandKHR wl;
#endif
} oxr_binding;

View File

@@ -239,7 +239,7 @@ class GHOST_System : public GHOST_ISystem {
* Set which tablet API to use. Only affects Windows, other platforms have a single API.
* \param api: Enum indicating which API to use.
*/
void setTabletAPI(GHOST_TTabletAPI api);
virtual void setTabletAPI(GHOST_TTabletAPI api);
GHOST_TTabletAPI getTabletAPI(void);
#ifdef WITH_INPUT_NDOF
@@ -328,8 +328,8 @@ class GHOST_System : public GHOST_ISystem {
*/
virtual GHOST_TSuccess showMessageBox(const char * /*title*/,
const char * /*message*/,
const char * /*help_label */,
const char * /*continue_label */,
const char * /*help_label*/,
const char * /*continue_label*/,
const char * /*link*/,
GHOST_DialogOptions /*dialog_options*/) const
{

View File

@@ -32,11 +32,7 @@
#include "GHOST_WindowCocoa.h"
#include "GHOST_WindowManager.h"
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextCGL.h"
#endif
#include "GHOST_ContextCGL.h"
#ifdef WITH_INPUT_NDOF
# include "GHOST_NDOFManagerCocoa.h"
@@ -90,7 +86,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
{
// printf("\nrecvchar %c 0x%x",recvChar,recvChar);
switch (rawCode) {
/*Physical keycodes not used due to map changes in int'l keyboards
/* Physical key-codes: (not used due to map changes in int'l keyboards). */
#if 0
case kVK_ANSI_A: return GHOST_kKeyA;
case kVK_ANSI_B: return GHOST_kKeyB;
case kVK_ANSI_C: return GHOST_kKeyC;
@@ -116,9 +113,9 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
case kVK_ANSI_W: return GHOST_kKeyW;
case kVK_ANSI_X: return GHOST_kKeyX;
case kVK_ANSI_Y: return GHOST_kKeyY;
case kVK_ANSI_Z: return GHOST_kKeyZ;*/
/* Numbers keys mapped to handle some int'l keyboard (e.g. French)*/
case kVK_ANSI_Z: return GHOST_kKeyZ;
#endif
/* Numbers keys: mapped to handle some int'l keyboard (e.g. French). */
case kVK_ISO_Section:
return GHOST_kKeyUnknown;
case kVK_ANSI_1:
@@ -248,8 +245,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
return GHOST_kKeyUpPage;
case kVK_PageDown:
return GHOST_kKeyDownPage;
/*case kVK_ANSI_Minus: return GHOST_kKeyMinus;
#if 0 /* TODO: why are these commented? */
case kVK_ANSI_Minus: return GHOST_kKeyMinus;
case kVK_ANSI_Equal: return GHOST_kKeyEqual;
case kVK_ANSI_Comma: return GHOST_kKeyComma;
case kVK_ANSI_Period: return GHOST_kKeyPeriod;
@@ -259,15 +256,15 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
case kVK_ANSI_Backslash: return GHOST_kKeyBackslash;
case kVK_ANSI_LeftBracket: return GHOST_kKeyLeftBracket;
case kVK_ANSI_RightBracket: return GHOST_kKeyRightBracket;
case kVK_ANSI_Grave: return GHOST_kKeyAccentGrave;*/
case kVK_ANSI_Grave: return GHOST_kKeyAccentGrave;
#endif
case kVK_VolumeUp:
case kVK_VolumeDown:
case kVK_Mute:
return GHOST_kKeyUnknown;
default: {
/* alphanumerical or punctuation key that is remappable in int'l keyboards */
/* Alphanumerical or punctuation key that is remappable in int'l keyboards. */
if ((recvChar >= 'A') && (recvChar <= 'Z')) {
return (GHOST_TKey)(recvChar - 'A' + GHOST_kKeyA);
}
@@ -275,8 +272,8 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
return (GHOST_TKey)(recvChar - 'a' + GHOST_kKeyA);
}
else {
/* Leopard and Snow Leopard 64bit compatible API*/
CFDataRef uchrHandle; /*the keyboard layout*/
/* Leopard and Snow Leopard 64bit compatible API. */
CFDataRef uchrHandle; /* The keyboard layout. */
TISInputSourceRef kbdTISHandle;
kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
@@ -284,9 +281,9 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
kTISPropertyUnicodeKeyLayoutData);
CFRelease(kbdTISHandle);
/*get actual character value of the "remappable" keys in int'l keyboards,
if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
then fallback on using the received charactersIgnoringModifiers */
/* Get actual character value of the "remappable" keys in int'l keyboards,
* if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
* then fallback on using the received #charactersIgnoringModifiers. */
if (uchrHandle) {
UInt32 deadKeyState = 0;
UniCharCount actualStrLength = 0;
@@ -437,8 +434,10 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
// So WM_exit needs to be called directly, as the event loop will never run before termination
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
/*G.is_break = FALSE; //Let Cocoa perform the termination at the end
WM_exit(C);*/
#if 0
G.is_break = false; /* Let Cocoa perform the termination at the end. */
WM_exit(C);
#endif
}
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
@@ -553,10 +552,12 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
// ProcessSerialNumber psn;
// Carbon stuff to move window & menu to foreground
/*if (!GetCurrentProcess(&psn)) {
#if 0
if (!GetCurrentProcess(&psn)) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
}*/
}
#endif
@autoreleasepool {
[NSApplication sharedApplication]; // initializes NSApp
@@ -1217,7 +1218,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
return GHOST_kFailure;
}
/*Get the bitmap of the image*/
/* Get the bitmap of the image. */
enumerator = [[droppedImg representations] objectEnumerator];
while ((representation = [enumerator nextObject])) {
if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
@@ -1230,7 +1231,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0) &&
![bitmapImage isPlanar]) {
/* Try a fast copy if the image is a meshed RGBA 32bit bitmap*/
/* Try a fast copy if the image is a meshed RGBA 32bit bitmap. */
toIBuf = (GHOST_TUns8 *)ibuf->rect;
rasterRGB = (GHOST_TUns8 *)[bitmapImage bitmapData];
for (y = 0; y < imgSize.height; y++) {
@@ -1260,7 +1261,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:(NSBitmapFormat)0
bytesPerRow:4 * imgSize.width
bitsPerPixel:32 /*RGB format padded to 32bits*/];
bitsPerPixel:32 /* RGB format padded to 32bits. */];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext
@@ -1307,7 +1308,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
return GHOST_kFailure;
}
/*Copy the image to ibuf, flipping it vertically*/
/* Copy the image to ibuf, flipping it vertically. */
toIBuf = (GHOST_TUns8 *)ibuf->rect;
for (y = 0; y < imgSize.height; y++) {
for (x = 0; x < imgSize.width; x++) {

View File

@@ -376,7 +376,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
bounds.wrapPoint(x_new, y_new, 8, window->getCursorGrabAxis());
window->getCursorGrabAccum(x_accum, y_accum);
// cant use setCursorPosition because the mouse may have no focus!
// can't use setCursorPosition because the mouse may have no focus!
if (x_new != x_root || y_new != y_root) {
if (1) { //xme.time > m_last_warp) {
/* when wrapping we don't need to add an event because the

View File

@@ -1590,15 +1590,36 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
d->os_surfaces.push_back(os_surface);
d->os_egl_windows.push_back(os_egl_window);
GHOST_Context *context = new GHOST_ContextEGL(false,
EGLNativeWindowType(os_egl_window),
EGLNativeDisplayType(d->display),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3,
3,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
GHOST_Context *context;
for (int minor = 6; minor >= 0; --minor) {
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(os_egl_window),
EGLNativeDisplayType(d->display),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
4,
minor,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext())
return context;
else
delete context;
}
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(os_egl_window),
EGLNativeDisplayType(d->display),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3,
3,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext()) {
return context;

View File

@@ -50,11 +50,7 @@
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextWGL.h"
#endif
#include "GHOST_ContextWGL.h"
#ifdef WITH_INPUT_NDOF
# include "GHOST_NDOFManagerWin32.h"
@@ -139,7 +135,6 @@ static void initRawInput()
#undef DEVICE_COUNT
}
typedef HRESULT(API *GHOST_WIN32_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
typedef BOOL(API *GHOST_WIN32_EnableNonClientDpiScaling)(HWND);
GHOST_SystemWin32::GHOST_SystemWin32()
@@ -867,23 +862,159 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
{
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
if (type == GHOST_kEventButtonDown) {
window->updateMouseCapture(MousePressed);
}
else if (type == GHOST_kEventButtonUp) {
window->updateMouseCapture(MouseReleased);
GHOST_TabletData td = window->getTabletData();
/* Move mouse to button event position. */
if (window->getTabletData().Active != GHOST_kTabletModeNone) {
/* Tablet should be handling in between mouse moves, only move to event position. */
DWORD msgPos = ::GetMessagePos();
int msgPosX = GET_X_LPARAM(msgPos);
int msgPosY = GET_Y_LPARAM(msgPos);
system->pushEvent(new GHOST_EventCursor(
::GetMessageTime(), GHOST_kEventCursorMove, window, msgPosX, msgPosY, td));
}
return new GHOST_EventButton(
system->getMilliSeconds(), type, window, mask, window->getTabletData());
window->updateMouseCapture(type == GHOST_kEventButtonDown ? MousePressed : MouseReleased);
return new GHOST_EventButton(system->getMilliSeconds(), type, window, mask, td);
}
void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
{
GHOST_Wintab *wt = window->getWintab();
if (!wt) {
return;
}
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
std::vector<GHOST_WintabInfoWin32> wintabInfo;
wt->getInput(wintabInfo);
/* Wintab provided coordinates are untrusted until a Wintab and Win32 button down event match.
* This is checked on every button down event, and revoked if there is a mismatch. This can
* happen when Wintab incorrectly scales cursor position or is in mouse mode.
*
* If Wintab was never trusted while processing this Win32 event, a fallback Ghost cursor move
* event is created at the position of the Win32 WT_PACKET event. */
bool mouseMoveHandled;
bool useWintabPos;
mouseMoveHandled = useWintabPos = wt->trustCoordinates();
for (GHOST_WintabInfoWin32 &info : wintabInfo) {
switch (info.type) {
case GHOST_kEventCursorMove: {
if (!useWintabPos) {
continue;
}
wt->mapWintabToSysCoordinates(info.x, info.y, info.x, info.y);
system->pushEvent(new GHOST_EventCursor(
info.time, GHOST_kEventCursorMove, window, info.x, info.y, info.tabletData));
break;
}
case GHOST_kEventButtonDown: {
UINT message;
switch (info.button) {
case GHOST_kButtonMaskLeft:
message = WM_LBUTTONDOWN;
break;
case GHOST_kButtonMaskRight:
message = WM_RBUTTONDOWN;
break;
case GHOST_kButtonMaskMiddle:
message = WM_MBUTTONDOWN;
break;
default:
continue;
}
/* Wintab buttons are modal, but the API does not inform us what mode a pressed button is
* in. Only issue button events if we can steal an equivalent Win32 button event from the
* event queue. */
MSG msg;
if (PeekMessage(&msg, window->getHWND(), message, message, PM_NOYIELD) &&
msg.message != WM_QUIT) {
/* Test for Win32/Wintab button down match. */
useWintabPos = wt->testCoordinates(msg.pt.x, msg.pt.y, info.x, info.y);
if (!useWintabPos) {
continue;
}
/* Steal the Win32 event which was previously peeked. */
PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD);
/* Move cursor to button location, to prevent incorrect cursor position when
* transitioning from unsynchronized Win32 to Wintab cursor control. */
wt->mapWintabToSysCoordinates(info.x, info.y, info.x, info.y);
system->pushEvent(new GHOST_EventCursor(
info.time, GHOST_kEventCursorMove, window, info.x, info.y, info.tabletData));
window->updateMouseCapture(MousePressed);
system->pushEvent(
new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData));
mouseMoveHandled = true;
break;
}
}
case GHOST_kEventButtonUp: {
if (!useWintabPos) {
continue;
}
UINT message;
switch (info.button) {
case GHOST_kButtonMaskLeft:
message = WM_LBUTTONUP;
break;
case GHOST_kButtonMaskRight:
message = WM_RBUTTONUP;
break;
case GHOST_kButtonMaskMiddle:
message = WM_MBUTTONUP;
break;
default:
continue;
}
/* Wintab buttons are modal, but the API does not inform us what mode a pressed button is
* in. Only issue button events if we can steal an equivalent Win32 button event from the
* event queue. */
MSG msg;
if (PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD) &&
msg.message != WM_QUIT) {
window->updateMouseCapture(MouseReleased);
system->pushEvent(
new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData));
}
break;
}
default:
break;
}
}
/* Fallback cursor movement if Wintab position were never trusted while processing this event. */
if (!mouseMoveHandled) {
DWORD pos = GetMessagePos();
int x = GET_X_LPARAM(pos);
int y = GET_Y_LPARAM(pos);
/* TODO supply tablet data */
system->pushEvent(new GHOST_EventCursor(
system->getMilliSeconds(), GHOST_kEventCursorMove, window, x, y, GHOST_TABLET_DATA_NONE));
}
}
void GHOST_SystemWin32::processPointerEvent(
UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventHandled)
{
/* Pointer events might fire when changing windows for a device which is set to use Wintab, even
* when when Wintab is left enabled but set to the bottom of Wintab overlap order. */
if (!window->useTabletAPI(GHOST_kTabletNative)) {
/* Pointer events might fire when changing windows for a device which is set to use Wintab,
* even when Wintab is left enabled but set to the bottom of Wintab overlap order. */
if (!window->usingTabletAPI(GHOST_kTabletWinPointer)) {
return;
}
@@ -894,20 +1025,21 @@ void GHOST_SystemWin32::processPointerEvent(
return;
}
if (!pointerInfo[0].isPrimary) {
eventHandled = true;
return; // For multi-touch displays we ignore these events
}
switch (type) {
case WM_POINTERENTER:
window->m_tabletInRange = true;
system->pushEvent(new GHOST_EventCursor(pointerInfo[0].time,
GHOST_kEventCursorMove,
window,
pointerInfo[0].pixelLocation.x,
pointerInfo[0].pixelLocation.y,
pointerInfo[0].tabletData));
case WM_POINTERUPDATE:
/* Coalesced pointer events are reverse chronological order, reorder chronologically.
* Only contiguous move events are coalesced. */
for (GHOST_TUns32 i = pointerInfo.size(); i-- > 0;) {
system->pushEvent(new GHOST_EventCursor(pointerInfo[i].time,
GHOST_kEventCursorMove,
window,
pointerInfo[i].pixelLocation.x,
pointerInfo[i].pixelLocation.y,
pointerInfo[i].tabletData));
}
/* Leave event unhandled so that system cursor is moved. */
break;
case WM_POINTERDOWN:
/* Move cursor to point of contact because GHOST_EventButton does not include position. */
@@ -923,18 +1055,10 @@ void GHOST_SystemWin32::processPointerEvent(
pointerInfo[0].buttonMask,
pointerInfo[0].tabletData));
window->updateMouseCapture(MousePressed);
break;
case WM_POINTERUPDATE:
/* Coalesced pointer events are reverse chronological order, reorder chronologically.
* Only contiguous move events are coalesced. */
for (GHOST_TUns32 i = pointerInfo.size(); i-- > 0;) {
system->pushEvent(new GHOST_EventCursor(pointerInfo[i].time,
GHOST_kEventCursorMove,
window,
pointerInfo[i].pixelLocation.x,
pointerInfo[i].pixelLocation.y,
pointerInfo[i].tabletData));
}
/* Mark event handled so that mouse button events are not generated. */
eventHandled = true;
break;
case WM_POINTERUP:
system->pushEvent(new GHOST_EventButton(pointerInfo[0].time,
@@ -943,16 +1067,14 @@ void GHOST_SystemWin32::processPointerEvent(
pointerInfo[0].buttonMask,
pointerInfo[0].tabletData));
window->updateMouseCapture(MouseReleased);
break;
case WM_POINTERLEAVE:
window->m_tabletInRange = false;
/* Mark event handled so that mouse button events are not generated. */
eventHandled = true;
break;
default:
break;
}
eventHandled = true;
system->setCursorPosition(pointerInfo[0].pixelLocation.x, pointerInfo[0].pixelLocation.y);
}
GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *window)
@@ -960,18 +1082,14 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
GHOST_TInt32 x_screen, y_screen;
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
if (window->m_tabletInRange) {
if (window->useTabletAPI(GHOST_kTabletNative)) {
/* Tablet input handled in WM_POINTER* events. WM_MOUSEMOVE events in response to tablet
* input aren't normally generated when using WM_POINTER events, but manually moving the
* system cursor as we do in WM_POINTER handling does. */
return NULL;
}
if (window->getTabletData().Active != GHOST_kTabletModeNone) {
/* While pen devices are in range, cursor movement is handled by tablet input processing. */
return NULL;
}
system->getCursorPosition(x_screen, y_screen);
if (window->getCursorGrabModeIsWarp() && !window->m_tabletInRange) {
if (window->getCursorGrabModeIsWarp()) {
GHOST_TInt32 x_new = x_screen;
GHOST_TInt32 y_new = y_screen;
GHOST_TInt32 x_accum, y_accum;
@@ -983,7 +1101,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
}
/* Could also clamp to screen bounds wrap with a window outside the view will fail atm.
* Use offset of 8 in case the window is at screen bounds. */
* Use inset in case the window is at screen bounds. */
bounds.wrapPoint(x_new, y_new, 2, window->getCursorGrabAxis());
window->getCursorGrabAccum(x_accum, y_accum);
@@ -999,7 +1117,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
window,
x_screen + x_accum,
y_screen + y_accum,
window->getTabletData());
GHOST_TABLET_DATA_NONE);
}
}
else {
@@ -1008,7 +1126,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
window,
x_screen,
y_screen,
window->getTabletData());
GHOST_TABLET_DATA_NONE);
}
return NULL;
}
@@ -1118,6 +1236,23 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
return event;
}
GHOST_Event *GHOST_SystemWin32::processWindowSizeEvent(GHOST_WindowWin32 *window)
{
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
GHOST_Event *sizeEvent = new GHOST_Event(
system->getMilliSeconds(), GHOST_kEventWindowSize, window);
/* We get WM_SIZE before we fully init. Do not dispatch before we are continuously resizing. */
if (window->m_inLiveResize) {
system->pushEvent(sizeEvent);
system->dispatchEvents();
return NULL;
}
else {
return sizeEvent;
}
}
GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type,
GHOST_WindowWin32 *window)
{
@@ -1125,7 +1260,6 @@ GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type,
if (type == GHOST_kEventWindowActivate) {
system->getWindowManager()->setActiveWindow(window);
window->bringTabletContextToFront();
}
return new GHOST_Event(system->getMilliSeconds(), type, window);
@@ -1153,6 +1287,31 @@ GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType,
system->getMilliSeconds(), eventType, draggedObjectType, window, mouseX, mouseY, data));
}
void GHOST_SystemWin32::setTabletAPI(GHOST_TTabletAPI api)
{
GHOST_System::setTabletAPI(api);
/* If API is set to WinPointer (Windows Ink), unload Wintab so that trouble drivers don't disable
* Windows Ink. Load Wintab when API is Automatic because decision logic relies on knowing
* whether a Wintab device is present. */
const bool loadWintab = GHOST_kTabletWinPointer != api;
GHOST_WindowManager *wm = getWindowManager();
for (GHOST_IWindow *win : wm->getWindows()) {
GHOST_WindowWin32 *windowWin32 = (GHOST_WindowWin32 *)win;
if (loadWintab) {
windowWin32->loadWintab(GHOST_kWindowStateMinimized != windowWin32->getState());
if (windowWin32->usingTabletAPI(GHOST_kTabletWintab)) {
windowWin32->resetPointerPenInfo();
}
}
else {
windowWin32->closeWintab();
}
}
}
void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO *minmax)
{
minmax->ptMinTrackSize.x = 320;
@@ -1344,7 +1503,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
/* These functions were replaced by WM_INPUT*/
/* These functions were replaced by #WM_INPUT. */
case WM_CHAR:
/* The WM_CHAR message is posted to the window with the keyboard focus when
* a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR
@@ -1387,33 +1546,100 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case SC_KEYMENU:
eventHandled = true;
break;
case SC_RESTORE:
case SC_RESTORE: {
::ShowWindow(hwnd, SW_RESTORE);
window->setState(window->getState());
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->enable();
}
eventHandled = true;
break;
}
case SC_MAXIMIZE: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->enable();
}
/* Don't report event as handled so that default handling occurs. */
break;
}
case SC_MINIMIZE: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->disable();
}
/* Don't report event as handled so that default handling occurs. */
break;
}
}
break;
////////////////////////////////////////////////////////////////////////
// Wintab events, processed
////////////////////////////////////////////////////////////////////////
case WT_PACKET:
window->processWin32TabletEvent(wParam, lParam);
case WT_CSRCHANGE: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->updateCursorInfo();
}
eventHandled = true;
break;
case WT_CSRCHANGE:
case WT_PROXIMITY:
window->processWin32TabletInitEvent();
}
case WT_PROXIMITY: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
bool inRange = LOWORD(lParam);
if (inRange) {
/* Some devices don't emit WT_CSRCHANGE events, so update cursor info here. */
wt->updateCursorInfo();
}
else {
wt->leaveRange();
}
}
eventHandled = true;
break;
}
case WT_INFOCHANGE: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->processInfoChange(lParam);
if (window->usingTabletAPI(GHOST_kTabletWintab)) {
window->resetPointerPenInfo();
}
}
eventHandled = true;
break;
}
case WT_PACKET:
processWintabEvent(window);
eventHandled = true;
break;
////////////////////////////////////////////////////////////////////////
// Pointer events, processed
////////////////////////////////////////////////////////////////////////
case WM_POINTERENTER:
case WM_POINTERDOWN:
case WM_POINTERUPDATE:
case WM_POINTERDOWN:
case WM_POINTERUP:
case WM_POINTERLEAVE:
processPointerEvent(msg, window, wParam, lParam, eventHandled);
break;
case WM_POINTERLEAVE: {
GHOST_TUns32 pointerId = GET_POINTERID_WPARAM(wParam);
POINTER_INFO pointerInfo;
if (!GetPointerInfo(pointerId, &pointerInfo)) {
break;
}
/* Reset pointer pen info if pen device has left tracking range. */
if (pointerInfo.pointerType == PT_PEN && !IS_POINTER_INRANGE_WPARAM(wParam)) {
window->resetPointerPenInfo();
eventHandled = true;
}
break;
}
////////////////////////////////////////////////////////////////////////
// Mouse events, processed
////////////////////////////////////////////////////////////////////////
@@ -1452,7 +1678,20 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
break;
case WM_MOUSEMOVE:
if (!window->m_mousePresent) {
TRACKMOUSEEVENT tme = {sizeof(tme)};
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
TrackMouseEvent(&tme);
window->m_mousePresent = true;
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->gainFocus();
}
}
event = processCursorEvent(window);
break;
case WM_MOUSEWHEEL: {
/* The WM_MOUSEWHEEL message is sent to the focus window
@@ -1487,7 +1726,17 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
window->loadCursor(true, GHOST_kStandardCursorDefault);
}
break;
case WM_MOUSELEAVE: {
window->m_mousePresent = false;
if (window->getTabletData().Active == GHOST_kTabletModeNone) {
processCursorEvent(window);
}
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->loseFocus();
}
break;
}
////////////////////////////////////////////////////////////////////////
// Mouse events, ignored
////////////////////////////////////////////////////////////////////////
@@ -1535,7 +1784,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* will not be dispatched to OUR active window if we minimize one of OUR windows. */
if (LOWORD(wParam) == WA_INACTIVE)
window->lostMouseCapture();
window->processWin32TabletActivateEvent(GET_WM_ACTIVATE_STATE(wParam, lParam));
lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
break;
}
@@ -1577,6 +1826,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
/* Let DefWindowProc handle it. */
break;
case WM_SIZING:
event = processWindowSizeEvent(window);
break;
case WM_SIZE:
/* The WM_SIZE message is sent to a window after its size has changed.
* The WM_SIZE and WM_MOVE messages are not sent if an application handles the
@@ -1584,15 +1835,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* to perform any move or size change processing during the WM_WINDOWPOSCHANGED
* message without calling DefWindowProc.
*/
/* we get first WM_SIZE before we fully init.
* So, do not dispatch before we continuously resizing. */
if (window->m_inLiveResize) {
system->pushEvent(processWindowEvent(GHOST_kEventWindowSize, window));
system->dispatchEvents();
}
else {
event = processWindowEvent(GHOST_kEventWindowSize, window);
}
event = processWindowSizeEvent(window);
break;
case WM_CAPTURECHANGED:
window->lostMouseCapture();
@@ -1608,7 +1851,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* to perform any move or size change processing during the WM_WINDOWPOSCHANGED
* message without calling DefWindowProc.
*/
/* see WM_SIZE comment*/
/* See #WM_SIZE comment. */
if (window->m_inLiveResize) {
system->pushEvent(processWindowEvent(GHOST_kEventWindowMove, window));
system->dispatchEvents();
@@ -1643,6 +1886,21 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
SWP_NOZORDER | SWP_NOACTIVATE);
}
break;
case WM_DISPLAYCHANGE: {
GHOST_Wintab *wt = window->getWintab();
if (wt) {
wt->remapCoordinates();
}
break;
}
case WM_KILLFOCUS:
/* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard
* focus. We want to prevent this if a window is still active and it loses focus to
* nowhere. */
if (!wParam && hwnd == ::GetActiveWindow()) {
::SetFocus(hwnd);
}
break;
////////////////////////////////////////////////////////////////////////
// Window events, ignored
////////////////////////////////////////////////////////////////////////
@@ -1679,12 +1937,6 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* object associated with the window.
*/
break;
case WM_KILLFOCUS:
/* The WM_KILLFOCUS message is sent to a window immediately before it loses the
* keyboard focus. We want to prevent this if a window is still active and it loses
* focus to nowhere. */
if (!wParam && hwnd == ::GetActiveWindow())
::SetFocus(hwnd);
case WM_SHOWWINDOW:
/* The WM_SHOWWINDOW message is sent to a window when the window is
* about to be hidden or shown. */

View File

@@ -265,6 +265,16 @@ class GHOST_SystemWin32 : public GHOST_System {
int mouseY,
void *data);
/***************************************************************************************
** Modify tablet API
***************************************************************************************/
/**
* Set which tablet API to use.
* \param api: Enum indicating which API to use.
*/
void setTabletAPI(GHOST_TTabletAPI api) override;
protected:
/**
* Initializes the system.
@@ -308,6 +318,12 @@ class GHOST_SystemWin32 : public GHOST_System {
GHOST_WindowWin32 *window,
GHOST_TButtonMask mask);
/**
* Creates tablet events from Wintab events.
* \param window: The window receiving the event (the active window).
*/
static void processWintabEvent(GHOST_WindowWin32 *window);
/**
* Creates tablet events from pointer events.
* \param type: The type of pointer event.
@@ -351,6 +367,13 @@ class GHOST_SystemWin32 : public GHOST_System {
*/
GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
/**
* Creates a window size event.
* \param window: The window receiving the event (the active window).
* \return The event created.
*/
static GHOST_Event *processWindowSizeEvent(GHOST_WindowWin32 *window);
/**
* Creates a window event.
* \param type: The type of event to create.

View File

@@ -89,7 +89,7 @@
/* see T34039 Fix Alt key glitch on Unity desktop */
#define USE_UNITY_WORKAROUND
/* Fix 'shortcut' part of keyboard reading code only ever using first defined keymap
/* Fix 'shortcut' part of keyboard reading code only ever using first defined key-map
* instead of active one. See T47228 and D1746 */
#define USE_NON_LATIN_KB_WORKAROUND
@@ -441,7 +441,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
for (int minor = 5; minor >= 0; --minor) {
#if defined(WITH_GL_EGL)
context = new GHOST_ContextEGL(false,
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(nullptr),
EGLNativeDisplayType(m_display),
profile_mask,
@@ -471,7 +472,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
}
#if defined(WITH_GL_EGL)
context = new GHOST_ContextEGL(false,
context = new GHOST_ContextEGL(this,
false,
EGLNativeWindowType(nullptr),
EGLNativeDisplayType(m_display),
profile_mask,
@@ -589,9 +591,7 @@ static void SleepTillEvent(Display *display, GHOST_TInt64 maxSleep)
}
}
/* This function borrowed from Qt's X11 support
* qclipboard_x11.cpp
* */
/* This function borrowed from Qt's X11 support qclipboard_x11.cpp */
struct init_timestamp_data {
Time timestamp;
};
@@ -2563,7 +2563,7 @@ static bool is_filler_char(char c)
return isspace(c) || c == '_' || c == '-' || c == ';' || c == ':';
}
/* These C functions are copied from Wine 3.12's wintab.c */
/* These C functions are copied from Wine 3.12's `wintab.c` */
static bool match_token(const char *haystack, const char *needle)
{
const char *h, *n;
@@ -2675,8 +2675,8 @@ void GHOST_SystemX11::refreshXInputDevices()
xtablet.PressureLevels = xvi->axes[2].max_value;
if (xvi->num_axes > 3) {
/* this is assuming that the tablet has the same tilt resolution in both
* positive and negative directions. It would be rather weird if it didn't.. */
/* This is assuming that the tablet has the same tilt resolution in both
* positive and negative directions. It would be rather weird if it didn't. */
xtablet.XtiltLevels = xvi->axes[3].max_value;
xtablet.YtiltLevels = xvi->axes[4].max_value;
}

View File

@@ -365,7 +365,7 @@ class GHOST_Window : public GHOST_IWindow {
/** The current grabbed state of the cursor */
GHOST_TGrabCursorMode m_cursorGrab;
/** Grab cursor axis.*/
/** Grab cursor axis. */
GHOST_TAxisFlag m_cursorGrabAxis;
/** Initial grab location. */

View File

@@ -22,11 +22,7 @@
#include "GHOST_Debug.h"
#include "GHOST_SystemCocoa.h"
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextCGL.h"
#endif
#include "GHOST_ContextCGL.h"
#include <Cocoa/Cocoa.h>
#include <Metal/Metal.h>

View File

@@ -556,7 +556,7 @@ static SDL_Cursor *sdl_ghost_CreateCursor(
return cursor;
}
/* TODO, this is currently never freed but it wont leak either. */
/* TODO, this is currently never freed but it won't leak either. */
static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
{
if (sdl_std_cursor_array[0] == NULL) {

View File

@@ -532,7 +532,25 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
context = new GHOST_ContextNone(m_wantStereoVisual);
break;
case GHOST_kDrawingContextTypeOpenGL:
context = new GHOST_ContextEGL(m_wantStereoVisual,
for (int minor = 6; minor >= 0; --minor) {
context = new GHOST_ContextEGL(this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(w->egl_window),
EGLNativeDisplayType(m_system->display()),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
4,
minor,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext())
return context;
else
delete context;
}
context = new GHOST_ContextEGL(this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(w->egl_window),
EGLNativeDisplayType(m_system->display()),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
@@ -541,7 +559,6 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
break;
}
return (context->initializeDrawingContext() == GHOST_kSuccess) ? context : nullptr;

View File

@@ -21,8 +21,6 @@
* \ingroup GHOST
*/
#define _USE_MATH_DEFINES
#include "GHOST_WindowWin32.h"
#include "GHOST_ContextD3D.h"
#include "GHOST_ContextNone.h"
@@ -32,11 +30,8 @@
#include "utf_winfunc.h"
#include "utfconv.h"
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextWGL.h"
#endif
#include "GHOST_ContextWGL.h"
#ifdef WIN32_COMPOSITING
# include <Dwmapi.h>
#endif
@@ -72,7 +67,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
bool is_debug,
bool dialog)
: GHOST_Window(width, height, state, wantStereoVisual, false),
m_tabletInRange(false),
m_mousePresent(false),
m_inLiveResize(false),
m_system(system),
m_hDC(0),
@@ -82,6 +77,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
m_nPressedButtons(0),
m_customCursor(0),
m_wantAlphaBackground(alphaBackground),
m_wintab(NULL),
m_lastPointerTabletData(GHOST_TABLET_DATA_NONE),
m_normal_state(GHOST_kWindowStateNormal),
m_user32(NULL),
m_parentWindowHwnd(parentwindow ? parentwindow->m_hWnd : HWND_DESKTOP),
@@ -90,10 +87,6 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
wchar_t *title_16 = alloc_utf16_from_8((char *)title, 0);
RECT win_rect = {left, top, (long)(left + width), (long)(top + height)};
// Initialize tablet variables
memset(&m_wintab, 0, sizeof(m_wintab));
m_tabletData = GHOST_TABLET_DATA_NONE;
DWORD style = parentwindow ?
WS_POPUPWINDOW | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX :
WS_OVERLAPPEDWINDOW;
@@ -218,65 +211,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
}
// Initialize Wintab
m_wintab.handle = ::LoadLibrary("Wintab32.dll");
if (m_wintab.handle && m_system->getTabletAPI() != GHOST_kTabletNative) {
// Get API functions
m_wintab.info = (GHOST_WIN32_WTInfo)::GetProcAddress(m_wintab.handle, "WTInfoA");
m_wintab.open = (GHOST_WIN32_WTOpen)::GetProcAddress(m_wintab.handle, "WTOpenA");
m_wintab.close = (GHOST_WIN32_WTClose)::GetProcAddress(m_wintab.handle, "WTClose");
m_wintab.packet = (GHOST_WIN32_WTPacket)::GetProcAddress(m_wintab.handle, "WTPacket");
m_wintab.enable = (GHOST_WIN32_WTEnable)::GetProcAddress(m_wintab.handle, "WTEnable");
m_wintab.overlap = (GHOST_WIN32_WTOverlap)::GetProcAddress(m_wintab.handle, "WTOverlap");
// Let's see if we can initialize tablet here.
// Check if WinTab available by getting system context info.
LOGCONTEXT lc = {0};
lc.lcOptions |= CXO_SYSTEM;
if (m_wintab.open && m_wintab.info && m_wintab.info(WTI_DEFSYSCTX, 0, &lc)) {
// Now init the tablet
/* The maximum tablet size, pressure and orientation (tilt) */
AXIS TabletX, TabletY, Pressure, Orientation[3];
// Open a Wintab context
// Open the context
lc.lcPktData = PACKETDATA;
lc.lcPktMode = PACKETMODE;
lc.lcOptions |= CXO_MESSAGES;
lc.lcMoveMask = PACKETDATA;
/* Set the entire tablet as active */
m_wintab.info(WTI_DEVICES, DVC_X, &TabletX);
m_wintab.info(WTI_DEVICES, DVC_Y, &TabletY);
/* get the max pressure, to divide into a float */
BOOL pressureSupport = m_wintab.info(WTI_DEVICES, DVC_NPRESSURE, &Pressure);
if (pressureSupport)
m_wintab.maxPressure = Pressure.axMax;
else
m_wintab.maxPressure = 0;
/* get the max tilt axes, to divide into floats */
BOOL tiltSupport = m_wintab.info(WTI_DEVICES, DVC_ORIENTATION, &Orientation);
if (tiltSupport) {
/* does the tablet support azimuth ([0]) and altitude ([1]) */
if (Orientation[0].axResolution && Orientation[1].axResolution) {
/* all this assumes the minimum is 0 */
m_wintab.maxAzimuth = Orientation[0].axMax;
m_wintab.maxAltitude = Orientation[1].axMax;
}
else { /* No so don't do tilt stuff. */
m_wintab.maxAzimuth = m_wintab.maxAltitude = 0;
}
}
// The Wintab spec says we must open the context disabled if we are using cursor masks.
m_wintab.tablet = m_wintab.open(m_hWnd, &lc, FALSE);
if (m_wintab.enable && m_wintab.tablet) {
m_wintab.enable(m_wintab.tablet, TRUE);
}
}
if (system->getTabletAPI() != GHOST_kTabletWinPointer) {
loadWintab(GHOST_kWindowStateMinimized != state);
}
CoCreateInstance(
CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&m_Bar);
}
@@ -289,14 +227,7 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
m_Bar = NULL;
}
if (m_wintab.handle) {
if (m_wintab.close && m_wintab.tablet) {
m_wintab.close(m_wintab.tablet);
}
FreeLibrary(m_wintab.handle);
memset(&m_wintab, 0, sizeof(m_wintab));
}
closeWintab();
if (m_user32) {
FreeLibrary(m_user32);
@@ -356,7 +287,7 @@ void GHOST_WindowWin32::setTitle(const char *title)
std::string GHOST_WindowWin32::getTitle() const
{
char buf[s_maxTitleLength]; /*CHANGE + never used yet*/
char buf[s_maxTitleLength]; /* CHANGE + never used yet. */
::GetWindowText(m_hWnd, buf, s_maxTitleLength);
return std::string(buf);
}
@@ -913,20 +844,16 @@ GHOST_TSuccess GHOST_WindowWin32::hasCursorShape(GHOST_TStandardCursor cursorSha
GHOST_TSuccess GHOST_WindowWin32::getPointerInfo(
std::vector<GHOST_PointerInfoWin32> &outPointerInfo, WPARAM wParam, LPARAM lParam)
{
if (!useTabletAPI(GHOST_kTabletNative)) {
return GHOST_kFailure;
}
GHOST_TInt32 pointerId = GET_POINTERID_WPARAM(wParam);
GHOST_TInt32 isPrimary = IS_POINTER_PRIMARY_WPARAM(wParam);
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)GHOST_System::getSystem();
GHOST_TUns32 outCount;
GHOST_TUns32 outCount = 0;
if (!(GetPointerInfoHistory(pointerId, &outCount, NULL))) {
if (!(GetPointerPenInfoHistory(pointerId, &outCount, NULL))) {
return GHOST_kFailure;
}
auto pointerPenInfo = std::vector<POINTER_PEN_INFO>(outCount);
std::vector<POINTER_PEN_INFO> pointerPenInfo(outCount);
outPointerInfo.resize(outCount);
if (!(GetPointerPenInfoHistory(pointerId, &outCount, pointerPenInfo.data()))) {
@@ -988,148 +915,77 @@ GHOST_TSuccess GHOST_WindowWin32::getPointerInfo(
}
}
if (!outPointerInfo.empty()) {
m_lastPointerTabletData = outPointerInfo.back().tabletData;
}
return GHOST_kSuccess;
}
void GHOST_WindowWin32::processWin32TabletActivateEvent(WORD state)
void GHOST_WindowWin32::resetPointerPenInfo()
{
if (!useTabletAPI(GHOST_kTabletWintab)) {
return;
}
m_lastPointerTabletData = GHOST_TABLET_DATA_NONE;
}
if (m_wintab.enable && m_wintab.tablet) {
m_wintab.enable(m_wintab.tablet, state);
GHOST_Wintab *GHOST_WindowWin32::getWintab() const
{
return m_wintab;
}
if (m_wintab.overlap && state) {
m_wintab.overlap(m_wintab.tablet, TRUE);
void GHOST_WindowWin32::loadWintab(bool enable)
{
if (!m_wintab) {
if (m_wintab = GHOST_Wintab::loadWintab(m_hWnd)) {
if (enable) {
m_wintab->enable();
/* Focus Wintab if cursor is inside this window. This ensures Wintab is enabled when the
* tablet is used to change the Tablet API. */
GHOST_TInt32 x, y;
if (m_system->getCursorPosition(x, y)) {
GHOST_Rect rect;
getClientBounds(rect);
if (rect.isInside(x, y)) {
m_wintab->gainFocus();
}
}
}
}
}
}
bool GHOST_WindowWin32::useTabletAPI(GHOST_TTabletAPI api) const
void GHOST_WindowWin32::closeWintab()
{
delete m_wintab;
m_wintab = NULL;
}
bool GHOST_WindowWin32::usingTabletAPI(GHOST_TTabletAPI api) const
{
if (m_system->getTabletAPI() == api) {
return true;
}
else if (m_system->getTabletAPI() == GHOST_kTabletAutomatic) {
if (m_wintab.tablet)
if (m_wintab && m_wintab->devicesPresent()) {
return api == GHOST_kTabletWintab;
else
return api == GHOST_kTabletNative;
}
else {
return api == GHOST_kTabletWinPointer;
}
}
else {
return false;
}
}
void GHOST_WindowWin32::processWin32TabletInitEvent()
GHOST_TabletData GHOST_WindowWin32::getTabletData()
{
if (!useTabletAPI(GHOST_kTabletWintab)) {
return;
if (usingTabletAPI(GHOST_kTabletWintab)) {
return m_wintab ? m_wintab->getLastTabletData() : GHOST_TABLET_DATA_NONE;
}
// Let's see if we can initialize tablet here
if (m_wintab.info && m_wintab.tablet) {
AXIS Pressure, Orientation[3]; /* The maximum tablet size */
BOOL pressureSupport = m_wintab.info(WTI_DEVICES, DVC_NPRESSURE, &Pressure);
if (pressureSupport)
m_wintab.maxPressure = Pressure.axMax;
else
m_wintab.maxPressure = 0;
BOOL tiltSupport = m_wintab.info(WTI_DEVICES, DVC_ORIENTATION, &Orientation);
if (tiltSupport) {
/* does the tablet support azimuth ([0]) and altitude ([1]) */
if (Orientation[0].axResolution && Orientation[1].axResolution) {
m_wintab.maxAzimuth = Orientation[0].axMax;
m_wintab.maxAltitude = Orientation[1].axMax;
}
else { /* No so don't do tilt stuff. */
m_wintab.maxAzimuth = m_wintab.maxAltitude = 0;
}
}
}
m_tabletData.Active = GHOST_kTabletModeNone;
}
void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam)
{
if (!useTabletAPI(GHOST_kTabletWintab)) {
return;
}
if (m_wintab.packet && m_wintab.tablet) {
PACKET pkt;
if (m_wintab.packet((HCTX)lParam, wParam, &pkt)) {
switch (pkt.pkCursor % 3) { /* % 3 for multiple devices ("DualTrack") */
case 0:
m_tabletData.Active = GHOST_kTabletModeNone; /* puck - not yet supported */
break;
case 1:
m_tabletData.Active = GHOST_kTabletModeStylus; /* stylus */
break;
case 2:
m_tabletData.Active = GHOST_kTabletModeEraser; /* eraser */
break;
}
if (m_wintab.maxPressure > 0) {
m_tabletData.Pressure = (float)pkt.pkNormalPressure / (float)m_wintab.maxPressure;
}
else {
m_tabletData.Pressure = 1.0f;
}
if ((m_wintab.maxAzimuth > 0) && (m_wintab.maxAltitude > 0)) {
ORIENTATION ort = pkt.pkOrientation;
float vecLen;
float altRad, azmRad; /* in radians */
/*
* from the wintab spec:
* orAzimuth Specifies the clockwise rotation of the
* cursor about the z axis through a full circular range.
*
* orAltitude Specifies the angle with the x-y plane
* through a signed, semicircular range. Positive values
* specify an angle upward toward the positive z axis;
* negative values specify an angle downward toward the negative z axis.
*
* wintab.h defines .orAltitude as a UINT but documents .orAltitude
* as positive for upward angles and negative for downward angles.
* WACOM uses negative altitude values to show that the pen is inverted;
* therefore we cast .orAltitude as an (int) and then use the absolute value.
*/
/* convert raw fixed point data to radians */
altRad = (float)((fabs((float)ort.orAltitude) / (float)m_wintab.maxAltitude) * M_PI / 2.0);
azmRad = (float)(((float)ort.orAzimuth / (float)m_wintab.maxAzimuth) * M_PI * 2.0);
/* find length of the stylus' projected vector on the XY plane */
vecLen = cos(altRad);
/* from there calculate X and Y components based on azimuth */
m_tabletData.Xtilt = sin(azmRad) * vecLen;
m_tabletData.Ytilt = (float)(sin(M_PI / 2.0 - azmRad) * vecLen);
}
else {
m_tabletData.Xtilt = 0.0f;
m_tabletData.Ytilt = 0.0f;
}
}
}
}
void GHOST_WindowWin32::bringTabletContextToFront()
{
if (!useTabletAPI(GHOST_kTabletWintab)) {
return;
}
if (m_wintab.overlap && m_wintab.tablet) {
m_wintab.overlap(m_wintab.tablet, TRUE);
else {
return m_lastPointerTabletData;
}
}

View File

@@ -30,34 +30,18 @@
#include "GHOST_TaskbarWin32.h"
#include "GHOST_Window.h"
#include "GHOST_Wintab.h"
#ifdef WITH_INPUT_IME
# include "GHOST_ImeWin32.h"
#endif
#include <vector>
#include <wintab.h>
// PACKETDATA and PACKETMODE modify structs in pktdef.h, so make sure they come first
#define PACKETDATA (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
#define PACKETMODE PK_BUTTONS
#include <pktdef.h>
class GHOST_SystemWin32;
class GHOST_DropTargetWin32;
// typedefs for WinTab functions to allow dynamic loading
typedef UINT(API *GHOST_WIN32_WTInfo)(UINT, UINT, LPVOID);
typedef HCTX(API *GHOST_WIN32_WTOpen)(HWND, LPLOGCONTEXTA, BOOL);
typedef BOOL(API *GHOST_WIN32_WTClose)(HCTX);
typedef BOOL(API *GHOST_WIN32_WTPacket)(HCTX, UINT, LPVOID);
typedef BOOL(API *GHOST_WIN32_WTEnable)(HCTX, BOOL);
typedef BOOL(API *GHOST_WIN32_WTOverlap)(HCTX, BOOL);
// typedefs for user32 functions to allow dynamic loading of Windows 10 DPI scaling functions
typedef UINT(API *GHOST_WIN32_GetDpiForWindow)(HWND);
#ifndef USER_DEFAULT_SCREEN_DPI
# define USER_DEFAULT_SCREEN_DPI 96
#endif // USER_DEFAULT_SCREEN_DPI
struct GHOST_PointerInfoWin32 {
GHOST_TInt32 pointerId;
@@ -65,7 +49,6 @@ struct GHOST_PointerInfoWin32 {
GHOST_TButtonMask buttonMask;
POINT pixelLocation;
GHOST_TUns64 time;
GHOST_TabletData tabletData;
};
@@ -259,16 +242,11 @@ class GHOST_WindowWin32 : public GHOST_Window {
HCURSOR getStandardCursor(GHOST_TStandardCursor shape) const;
void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
const GHOST_TabletData &getTabletData()
{
return m_tabletData;
}
/**
* Query whether given tablet API should be used.
* \param api: Tablet API to test.
*/
bool useTabletAPI(GHOST_TTabletAPI api) const;
bool usingTabletAPI(GHOST_TTabletAPI api) const;
/**
* Translate WM_POINTER events into GHOST_PointerInfoWin32 structs.
@@ -281,10 +259,34 @@ class GHOST_WindowWin32 : public GHOST_Window {
WPARAM wParam,
LPARAM lParam);
void processWin32TabletActivateEvent(WORD state);
void processWin32TabletInitEvent();
void processWin32TabletEvent(WPARAM wParam, LPARAM lParam);
void bringTabletContextToFront();
/**
* Resets pointer pen tablet state.
*/
void resetPointerPenInfo();
/**
* Retrieves pointer to Wintab if Wintab is the set Tablet API.
* \return Pointer to Wintab member.
*/
GHOST_Wintab *getWintab() const;
/**
* Loads Wintab context for the window.
* \param enable: True if Wintab should be enabled after loading. Wintab should not be enabled if
* the window is minimized.
*/
void loadWintab(bool enable);
/**
* Closes Wintab for the window.
*/
void closeWintab();
/**
* Get the most recent Windows Pointer tablet data.
* \return Most recent pointer tablet data.
*/
GHOST_TabletData getTabletData();
GHOST_TSuccess beginFullScreen() const
{
@@ -298,10 +300,10 @@ class GHOST_WindowWin32 : public GHOST_Window {
GHOST_TUns16 getDPIHint() override;
/** Whether a tablet stylus is being tracked. */
bool m_tabletInRange;
/** True if the mouse is either over or captured by the window. */
bool m_mousePresent;
/** if the window currently resizing */
/** True if the window currently resizing. */
bool m_inLiveResize;
#ifdef WITH_INPUT_IME
@@ -385,27 +387,11 @@ class GHOST_WindowWin32 : public GHOST_Window {
static const wchar_t *s_windowClassName;
static const int s_maxTitleLength;
/** Tablet data for GHOST */
GHOST_TabletData m_tabletData;
/** Pointer to Wintab manager if Wintab is loaded. */
GHOST_Wintab *m_wintab;
/* Wintab API */
struct {
/** `WinTab.dll` handle. */
HMODULE handle = NULL;
/** API functions */
GHOST_WIN32_WTInfo info;
GHOST_WIN32_WTOpen open;
GHOST_WIN32_WTClose close;
GHOST_WIN32_WTPacket packet;
GHOST_WIN32_WTEnable enable;
GHOST_WIN32_WTOverlap overlap;
/** Stores the Tablet context if detected Tablet features using `WinTab.dll` */
HCTX tablet;
LONG maxPressure;
LONG maxAzimuth, maxAltitude;
} m_wintab;
/** Most recent tablet data. */
GHOST_TabletData m_lastPointerTabletData;
GHOST_TWindowState m_normal_state;

View File

@@ -1241,7 +1241,7 @@ GHOST_WindowX11::~GHOST_WindowX11()
if (m_valid_setup) {
static Atom Primary_atom, Clipboard_atom;
Window p_owner, c_owner;
/*Change the owner of the Atoms to None if we are the owner*/
/* Change the owner of the Atoms to None if we are the owner. */
Primary_atom = XInternAtom(m_display, "PRIMARY", False);
Clipboard_atom = XInternAtom(m_display, "CLIPBOARD", False);
@@ -1325,6 +1325,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
for (int minor = 5; minor >= 0; --minor) {
#ifdef WITH_GL_EGL
context = new GHOST_ContextEGL(
this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(m_window),
EGLNativeDisplayType(m_display),
@@ -1355,7 +1356,8 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
}
#ifdef WITH_GL_EGL
context = new GHOST_ContextEGL(m_wantStereoVisual,
context = new GHOST_ContextEGL(this->m_system,
m_wantStereoVisual,
EGLNativeWindowType(m_window),
EGLNativeDisplayType(m_display),
profile_mask,

View File

@@ -0,0 +1,491 @@
/*
* 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.
*/
/** \file
* \ingroup GHOST
*/
#define _USE_MATH_DEFINES
#include "GHOST_Wintab.h"
GHOST_Wintab *GHOST_Wintab::loadWintab(HWND hwnd)
{
/* Load Wintab library if available. */
auto handle = unique_hmodule(::LoadLibrary("Wintab32.dll"), &::FreeLibrary);
if (!handle) {
return nullptr;
}
/* Get Wintab functions. */
auto info = (GHOST_WIN32_WTInfo)::GetProcAddress(handle.get(), "WTInfoA");
if (!info) {
return nullptr;
}
auto open = (GHOST_WIN32_WTOpen)::GetProcAddress(handle.get(), "WTOpenA");
if (!open) {
return nullptr;
}
auto get = (GHOST_WIN32_WTGet)::GetProcAddress(handle.get(), "WTGetA");
if (!get) {
return nullptr;
}
auto set = (GHOST_WIN32_WTSet)::GetProcAddress(handle.get(), "WTSetA");
if (!set) {
return nullptr;
}
auto close = (GHOST_WIN32_WTClose)::GetProcAddress(handle.get(), "WTClose");
if (!close) {
return nullptr;
}
auto packetsGet = (GHOST_WIN32_WTPacketsGet)::GetProcAddress(handle.get(), "WTPacketsGet");
if (!packetsGet) {
return nullptr;
}
auto queueSizeGet = (GHOST_WIN32_WTQueueSizeGet)::GetProcAddress(handle.get(), "WTQueueSizeGet");
if (!queueSizeGet) {
return nullptr;
}
auto queueSizeSet = (GHOST_WIN32_WTQueueSizeSet)::GetProcAddress(handle.get(), "WTQueueSizeSet");
if (!queueSizeSet) {
return nullptr;
}
auto enable = (GHOST_WIN32_WTEnable)::GetProcAddress(handle.get(), "WTEnable");
if (!enable) {
return nullptr;
}
auto overlap = (GHOST_WIN32_WTOverlap)::GetProcAddress(handle.get(), "WTOverlap");
if (!overlap) {
return nullptr;
}
/* Build Wintab context. */
LOGCONTEXT lc = {0};
if (!info(WTI_DEFSYSCTX, 0, &lc)) {
return nullptr;
}
Coord tablet, system;
extractCoordinates(lc, tablet, system);
modifyContext(lc);
/* The Wintab spec says we must open the context disabled if we are using cursor masks. */
auto hctx = unique_hctx(open(hwnd, &lc, FALSE), close);
if (!hctx) {
return nullptr;
}
/* Wintab provides no way to determine the maximum queue size aside from checking if attempts
* to change the queue size are successful. */
const int maxQueue = 500;
int queueSize = queueSizeGet(hctx.get());
while (queueSize < maxQueue) {
int testSize = min(queueSize + 16, maxQueue);
if (queueSizeSet(hctx.get(), testSize)) {
queueSize = testSize;
}
else {
/* From Windows Wintab Documentation for WTQueueSizeSet:
* "If the return value is zero, the context has no queue because the function deletes the
* original queue before attempting to create a new one. The application must continue
* calling the function with a smaller queue size until the function returns a non - zero
* value."
*
* In our case we start with a known valid queue size and in the event of failure roll
* back to the last valid queue size. The Wintab spec dates back to 16 bit Windows, thus
* assumes memory recently deallocated may not be available, which is no longer a practical
* concern. */
if (!queueSizeSet(hctx.get(), queueSize)) {
/* If a previously valid queue size is no longer valid, there is likely something wrong in
* the Wintab implementation and we should not use it. */
return nullptr;
}
break;
}
}
return new GHOST_Wintab(hwnd,
std::move(handle),
info,
get,
set,
packetsGet,
enable,
overlap,
std::move(hctx),
tablet,
system,
queueSize);
}
void GHOST_Wintab::modifyContext(LOGCONTEXT &lc)
{
lc.lcPktData = PACKETDATA;
lc.lcPktMode = PACKETMODE;
lc.lcMoveMask = PACKETDATA;
lc.lcOptions |= CXO_CSRMESSAGES | CXO_MESSAGES;
/* Tablet scaling is handled manually because some drivers don't handle HIDPI or multi-display
* correctly; reset tablet scale factors to un-scaled tablet coordinates. */
lc.lcOutOrgX = lc.lcInOrgX;
lc.lcOutOrgY = lc.lcInOrgY;
lc.lcOutExtX = lc.lcInExtX;
lc.lcOutExtY = lc.lcInExtY;
}
void GHOST_Wintab::extractCoordinates(LOGCONTEXT &lc, Coord &tablet, Coord &system)
{
tablet.x.org = lc.lcInOrgX;
tablet.x.ext = lc.lcInExtX;
tablet.y.org = lc.lcInOrgY;
tablet.y.ext = lc.lcInExtY;
system.x.org = lc.lcSysOrgX;
system.x.ext = lc.lcSysExtX;
system.y.org = lc.lcSysOrgY;
/* Wintab maps y origin to the tablet's bottom; invert y to match Windows y origin mapping to the
* screen top. */
system.y.ext = -lc.lcSysExtY;
}
GHOST_Wintab::GHOST_Wintab(HWND hwnd,
unique_hmodule handle,
GHOST_WIN32_WTInfo info,
GHOST_WIN32_WTGet get,
GHOST_WIN32_WTSet set,
GHOST_WIN32_WTPacketsGet packetsGet,
GHOST_WIN32_WTEnable enable,
GHOST_WIN32_WTOverlap overlap,
unique_hctx hctx,
Coord tablet,
Coord system,
int queueSize)
: m_handle{std::move(handle)},
m_fpInfo{info},
m_fpGet{get},
m_fpSet{set},
m_fpPacketsGet{packetsGet},
m_fpEnable{enable},
m_fpOverlap{overlap},
m_context{std::move(hctx)},
m_tabletCoord{tablet},
m_systemCoord{system},
m_pkts{queueSize}
{
m_fpInfo(WTI_INTERFACE, IFC_NDEVICES, &m_numDevices);
updateCursorInfo();
}
void GHOST_Wintab::enable()
{
m_fpEnable(m_context.get(), true);
m_enabled = true;
}
void GHOST_Wintab::disable()
{
if (m_focused) {
loseFocus();
}
m_fpEnable(m_context.get(), false);
m_enabled = false;
}
void GHOST_Wintab::gainFocus()
{
m_fpOverlap(m_context.get(), true);
m_focused = true;
}
void GHOST_Wintab::loseFocus()
{
if (m_lastTabletData.Active != GHOST_kTabletModeNone) {
leaveRange();
}
/* Mouse mode of tablet or display layout may change when Wintab or Window is inactive. Don't
* trust for mouse movement until re-verified. */
m_coordTrusted = false;
m_fpOverlap(m_context.get(), false);
m_focused = false;
}
void GHOST_Wintab::leaveRange()
{
/* Button state can't be tracked while out of range, reset it. */
m_buttons = 0;
/* Set to none to indicate tablet is inactive. */
m_lastTabletData = GHOST_TABLET_DATA_NONE;
/* Clear the packet queue. */
m_fpPacketsGet(m_context.get(), m_pkts.size(), m_pkts.data());
}
void GHOST_Wintab::remapCoordinates()
{
LOGCONTEXT lc = {0};
if (m_fpInfo(WTI_DEFSYSCTX, 0, &lc)) {
extractCoordinates(lc, m_tabletCoord, m_systemCoord);
modifyContext(lc);
m_fpSet(m_context.get(), &lc);
}
}
void GHOST_Wintab::updateCursorInfo()
{
AXIS Pressure, Orientation[3];
BOOL pressureSupport = m_fpInfo(WTI_DEVICES, DVC_NPRESSURE, &Pressure);
m_maxPressure = pressureSupport ? Pressure.axMax : 0;
BOOL tiltSupport = m_fpInfo(WTI_DEVICES, DVC_ORIENTATION, &Orientation);
/* Check if tablet supports azimuth [0] and altitude [1], encoded in axResolution. */
if (tiltSupport && Orientation[0].axResolution && Orientation[1].axResolution) {
m_maxAzimuth = Orientation[0].axMax;
m_maxAltitude = Orientation[1].axMax;
}
else {
m_maxAzimuth = m_maxAltitude = 0;
}
}
void GHOST_Wintab::processInfoChange(LPARAM lParam)
{
/* Update number of connected Wintab digitizers. */
if (LOWORD(lParam) == WTI_INTERFACE && HIWORD(lParam) == IFC_NDEVICES) {
m_fpInfo(WTI_INTERFACE, IFC_NDEVICES, &m_numDevices);
}
}
bool GHOST_Wintab::devicesPresent()
{
return m_numDevices > 0;
}
GHOST_TabletData GHOST_Wintab::getLastTabletData()
{
return m_lastTabletData;
}
void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
{
const int numPackets = m_fpPacketsGet(m_context.get(), m_pkts.size(), m_pkts.data());
outWintabInfo.resize(numPackets);
size_t outExtent = 0;
for (int i = 0; i < numPackets; i++) {
PACKET pkt = m_pkts[i];
GHOST_WintabInfoWin32 &out = outWintabInfo[i + outExtent];
out.tabletData = GHOST_TABLET_DATA_NONE;
/* % 3 for multiple devices ("DualTrack"). */
switch (pkt.pkCursor % 3) {
case 0:
/* Puck - processed as mouse. */
out.tabletData.Active = GHOST_kTabletModeNone;
break;
case 1:
out.tabletData.Active = GHOST_kTabletModeStylus;
break;
case 2:
out.tabletData.Active = GHOST_kTabletModeEraser;
break;
}
out.x = pkt.pkX;
out.y = pkt.pkY;
if (m_maxPressure > 0) {
out.tabletData.Pressure = (float)pkt.pkNormalPressure / (float)m_maxPressure;
}
if ((m_maxAzimuth > 0) && (m_maxAltitude > 0)) {
ORIENTATION ort = pkt.pkOrientation;
float vecLen;
float altRad, azmRad; /* In radians. */
/*
* From the wintab spec:
* orAzimuth: Specifies the clockwise rotation of the cursor about the z axis through a
* full circular range.
* orAltitude: Specifies the angle with the x-y plane through a signed, semicircular range.
* Positive values specify an angle upward toward the positive z axis; negative values
* specify an angle downward toward the negative z axis.
*
* wintab.h defines orAltitude as a UINT but documents orAltitude as positive for upward
* angles and negative for downward angles. WACOM uses negative altitude values to show that
* the pen is inverted; therefore we cast orAltitude as an (int) and then use the absolute
* value.
*/
/* Convert raw fixed point data to radians. */
altRad = (float)((fabs((float)ort.orAltitude) / (float)m_maxAltitude) * M_PI / 2.0);
azmRad = (float)(((float)ort.orAzimuth / (float)m_maxAzimuth) * M_PI * 2.0);
/* Find length of the stylus' projected vector on the XY plane. */
vecLen = cos(altRad);
/* From there calculate X and Y components based on azimuth. */
out.tabletData.Xtilt = sin(azmRad) * vecLen;
out.tabletData.Ytilt = (float)(sin(M_PI / 2.0 - azmRad) * vecLen);
}
out.time = pkt.pkTime;
/* Some Wintab libraries don't handle relative button input, so we track button presses
* manually. */
out.button = GHOST_kButtonMaskNone;
out.type = GHOST_kEventCursorMove;
DWORD buttonsChanged = m_buttons ^ pkt.pkButtons;
WORD buttonIndex = 0;
GHOST_WintabInfoWin32 buttonRef = out;
int buttons = 0;
while (buttonsChanged) {
if (buttonsChanged & 1) {
/* Find the index for the changed button from the button map. */
GHOST_TButtonMask button = mapWintabToGhostButton(pkt.pkCursor, buttonIndex);
if (button != GHOST_kButtonMaskNone) {
/* Extend output if multiple buttons are pressed. We don't extend input until we confirm
* a Wintab buttons maps to a system button. */
if (buttons > 0) {
outWintabInfo.resize(outWintabInfo.size() + 1);
outExtent++;
GHOST_WintabInfoWin32 &out = outWintabInfo[i + outExtent];
out = buttonRef;
}
buttons++;
out.button = button;
if (buttonsChanged & pkt.pkButtons) {
out.type = GHOST_kEventButtonDown;
}
else {
out.type = GHOST_kEventButtonUp;
}
}
m_buttons ^= 1 << buttonIndex;
}
buttonsChanged >>= 1;
buttonIndex++;
}
}
if (!outWintabInfo.empty()) {
m_lastTabletData = outWintabInfo.back().tabletData;
}
}
GHOST_TButtonMask GHOST_Wintab::mapWintabToGhostButton(UINT cursor, WORD physicalButton)
{
const WORD numButtons = 32;
BYTE logicalButtons[numButtons] = {0};
BYTE systemButtons[numButtons] = {0};
if (!m_fpInfo(WTI_CURSORS + cursor, CSR_BUTTONMAP, &logicalButtons) ||
!m_fpInfo(WTI_CURSORS + cursor, CSR_SYSBTNMAP, &systemButtons)) {
return GHOST_kButtonMaskNone;
}
if (physicalButton >= numButtons) {
return GHOST_kButtonMaskNone;
}
BYTE lb = logicalButtons[physicalButton];
if (lb >= numButtons) {
return GHOST_kButtonMaskNone;
}
switch (systemButtons[lb]) {
case SBN_LCLICK:
return GHOST_kButtonMaskLeft;
case SBN_RCLICK:
return GHOST_kButtonMaskRight;
case SBN_MCLICK:
return GHOST_kButtonMaskMiddle;
default:
return GHOST_kButtonMaskNone;
}
}
void GHOST_Wintab::mapWintabToSysCoordinates(int x_in, int y_in, int &x_out, int &y_out)
{
/* Maps from range [in.org, in.org + abs(in.ext)] to [out.org, out.org + abs(out.ext)], in
* reverse if in.ext and out.ext have differing sign. */
auto remap = [](int inPoint, Range in, Range out) -> int {
int absInExt = abs(in.ext);
int absOutExt = abs(out.ext);
/* Translate input from range [in.org, in.org + absInExt] to [0, absInExt] */
int inMagnitude = inPoint - in.org;
/* If signs of extents differ, reverse input over range. */
if ((in.ext < 0) != (out.ext < 0)) {
inMagnitude = absInExt - inMagnitude;
}
/* Scale from [0, absInExt] to [0, absOutExt]. */
int outMagnitude = inMagnitude * absOutExt / absInExt;
/* Translate from range [0, absOutExt] to [out.org, out.org + absOutExt]. */
int outPoint = outMagnitude + out.org;
return outPoint;
};
x_out = remap(x_in, m_tabletCoord.x, m_systemCoord.x);
y_out = remap(y_in, m_tabletCoord.y, m_systemCoord.y);
}
bool GHOST_Wintab::trustCoordinates()
{
return m_coordTrusted;
}
bool GHOST_Wintab::testCoordinates(int sysX, int sysY, int wtX, int wtY)
{
mapWintabToSysCoordinates(wtX, wtY, wtX, wtY);
/* Allow off by one pixel tolerance in case of rounding error. */
if (abs(sysX - wtX) <= 1 && abs(sysY - wtY) <= 1) {
m_coordTrusted = true;
return true;
}
else {
m_coordTrusted = false;
return false;
}
}

View File

@@ -0,0 +1,250 @@
/*
* 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.
*/
/** \file
* \ingroup GHOST
* Declaration of GHOST_WintabWin32 class.
*/
/* Wacom's Wintab documentation is periodically offline, moved, and increasingly hidden away. You
* can find a (painstakingly) archived copy of the documentation at
* https://web.archive.org/web/20201122230125/https://developer-docs-legacy.wacom.com/display/DevDocs/Windows+Wintab+Documentation
*/
#pragma once
#include <memory>
#include <vector>
#include <wtypes.h>
#include "GHOST_Types.h"
#include <wintab.h>
/* PACKETDATA and PACKETMODE modify structs in pktdef.h, so make sure they come first. */
#define PACKETDATA \
(PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR | PK_X | PK_Y | PK_TIME)
#define PACKETMODE 0
#include <pktdef.h>
/* Typedefs for Wintab functions to allow dynamic loading. */
typedef UINT(API *GHOST_WIN32_WTInfo)(UINT, UINT, LPVOID);
typedef BOOL(API *GHOST_WIN32_WTGet)(HCTX, LPLOGCONTEXTA);
typedef BOOL(API *GHOST_WIN32_WTSet)(HCTX, LPLOGCONTEXTA);
typedef HCTX(API *GHOST_WIN32_WTOpen)(HWND, LPLOGCONTEXTA, BOOL);
typedef BOOL(API *GHOST_WIN32_WTClose)(HCTX);
typedef int(API *GHOST_WIN32_WTPacketsGet)(HCTX, int, LPVOID);
typedef int(API *GHOST_WIN32_WTQueueSizeGet)(HCTX);
typedef BOOL(API *GHOST_WIN32_WTQueueSizeSet)(HCTX, int);
typedef BOOL(API *GHOST_WIN32_WTEnable)(HCTX, BOOL);
typedef BOOL(API *GHOST_WIN32_WTOverlap)(HCTX, BOOL);
/* Typedefs for Wintab and Windows resource management. */
typedef std::unique_ptr<std::remove_pointer_t<HMODULE>, decltype(&::FreeLibrary)> unique_hmodule;
typedef std::unique_ptr<std::remove_pointer_t<HCTX>, GHOST_WIN32_WTClose> unique_hctx;
struct GHOST_WintabInfoWin32 {
GHOST_TInt32 x, y;
GHOST_TEventType type;
GHOST_TButtonMask button;
GHOST_TUns64 time;
GHOST_TabletData tabletData;
};
class GHOST_Wintab {
public:
/**
* Loads Wintab if available.
* \param hwnd: Window to attach Wintab context to.
*/
static GHOST_Wintab *loadWintab(HWND hwnd);
/**
* Enables Wintab context.
*/
void enable();
/**
* Disables the Wintab context and unwinds Wintab state.
*/
void disable();
/**
* Brings Wintab context to the top of the overlap order.
*/
void gainFocus();
/**
* Puts Wintab context at bottom of overlap order and unwinds Wintab state.
*/
void loseFocus();
/**
* Clean up when Wintab leaves tracking range.
*/
void leaveRange();
/**
* Handle Wintab coordinate changes when DisplayChange events occur.
*/
void remapCoordinates();
/**
* Maps Wintab to Win32 display coordinates.
* \param x_in: The tablet x coordinate.
* \param y_in: The tablet y coordinate.
* \param x_out: Output for the Win32 mapped x coordinate.
* \param y_out: Output for the Win32 mapped y coordinate.
*/
void mapWintabToSysCoordinates(int x_in, int y_in, int &x_out, int &y_out);
/**
* Updates cached Wintab properties for current cursor.
*/
void updateCursorInfo();
/**
* Handle Wintab info changes such as change in number of connected tablets.
* \param lParam: LPARAM of the event.
*/
void processInfoChange(LPARAM lParam);
/**
* Whether Wintab devices are present.
* \return True if Wintab devices are present.
*/
bool devicesPresent();
/**
* Translate Wintab packets into GHOST_WintabInfoWin32 structs.
* \param outWintabInfo: Storage to return resulting GHOST_WintabInfoWin32 data.
*/
void getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo);
/**
* Whether Wintab coordinates should be trusted.
* \return True if Wintab coordinates should be trusted.
*/
bool trustCoordinates();
/**
* Tests whether Wintab coordinates can be trusted by comparing Win32 and Wintab reported cursor
* position.
* \param sysX: System cursor x position.
* \param sysY: System cursor y position.
* \param wtX: Wintab cursor x position.
* \param wtY: Wintab cursor y position.
* \return True if Win32 and Wintab cursor positions match within tolerance.
*
* Note: Only test coordinates on button press, not release. This prevents issues when async
* mismatch causes mouse movement to replay and snap back, which is only an issue while drawing.
*/
bool testCoordinates(int sysX, int sysY, int wtX, int wtY);
/**
* Retrieve the most recent tablet data, or none if pen is not in range.
* \return Most recent tablet data, or none if pen is not in range.
*/
GHOST_TabletData getLastTabletData();
private:
/** Wintab DLL handle. */
unique_hmodule m_handle;
/** Wintab API functions. */
GHOST_WIN32_WTInfo m_fpInfo = nullptr;
GHOST_WIN32_WTGet m_fpGet = nullptr;
GHOST_WIN32_WTSet m_fpSet = nullptr;
GHOST_WIN32_WTPacketsGet m_fpPacketsGet = nullptr;
GHOST_WIN32_WTEnable m_fpEnable = nullptr;
GHOST_WIN32_WTOverlap m_fpOverlap = nullptr;
/** Stores the Wintab tablet context. */
unique_hctx m_context;
/** Whether the context is enabled. */
bool m_enabled = false;
/** Whether the context has focus and is at the top of overlap order. */
bool m_focused = false;
/** Pressed button map. */
GHOST_TUns8 m_buttons = 0;
/** Range of a coordinate space. */
struct Range {
/** Origin of range. */
int org = 0;
/** Extent of range. */
int ext = 1;
};
/** 2D Coordinate space. */
struct Coord {
/** Range of x. */
Range x = {};
/** Range of y. */
Range y = {};
};
/** Whether Wintab coordinates are trusted. */
bool m_coordTrusted = false;
/** Tablet input range. */
Coord m_tabletCoord = {};
/** System output range. */
Coord m_systemCoord = {};
int m_maxPressure = 0;
int m_maxAzimuth = 0;
int m_maxAltitude = 0;
/** Number of connected Wintab devices. */
UINT m_numDevices = 0;
/** Reusable buffer to read in Wintab packets. */
std::vector<PACKET> m_pkts;
/** Most recently received tablet data, or none if pen is not in range. */
GHOST_TabletData m_lastTabletData = GHOST_TABLET_DATA_NONE;
GHOST_Wintab(HWND hwnd,
unique_hmodule handle,
GHOST_WIN32_WTInfo info,
GHOST_WIN32_WTGet get,
GHOST_WIN32_WTSet set,
GHOST_WIN32_WTPacketsGet packetsGet,
GHOST_WIN32_WTEnable enable,
GHOST_WIN32_WTOverlap overlap,
unique_hctx hctx,
Coord tablet,
Coord system,
int queueSize);
/**
* Convert Wintab system mapped (mouse) buttons into Ghost button mask.
* \param cursor: The Wintab cursor associated to the button.
* \param physicalButton: The physical button ID to inspect.
* \return The system mapped button.
*/
GHOST_TButtonMask mapWintabToGhostButton(UINT cursor, WORD physicalButton);
/**
* Applies common modifications to Wintab context.
* \param lc: Wintab context to modify.
*/
static void modifyContext(LOGCONTEXT &lc);
/**
* Extracts tablet and system coordinates from Wintab context.
* \param lc: Wintab context to extract coordinates from.
* \param tablet: Tablet coordinates.
* \param system: System coordinates.
*/
static void extractCoordinates(LOGCONTEXT &lc, Coord &tablet, Coord &system);
};

View File

@@ -392,9 +392,10 @@ GHOST_XrActionSet::GHOST_XrActionSet(XrInstance instance, const GHOST_XrActionSe
{
XrActionSetCreateInfo action_set_info{XR_TYPE_ACTION_SET_CREATE_INFO};
strcpy(action_set_info.actionSetName, info.name);
strcpy(action_set_info.localizedActionSetName,
info.name); /* Just use same name for localized. This can be changed in the future if
necessary. */
/* Just use same name for localized. This can be changed in the future if necessary. */
strcpy(action_set_info.localizedActionSetName, info.name);
action_set_info.priority = 0; /* Use same (default) priority for all action sets. */
CHECK_XR(xrCreateActionSet(instance, &action_set_info, &m_action_set),

View File

@@ -420,6 +420,11 @@ void GHOST_XrContext::getExtensionsToEnable(
r_ext_names.push_back(gpu_binding);
}
#if defined(WITH_GHOST_X11) && defined(WITH_GL_EGL)
assert(openxr_extension_is_available(m_oxr->extensions, XR_MNDX_EGL_ENABLE_EXTENSION_NAME));
r_ext_names.push_back(XR_MNDX_EGL_ENABLE_EXTENSION_NAME);
#endif
for (const std::string_view &ext : try_ext) {
if (openxr_extension_is_available(m_oxr->extensions, ext)) {
r_ext_names.push_back(ext.data());

View File

@@ -22,7 +22,15 @@
#include <list>
#include <sstream>
#if defined(WITH_GHOST_X11)
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
# if defined(WITH_GHOST_X11)
# include "GHOST_SystemX11.h"
# endif
# if defined(WITH_GHOST_WAYLAND)
# include "GHOST_SystemWayland.h"
# endif
#elif defined(WITH_GHOST_X11)
# include "GHOST_ContextGLX.h"
#elif defined(WIN32)
# include "GHOST_ContextD3D.h"
@@ -66,7 +74,9 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
XrSystemId system_id,
std::string *r_requirement_info) const override
{
#if defined(WITH_GHOST_X11)
#if defined(WITH_GL_EGL)
GHOST_ContextEGL &ctx_gl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
#elif defined(WITH_GHOST_X11)
GHOST_ContextGLX &ctx_gl = static_cast<GHOST_ContextGLX &>(ghost_ctx);
#else
GHOST_ContextWGL &ctx_gl = static_cast<GHOST_ContextWGL &>(ghost_ctx);
@@ -106,6 +116,17 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
void initFromGhostContext(GHOST_Context &ghost_ctx) override
{
#if defined(WITH_GHOST_X11)
# if defined(WITH_GL_EGL)
GHOST_ContextEGL &ctx_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
if (dynamic_cast<const GHOST_SystemX11 *const>(ctx_egl.m_system)) {
oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
oxr_binding.egl.getProcAddress = eglGetProcAddress;
oxr_binding.egl.display = ctx_egl.getDisplay();
oxr_binding.egl.config = ctx_egl.getConfig();
oxr_binding.egl.context = ctx_egl.getContext();
}
# else
GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx);
XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig);
@@ -117,6 +138,7 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
oxr_binding.glx.visualid = visual_info->visualid;
XFree(visual_info);
# endif
#elif defined(WIN32)
GHOST_ContextWGL &ctx_wgl = static_cast<GHOST_ContextWGL &>(ghost_ctx);
@@ -125,6 +147,14 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
oxr_binding.wgl.hGLRC = ctx_wgl.m_hGLRC;
#endif
#if defined(WITH_GHOST_WAYLAND)
GHOST_ContextEGL &ctx_wl_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
if (dynamic_cast<const GHOST_SystemWayland *const>(ctx_wl_egl.m_system)) {
oxr_binding.wl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR;
oxr_binding.wl.display = (struct wl_display *)ctx_wl_egl.m_nativeDisplay;
}
#endif
/* Generate a frame-buffer to use for blitting into the texture. */
glGenFramebuffers(1, &m_fbo);
}

View File

@@ -74,10 +74,11 @@ class GHOST_XrSession {
const GHOST_XrActionProfileInfo *infos);
bool attachActionSets();
/** Action functions to be called post-session start. */
bool syncActions(
const char *action_set_name = nullptr); /* If action_set_name is nullptr, all attached
* action sets will be synced. */
/**
* Action functions to be called post-session start.
* \param action_set_name: When `nullptr`, all attached action sets will be synced.
*/
bool syncActions(const char *action_set_name = nullptr);
bool applyHapticAction(const char *action_set_name,
const char *action_name,
const GHOST_TInt64 &duration,

View File

@@ -42,7 +42,13 @@
# include <d3d12.h>
#endif
#ifdef WITH_GHOST_X11
# include <GL/glxew.h>
# ifdef WITH_GL_EGL
/* TODO: Why do we have to create this typedef manually? */
typedef void (*(*PFNEGLGETPROCADDRESSPROC)(const char *procname))(void);
# include <GL/eglew.h>
# else
# include <GL/glxew.h>
# endif
#endif
#include <openxr/openxr.h>

View File

@@ -78,7 +78,7 @@ extern short (*MEM_testN)(void *vmemh);
/**
* Duplicates a block of memory, and returns a pointer to the
* newly allocated block. */
* newly allocated block. */
extern void *(*MEM_dupallocN)(const void *vmemh) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT;
/**

View File

@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
/* ----------------------------------------------------------------- */
/* Round two, do a normal allocation, and corrupt some blocks. */
/* ----------------------------------------------------------------- */
/* switch off, because it will complain about some things. */
/* Switch off, because it will complain about some things. */
MEM_set_error_callback(NULL);
for (i = 0; i < NUM_BLOCKS; i++) {
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
p[i] = MEM_callocN(blocksize, strdup(tagstring));
}
/* now corrupt a few blocks...*/
/* Now corrupt a few blocks. */
ip = (int *)p[5] - 50;
for (i = 0; i < 1000; i++, ip++)
*ip = i + 1;

Some files were not shown because too many files have changed in this diff Show More