Compare commits

..

115 Commits

Author SHA1 Message Date
d85adbe929 Tweak settings to reduce max. node scroll speed.
Reduced the max. speed when edge-panning in the node editor
from 70 to 40 UI units.
Increased the fade-in delay from 0.6 to 1.0 seconds.
2021-06-07 16:25:48 +01:00
f1f53f9122 Merge branch 'master' into node-editor-edge-pan 2021-06-07 15:01:44 +01:00
91d3a54869 Fix build error, remove duplicate include. 2021-06-07 19:11:36 +05:30
542aed8d55 Merge branch 'master' into node-editor-edge-pan 2021-06-07 14:20:10 +01:00
ee0000b8bb LineArt: Shifting fix for different camera fitting.
FOV was expanded to cover the shifting range,
rather than to precisely cut at the image border. Now fixed.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11523
2021-06-07 21:07:17 +08:00
7f1d1b03ad Cleanup: Fix uninitialized variable warning 2021-06-07 07:54:49 -05:00
abee9a85d4 Cleanup: renamed function to extract_run_single_threaded. 2021-06-07 13:51:47 +02:00
Germano Cavalcante
223016a408 GPUIndexBuf: Find the minimum and maximum index through the builder
Moving the bounds code to the builder can be useful
for future optimizations like building multithreaded.

Reviewed By: fclem, jbakker

Differential Revision: https://developer.blender.org/D11455
2021-06-07 08:41:38 -03:00
6e6a1838ea Cleanup: Added Guarderalloc deallocators to CPP structs. 2021-06-07 13:34:30 +02:00
1d3ffc93ec Added TODO comment for putting parameters into struct. 2021-06-07 13:31:09 +02:00
e517aaa136 Cleanup: move extract points into own compile unit. 2021-06-07 13:27:38 +02:00
8b8c3c34dd Fix T88900: Crash when setting Edge Weight/Crease
The `recalcData` of "convert_mesh_edge" did more
than it was supposed to.
2021-06-07 07:52:34 -03:00
4f6cab176a Cleanup: remove trailing space from pipeline_config.json
Remove trailing spaces from `pipeline_config.json`

No functional changes.
2021-06-07 11:36:26 +02:00
98876d46ef Fix T88899: __file__ not set for text.as_module() 2021-06-07 14:04:26 +10:00
7ef2b760dc 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-06 23:05:46 +10:00
c27b7df563 Cleanup: unused argument 2021-06-06 23:03:34 +10:00
a496af8680 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-06 11:18:18 +08:00
54ce344bc7 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-06 03:05:45 +02:00
dbfde0fe70 Exact Boolean: fix last commit: pass an arg by reference instead of value. 2021-06-05 14:17:15 -07:00
8e43ef5f31 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-05 11:31:08 -07:00
edaaa2afdd 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-05 16:29:46 +03:00
d2dc452333 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-05 16:29:46 +03:00
2cd1bc3aa7 Fix T88859: Assert when changing view modes
The `loose_lines`' ibo was not being initialized.
2021-06-05 09:49:48 -03:00
1a912462f4 BMesh: avoid extra faces-of-edges loop building partial update data 2021-06-05 21:33:15 +10:00
bcf9c73cbc Fix assert check in BLI_polyfill_beautify 2021-06-05 17:16:37 +10:00
3c9c557580 Fix assert in gpencil_batches_ensure 2021-06-05 17:13:12 +10:00
c7fee64dea Cleanup: use ternary operator for icon argument 2021-06-05 17:05:11 +10:00
ca3891e83b Fix T88828: View/Navigation(Walk/Fly) disappeared from keymap
This was unintentionally removed in
f92f5d1ac6.
2021-06-05 15:06:48 +10:00
a5114bfb85 Cleanup: indentation 2021-06-05 15:06:47 +10:00
022f8b552d Cleanup: spelling in comments
Also remove reference to function that never existed for adding `bNode`.
2021-06-05 15:03:59 +10:00
14508ef100 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-05 02:48:09 +02:00
bfaf09b5bc 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-04 17:22:31 -06:00
c2fa36999f 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-05 08:35:31 +10:00
Charlie Jolly
00073651d4 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-04 16:59:28 +01:00
eb030204f1 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-04 09:16:03 -06:00
Philipp Oeser
56005ef499 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-04 16:02:02 +02:00
b6d6d8a1aa 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-04 15:54:07 +02:00
0037e08b06 GPencil: Change Fill Boundary icon
The icon has been changed to `eye` because is more consistent with other areas.
2021-06-04 12:44:34 +02:00
b6b20c4d92 GPencil: Change Fill extend lines icon
The icon has been changed to `eye` because is more consistent with other areas.
2021-06-04 12:44:34 +02:00
Fynn Grotehans
d486ee2dbd 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-04 12:19:58 +02:00
9ba6b64efa 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-04 12:17:33 +02:00
e4ca6b93ad 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-04 12:09:05 +02:00
77d7cae266 GPencil: Cleanup unneeded variable assign
The variable is assigned below again and the initial value is not used.
2021-06-04 10:44:01 +02:00
f4e0a19d4f 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-04 10:34:05 +02:00
053082e9d8 Math: Added max_uu/min_uu variations. 2021-06-04 09:14:15 +02:00
Johnny Matthews
ddd4b2b785 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-03 19:12:38 -04:00
e5a1cadb2f 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-03 18:33:37 -04:00
c18675b12c 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-03 18:06:31 -04:00
dba3fb9e09 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-03 20:17:17 +02:00
3e695a27cd 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-03 19:58:36 +02:00
a1063fc6c2 VSE: Remove JPEG reference from proxy panel
Proxies doesn't use MJPEG codec anymore, but text still referenced it.
2021-06-03 19:44:00 +02:00
b414322f26 GHOST/wayland: fix restoring hidden cursor 2021-06-03 18:18:27 +01:00
899eefd1bb GHOST/wayland: fix non-moving normal cursor 2021-06-03 18:18:27 +01:00
72607feb91 GHOST/wayland: add 'xdg-decoration' support 2021-06-03 18:18:27 +01:00
870bcf6e1a GHOST/wayland: adapt window and cursor surface scale to support HiDPI screens 2021-06-03 18:18:27 +01:00
8b78510fc4 GHOST/wayland: handle return values for data sources 2021-06-03 18:18:27 +01:00
e0bc5c4087 GHOST/wayland: set parent relation only for dialogs to mimic X11 behaviour 2021-06-03 18:18:27 +01:00
1fd653dd82 GHOST/wayland: handle missing relative-pointer and pointer-constraints support 2021-06-03 18:18:27 +01:00
d9aae38bc8 GHOST/wayland: get cursor settings via D-Bus 2021-06-03 18:18:27 +01:00
efad9bcdda GHOST/wayland: inhibit warning 2021-06-03 18:18:27 +01:00
b5d7fb813f cmake: use absolute path for Wayland libraries 2021-06-03 18:18:27 +01:00
bb16f96973 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-03 18:18:27 +01:00
7197017ea9 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-04 01:18:23 +10:00
ed6fd01ba9 LibOverride: fix previous commit (rB826bed4349fa). 2021-06-03 16:44:20 +02:00
826bed4349 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-03 16:12:26 +02:00
797f6e1483 Fix missing updates in RNA override create functions. 2021-06-03 15:44:23 +02:00
e011e4ce76 LibOverride: Add override_hierarchy_createto ID's RNA API. 2021-06-03 15:00:50 +02:00
92f8a6ac21 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-03 14:16:53 +02:00
7b8d812277 Cleanup: make format 2021-06-03 13:33:09 +02:00
2ae4e860f6 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-03 10:27:05 +02:00
2ef192a55b 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-03 10:27:05 +02:00
a51f8f94d5 Cleanup: use ascii characters instead of unicode where possible
Follow own code style docs.
2021-06-03 11:32:53 +10:00
17f72be3cb Cleanup: spelling in comments, correct outdated comments 2021-06-03 10:47:02 +10:00
2a868d277e Cleanup: use doxy sections for node_relationships.cc 2021-06-03 10:35:46 +10:00
b60a72eaab Fix invalid return values from file_execute
Error in 6c8c30d865
2021-06-03 10:23:40 +10:00
2dcb6782e0 Draw Mesh Extractor: Fix used thread count
Some threads were always idle because of this.
2021-06-02 18:05:58 -03:00
4d64de2853 Cleanup: Remove unused 'ExtractTaskData's members 2021-06-02 17:55:25 -03:00
5af7225816 Cleanup: Fix build warnings 2021-06-02 21:52:36 +02:00
925df8ef26 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-02 21:41:38 +02:00
2ee575fc1f 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-02 21:41:17 +02:00
1f55786791 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-02 21:29:38 +02:00
a9dfde7b49 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-02 21:25:37 +02:00
0ea0ccc4ff 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-02 21:24:09 +02:00
81366b7d2c 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-02 12:08:46 -07:00
dc960a81d1 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-02 11:18:00 -07:00
4f8edc8e7f 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-02 17:20:46 +02:00
b8ae30e9e3 Cleanup: unused variable 2021-06-03 01:12:00 +10:00
ae28ceb9d8 Fix swapped x/y in event simulation script
Incorrect area center calculation, also correct comments.
2021-06-03 01:11:47 +10:00
05b685989b 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-02 11:11:34 -04:00
7654203cc8 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-02 16:58:36 +02:00
2489f72d79 Revert "EEVEE: AOVs not same as cycles."
This reverts commit 730a46e87d.
2021-06-02 16:56:10 +02:00
730a46e87d 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-02 16:54:01 +02:00
f944121700 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-02 16:43:37 +02:00
21de669141 Splines: Function to copy spline settings without data
Often you need to copy a spline to do an operation, but don't want
to manually copy over all of the settings. I've already forgotten to
do it once anyway. These functions copy a spline's "settings" into a
new spline, but not the data. I tried to avoid duplicating any copying
so this is easier to extend in the future.

Differential Revision: https://developer.blender.org/D11463
2021-06-02 09:11:35 -04:00
5b176b66da LineArt: Tolerance for faces perpendicular to view
This is due to cam->obmat precision issue,
where it affects view vector precision.

Reviewed by Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11461
2021-06-02 20:55:54 +08:00
a55b73417f Cleanup: Correct comments
This corrects an outdated comment in the vector header and a typo
in the index mask header.
2021-06-02 08:28:46 -04:00
ea6d099082 Cleanup: Clang format 2021-06-02 08:27:53 -04:00
34f99bc6be Geometry Nodes: Allow reading converted attribute directly from spline
Often it would be beneficial to avoid the virtual array implementation
in `geometry_component_curve.cc` that flattens an attribute for every
spline and instead read an attribute separately for every input spline.
This commit implements functions to do that.

The downside is some code duplication-- we now have two places handling
this conversion. However, we can head in this general direction for the
attribute API anyway and support accessing attributes in smaller
contiguous chunks where necessary.

No functional changes in this commit.

Differential Revision: https://developer.blender.org/D11456
2021-06-02 08:24:42 -04:00
e65a0ee1e1 Merge branch 'master' into node-editor-edge-pan 2021-05-03 11:34:49 +01:00
f186e7f47f Only apply edge panning in translation mode. 2021-04-28 17:19:19 +01:00
594bdf1cc0 Longer edge pan delay and higher max speed. 2021-04-28 17:13:37 +01:00
9be38c1fbf Clean up comments. 2021-04-28 16:53:16 +01:00
e1418ad7a1 Remove unused include. 2021-04-28 16:45:51 +01:00
f964d80b82 Define edge-pan defaults on operator properties.
Use the UI_view2d_edge_pan_operator_properties_ex function to define
operator property defaults for edge panning, rather than setting fixed
values after the operator is created. That way the defaults can still
be changed by users in keymaps as one would expect from an operator.
2021-04-28 10:52:53 +01:00
a967780fd7 Add transform option to disable cursor wrapping.
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).
2021-04-25 16:29:40 +01:00
c6ae967059 Fix region-based mouse coordinates for panning. 2021-04-24 12:42:08 +01:00
d2e9ce2a46 Tweak node panning settings. 2021-04-24 11:36:21 +01:00
ab333aaac5 Take v2d change into account in node transforms.
Store the initial v2d->cur rect, then apply the difference as transform
to nodes during transform. This ensures nodes are moving along with the
view rect when edge panning in the node editor.
2021-04-24 11:20:46 +01:00
d8c24c165f Basic support for edge pan in node transforms.
Nodes currently are stuck to the 2D view rect, so when edge panning they
don't move with the view and fall behind.
2021-04-24 09:42:22 +01:00
687b653797 Edge pan apply function does not need operator. 2021-04-24 09:12:58 +01:00
a5f221cc2f Use operator props for configuring edge panning. 2021-04-23 18:46:54 +01:00
fa01599de7 Re-use the new edge pan API for existing operator. 2021-04-23 13:18:15 +01:00
cfbf277e37 Make edge pan behavior configurable. 2021-04-23 12:31:52 +01:00
76bfcb34fb Moved edge pan functions into a public UI header.
Edge panning operator customdata and supporting functions now in
UI_view2d.h, so they could be used by operators in other editor
libraries.
2021-04-20 09:21:07 +01:00
Lukas Tönne
b67c7f89ff Edge-scrolling for node "link" operator.
Largely copied from the VIEW2D_OT_edge_pan
operator. Starts scrolling when dragging a node
link and going outside the current window.
2021-04-19 08:32:58 +01:00
298 changed files with 5156 additions and 2520 deletions

View File

@@ -43,6 +43,12 @@ endif()
if(WIN32)
set(EMBREE_BUILD_DIR ${BUILD_MODE}/)
if(BUILD_MODE STREQUAL Debug)
list(APPEND EMBREE_EXTRA_ARGS
-DEMBREE_TBBMALLOC_LIBRARY_NAME=tbbmalloc_debug
-DEMBREE_TBB_LIBRARY_NAME=tbb_debug
)
endif()
else()
set(EMBREE_BUILD_DIR)
endif()

View File

@@ -22,6 +22,7 @@ if(WIN32)
-DTBB_BUILD_TBBMALLOC_PROXY=On
-DTBB_BUILD_STATIC=Off
-DTBB_BUILD_TESTS=Off
-DCMAKE_DEBUG_POSTFIX=_debug
)
set(TBB_LIBRARY tbb)
set(TBB_STATIC_LIBRARY Off)
@@ -55,17 +56,17 @@ if(WIN32)
ExternalProject_Add_Step(external_tbb after_install
# findtbb.cmake in some deps *NEEDS* to find tbb_debug.lib even if they are not going to use it
# to make that test pass, we place a copy with the right name in the lib folder.
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.dll ${HARVEST_TARGET}/tbb/lib/tbb_debug.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.dll ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${LIBDIR}/tbb/lib/tbb_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbb.dll ${LIBDIR}/tbb/bin/tbb_debug.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc.dll ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll
# Normal collection of build artifacts
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.dll ${HARVEST_TARGET}/tbb/lib/tbb.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbb.dll ${HARVEST_TARGET}/tbb/bin/tbb.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.dll ${HARVEST_TARGET}/tbb/lib/tbbmalloc.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.dll ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc_proxy.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy.dll
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tbb/include/ ${HARVEST_TARGET}/tbb/include/
DEPENDEES install
)
@@ -76,11 +77,11 @@ if(WIN32)
# to make that test pass, we place a copy with the right name in the lib folder.
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_debug.lib ${LIBDIR}/tbb/lib/tbb.lib
# Normal collection of build artifacts
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_debug.lib ${HARVEST_TARGET}/tbb/lib/debug/tbb_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_debug.dll ${HARVEST_TARGET}/tbb/lib/debug/tbb_debug.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy_debug.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.dll ${HARVEST_TARGET}/tbb/lib/debug/tbbmalloc.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.dll ${HARVEST_TARGET}/tbb/lib/debug/tbbmalloc_proxy.dll
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_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
DEPENDEES install
)
endif()

View File

@@ -596,14 +596,6 @@ function(SETUP_LIBDIRS)
link_directories(${GMP_LIBPATH})
endif()
if(WITH_GHOST_WAYLAND)
link_directories(
${wayland-client_LIBRARY_DIRS}
${wayland-egl_LIBRARY_DIRS}
${xkbcommon_LIBRARY_DIRS}
${wayland-cursor_LIBRARY_DIRS})
endif()
if(WIN32 AND NOT UNIX)
link_directories(${PTHREADS_LIBPATH})
endif()

View File

@@ -575,17 +575,17 @@ if(WITH_GHOST_WAYLAND)
pkg_check_modules(wayland-scanner REQUIRED wayland-scanner)
pkg_check_modules(xkbcommon REQUIRED xkbcommon)
pkg_check_modules(wayland-cursor REQUIRED wayland-cursor)
pkg_check_modules(dbus REQUIRED dbus-1)
set(WITH_GL_EGL ON)
if(WITH_GHOST_WAYLAND)
list(APPEND PLATFORM_LINKLIBS
${wayland-client_LIBRARIES}
${wayland-egl_LIBRARIES}
${xkbcommon_LIBRARIES}
${wayland-cursor_LIBRARIES}
)
endif()
list(APPEND PLATFORM_LINKLIBS
${wayland-client_LINK_LIBRARIES}
${wayland-egl_LINK_LIBRARIES}
${xkbcommon_LINK_LIBRARIES}
${wayland-cursor_LINK_LIBRARIES}
${dbus_LINK_LIBRARIES}
)
endif()
if(WITH_GHOST_X11)

View File

@@ -675,7 +675,7 @@ if(WITH_SYSTEM_AUDASPACE)
endif()
if(WITH_TBB)
set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/debug/tbb_debug.lib)
set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
if(WITH_TBB_MALLOC_PROXY)

View File

@@ -15,6 +15,15 @@ if(WITH_WINDOWS_BUNDLE_CRT)
include(InstallRequiredSystemLibraries)
# ucrtbase(d).dll cannot be in the manifest, due to the way windows 10 handles
# redirects for this dll, for details see T88813.
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
string(FIND ${lib} "ucrtbase" pos)
if(NOT pos EQUAL -1)
list(REMOVE_ITEM CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
install(FILES ${lib} DESTINATION . COMPONENT Libraries)
endif()
endforeach()
# Install the CRT to the blender.crt Sub folder.
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ./blender.crt COMPONENT Libraries)

View File

@@ -11,7 +11,7 @@
{ "path": "source/tools", "branch": "master", "commit_id": "HEAD" }
]
},
"svn":
"svn":
{
"tests": { "path": "lib/tests", "branch": "trunk", "commit_id": "HEAD" },
"libraries":
@@ -47,7 +47,7 @@
"cmake":
{
"default":
{
{
"version": "any",
"overrides":
{
@@ -58,28 +58,28 @@
{
"overrides":
{
}
},
"darwin-arm64":
{
"overrides":
{
}
},
"linux-x86_64":
{
"overrides":
{
}
},
"windows-amd64":
{
"overrides":
{
}
}
}

View File

@@ -52,6 +52,9 @@ shader node_vector_math(string math_type = "add",
else if (math_type == "faceforward") {
Vector = compatible_faceforward(Vector1, Vector2, Vector3);
}
else if (math_type == "multiply_add") {
Vector = Vector1 * Vector2 + Vector3;
}
else if (math_type == "dot_product") {
Value = dot(Vector1, Vector2);
}

View File

@@ -58,7 +58,8 @@ ccl_device void svm_node_vector_math(KernelGlobals *kg,
float3 vector;
/* 3 Vector Operators */
if (type == NODE_VECTOR_MATH_WRAP || type == NODE_VECTOR_MATH_FACEFORWARD) {
if (type == NODE_VECTOR_MATH_WRAP || type == NODE_VECTOR_MATH_FACEFORWARD ||
type == NODE_VECTOR_MATH_MULTIPLY_ADD) {
uint4 extra_node = read_node(kg, offset);
c = stack_load_float3(stack, extra_node.x);
}

View File

@@ -52,6 +52,9 @@ ccl_device void svm_vector_math(float *value,
case NODE_VECTOR_MATH_FACEFORWARD:
*vector = faceforward(a, b, c);
break;
case NODE_VECTOR_MATH_MULTIPLY_ADD:
*vector = a * b + c;
break;
case NODE_VECTOR_MATH_DOT_PRODUCT:
*value = dot(a, b);
break;

View File

@@ -341,6 +341,7 @@ typedef enum NodeVectorMathType {
NODE_VECTOR_MATH_TANGENT,
NODE_VECTOR_MATH_REFRACT,
NODE_VECTOR_MATH_FACEFORWARD,
NODE_VECTOR_MATH_MULTIPLY_ADD,
} NodeVectorMathType;
typedef enum NodeClampType {

View File

@@ -6093,6 +6093,7 @@ NODE_DEFINE(VectorMathNode)
type_enum.insert("reflect", NODE_VECTOR_MATH_REFLECT);
type_enum.insert("refract", NODE_VECTOR_MATH_REFRACT);
type_enum.insert("faceforward", NODE_VECTOR_MATH_FACEFORWARD);
type_enum.insert("multiply_add", NODE_VECTOR_MATH_MULTIPLY_ADD);
type_enum.insert("dot_product", NODE_VECTOR_MATH_DOT_PRODUCT);
@@ -6165,7 +6166,8 @@ void VectorMathNode::compile(SVMCompiler &compiler)
int vector_stack_offset = compiler.stack_assign_if_linked(vector_out);
/* 3 Vector Operators */
if (math_type == NODE_VECTOR_MATH_WRAP || math_type == NODE_VECTOR_MATH_FACEFORWARD) {
if (math_type == NODE_VECTOR_MATH_WRAP || math_type == NODE_VECTOR_MATH_FACEFORWARD ||
math_type == NODE_VECTOR_MATH_MULTIPLY_ADD) {
ShaderInput *vector3_in = input("Vector3");
int vector3_stack_offset = compiler.stack_assign(vector3_in);
compiler.add_node(

View File

@@ -282,6 +282,7 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
${wayland-egl_INCLUDE_DIRS}
${xkbcommon_INCLUDE_DIRS}
${wayland-cursor_INCLUDE_DIRS}
${dbus_INCLUDE_DIRS}
)
list(APPEND SRC
@@ -321,6 +322,11 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
xdg-shell
"${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml"
)
# xdg-decoration.
generate_protocol_bindings(
xdg-decoration
"${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
)
# Pointer-constraints.
generate_protocol_bindings(
pointer-constraints

View File

@@ -40,6 +40,7 @@
#include <unordered_map>
#include <unordered_set>
#include "GHOST_WaylandCursorSettings.h"
#include <pointer-constraints-client-protocol.h>
#include <relative-pointer-client-protocol.h>
#include <wayland-cursor.h>
@@ -52,15 +53,6 @@
#include <cstring>
struct output_t {
struct wl_output *output;
int32_t width, height;
int transform;
int scale;
std::string make;
std::string model;
};
struct buffer_t {
void *data;
size_t size;
@@ -72,6 +64,12 @@ struct cursor_t {
struct wl_buffer *buffer;
struct wl_cursor_image image;
struct buffer_t *file_buffer = nullptr;
struct wl_cursor_theme *theme = nullptr;
int size;
std::string theme_name;
// outputs on which the cursor is visible
std::unordered_set<const output_t *> outputs;
int scale = 1;
};
struct data_offer_t {
@@ -142,10 +140,14 @@ struct display_t {
struct wl_display *display;
struct wl_compositor *compositor = nullptr;
struct xdg_wm_base *xdg_shell = nullptr;
struct zxdg_decoration_manager_v1 *xdg_decoration_manager = nullptr;
struct wl_shm *shm = nullptr;
std::vector<output_t *> outputs;
std::vector<input_t *> inputs;
struct wl_cursor_theme *cursor_theme = nullptr;
struct {
std::string theme;
int size;
} cursor;
struct wl_data_device_manager *data_device_manager = nullptr;
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager = nullptr;
struct zwp_pointer_constraints_v1 *pointer_constraints = nullptr;
@@ -154,6 +156,8 @@ struct display_t {
std::vector<struct wl_egl_window *> os_egl_windows;
};
static GHOST_WindowManager *window_manager = nullptr;
static void display_destroy(display_t *d)
{
if (d->data_device_manager) {
@@ -188,6 +192,9 @@ static void display_destroy(display_t *d)
if (input->cursor.surface) {
wl_surface_destroy(input->cursor.surface);
}
if (input->cursor.theme) {
wl_cursor_theme_destroy(input->cursor.theme);
}
if (input->pointer) {
wl_pointer_destroy(input->pointer);
}
@@ -210,10 +217,6 @@ static void display_destroy(display_t *d)
delete input;
}
if (d->cursor_theme) {
wl_cursor_theme_destroy(d->cursor_theme);
}
if (d->shm) {
wl_shm_destroy(d->shm);
}
@@ -238,6 +241,10 @@ static void display_destroy(display_t *d)
wl_compositor_destroy(d->compositor);
}
if (d->xdg_decoration_manager) {
zxdg_decoration_manager_v1_destroy(d->xdg_decoration_manager);
}
if (d->xdg_shell) {
xdg_wm_base_destroy(d->xdg_shell);
}
@@ -478,7 +485,9 @@ static void dnd_events(const input_t *const input, const GHOST_TEventType event)
static std::string read_pipe(data_offer_t *data_offer, const std::string mime_receive)
{
int pipefd[2];
pipe(pipefd);
if (pipe(pipefd) != 0) {
return {};
}
wl_data_offer_receive(data_offer->id, mime_receive.c_str(), pipefd[1]);
close(pipefd[1]);
@@ -513,7 +522,9 @@ static void data_source_send(void *data,
int32_t fd)
{
const char *const buffer = static_cast<char *>(data);
write(fd, buffer, strlen(buffer) + 1);
if (write(fd, buffer, strlen(buffer) + 1) < 0) {
GHOST_PRINT("error writing to clipboard: " << std::strerror(errno) << std::endl);
}
close(fd);
}
@@ -789,13 +800,80 @@ static void cursor_buffer_release(void *data, struct wl_buffer *wl_buffer)
cursor_t *cursor = static_cast<cursor_t *>(data);
wl_buffer_destroy(wl_buffer);
cursor->buffer = nullptr;
if (wl_buffer == cursor->buffer) {
/* the mapped buffer was from a custom cursor */
cursor->buffer = nullptr;
}
}
const struct wl_buffer_listener cursor_buffer_listener = {
cursor_buffer_release,
};
static GHOST_IWindow *get_window(struct wl_surface *surface)
{
if (!surface) {
return nullptr;
}
for (GHOST_IWindow *win : window_manager->getWindows()) {
if (surface == static_cast<const GHOST_WindowWayland *>(win)->surface()) {
return win;
}
}
return nullptr;
}
static bool update_cursor_scale(cursor_t &cursor, wl_shm *shm)
{
int scale = 0;
for (const output_t *output : cursor.outputs) {
if (output->scale > scale)
scale = output->scale;
}
if (scale > 0 && cursor.scale != scale) {
cursor.scale = scale;
wl_surface_set_buffer_scale(cursor.surface, scale);
wl_cursor_theme_destroy(cursor.theme);
cursor.theme = wl_cursor_theme_load(cursor.theme_name.c_str(), scale * cursor.size, shm);
return true;
}
return false;
}
static void cursor_surface_enter(void *data,
struct wl_surface * /*wl_surface*/,
struct wl_output *output)
{
input_t *input = static_cast<input_t *>(data);
for (const output_t *reg_output : input->system->outputs()) {
if (reg_output->output == output) {
input->cursor.outputs.insert(reg_output);
}
}
update_cursor_scale(input->cursor, input->system->shm());
}
static void cursor_surface_leave(void *data,
struct wl_surface * /*wl_surface*/,
struct wl_output *output)
{
input_t *input = static_cast<input_t *>(data);
for (const output_t *reg_output : input->system->outputs()) {
if (reg_output->output == output) {
input->cursor.outputs.erase(reg_output);
}
}
update_cursor_scale(input->cursor, input->system->shm());
}
struct wl_surface_listener cursor_surface_listener = {
cursor_surface_enter,
cursor_surface_leave,
};
static void pointer_enter(void *data,
struct wl_pointer * /*wl_pointer*/,
uint32_t serial,
@@ -803,22 +881,28 @@ static void pointer_enter(void *data,
wl_fixed_t surface_x,
wl_fixed_t surface_y)
{
if (!surface) {
GHOST_WindowWayland *win = static_cast<GHOST_WindowWayland *>(get_window(surface));
if (!win) {
return;
}
win->activate();
input_t *input = static_cast<input_t *>(data);
input->pointer_serial = serial;
input->x = wl_fixed_to_int(surface_x);
input->y = wl_fixed_to_int(surface_y);
input->x = win->scale() * wl_fixed_to_int(surface_x);
input->y = win->scale() * wl_fixed_to_int(surface_y);
input->focus_pointer = surface;
input->system->pushEvent(
new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
static_cast<GHOST_WindowWayland *>(wl_surface_get_user_data(surface)),
input->x,
input->y,
GHOST_TABLET_DATA_NONE));
win->setCursorShape(win->getCursorShape());
input->system->pushEvent(new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
static_cast<GHOST_WindowWayland *>(win),
input->x,
input->y,
GHOST_TABLET_DATA_NONE));
}
static void pointer_leave(void *data,
@@ -826,9 +910,14 @@ static void pointer_leave(void *data,
uint32_t /*serial*/,
struct wl_surface *surface)
{
if (surface != nullptr) {
static_cast<input_t *>(data)->focus_pointer = nullptr;
GHOST_IWindow *win = get_window(surface);
if (!win) {
return;
}
static_cast<input_t *>(data)->focus_pointer = nullptr;
static_cast<GHOST_WindowWayland *>(win)->deactivate();
}
static void pointer_motion(void *data,
@@ -839,21 +928,20 @@ static void pointer_motion(void *data,
{
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
GHOST_WindowWayland *win = static_cast<GHOST_WindowWayland *>(get_window(input->focus_pointer));
if (!win) {
return;
}
input->x = wl_fixed_to_int(surface_x);
input->y = wl_fixed_to_int(surface_y);
input->x = win->scale() * wl_fixed_to_int(surface_x);
input->y = win->scale() * wl_fixed_to_int(surface_y);
input->system->pushEvent(new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
win,
wl_fixed_to_int(surface_x),
wl_fixed_to_int(surface_y),
input->x,
input->y,
GHOST_TABLET_DATA_NONE));
}
@@ -864,6 +952,14 @@ static void pointer_button(void *data,
uint32_t button,
uint32_t state)
{
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = get_window(input->focus_pointer);
if (!win) {
return;
}
GHOST_TEventType etype = GHOST_kEventUnknown;
switch (state) {
case WL_POINTER_BUTTON_STATE_RELEASED:
@@ -887,9 +983,6 @@ static void pointer_button(void *data,
break;
}
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
input->data_source->source_serial = serial;
input->buttons.set(ebutton, state == WL_POINTER_BUTTON_STATE_PRESSED);
input->system->pushEvent(new GHOST_EventButton(
@@ -902,12 +995,18 @@ static void pointer_axis(void *data,
uint32_t axis,
wl_fixed_t value)
{
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = get_window(input->focus_pointer);
if (!win) {
return;
}
if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL) {
return;
}
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
input->system->pushEvent(
new GHOST_EventWheel(input->system->getMilliSeconds(), win, std::signbit(value) ? +1 : -1));
}
@@ -1137,7 +1236,12 @@ static void seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capa
input->cursor.visible = true;
input->cursor.buffer = nullptr;
input->cursor.file_buffer = new buffer_t;
if (!get_cursor_settings(input->cursor.theme_name, input->cursor.size)) {
input->cursor.theme_name = std::string();
input->cursor.size = default_cursor_size;
}
wl_pointer_add_listener(input->pointer, &pointer_listener, data);
wl_surface_add_listener(input->cursor.surface, &cursor_surface_listener, data);
}
if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
@@ -1160,8 +1264,8 @@ static void output_geometry(void *data,
struct wl_output * /*wl_output*/,
int32_t /*x*/,
int32_t /*y*/,
int32_t /*physical_width*/,
int32_t /*physical_height*/,
int32_t physical_width,
int32_t physical_height,
int32_t /*subpixel*/,
const char *make,
const char *model,
@@ -1171,6 +1275,8 @@ static void output_geometry(void *data,
output->transform = transform;
output->make = std::string(make);
output->model = std::string(model);
output->width_mm = physical_width;
output->height_mm = physical_height;
}
static void output_mode(void *data,
@@ -1181,8 +1287,8 @@ static void output_mode(void *data,
int32_t /*refresh*/)
{
output_t *output = static_cast<output_t *>(data);
output->width = width;
output->height = height;
output->width_pxl = width;
output->height_pxl = height;
}
/**
@@ -1227,13 +1333,17 @@ static void global_add(void *data,
struct display_t *display = static_cast<struct display_t *>(data);
if (!strcmp(interface, wl_compositor_interface.name)) {
display->compositor = static_cast<wl_compositor *>(
wl_registry_bind(wl_registry, name, &wl_compositor_interface, 1));
wl_registry_bind(wl_registry, name, &wl_compositor_interface, 3));
}
else if (!strcmp(interface, xdg_wm_base_interface.name)) {
display->xdg_shell = static_cast<xdg_wm_base *>(
wl_registry_bind(wl_registry, name, &xdg_wm_base_interface, 1));
xdg_wm_base_add_listener(display->xdg_shell, &shell_listener, nullptr);
}
else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name)) {
display->xdg_decoration_manager = static_cast<zxdg_decoration_manager_v1 *>(
wl_registry_bind(wl_registry, name, &zxdg_decoration_manager_v1_interface, 1));
}
else if (!strcmp(interface, wl_output_interface.name)) {
output_t *output = new output_t;
output->scale = 1;
@@ -1335,16 +1445,6 @@ GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new display_t)
wl_data_device_add_listener(input->data_device, &data_device_listener, input);
}
}
const char *theme = std::getenv("XCURSOR_THEME");
const char *size = std::getenv("XCURSOR_SIZE");
const int sizei = size ? std::stoi(size) : default_cursor_size;
d->cursor_theme = wl_cursor_theme_load(theme, sizei, d->shm);
if (!d->cursor_theme) {
display_destroy(d);
throw std::runtime_error("Wayland: unable to access cursor themes!");
}
}
GHOST_SystemWayland::~GHOST_SystemWayland()
@@ -1471,8 +1571,8 @@ void GHOST_SystemWayland::getMainDisplayDimensions(GHOST_TUns32 &width, GHOST_TU
{
if (getNumDisplays() > 0) {
/* We assume first output as main. */
width = uint32_t(d->outputs[0]->width);
height = uint32_t(d->outputs[0]->height);
width = uint32_t(d->outputs[0]->width_pxl) / d->outputs[0]->scale;
height = uint32_t(d->outputs[0]->height_pxl) / d->outputs[0]->scale;
}
}
@@ -1481,7 +1581,7 @@ void GHOST_SystemWayland::getAllDisplayDimensions(GHOST_TUns32 &width, GHOST_TUn
getMainDisplayDimensions(width, height);
}
GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings glSettings)
GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*glSettings*/)
{
/* Create new off-screen window. */
wl_surface *os_surface = wl_compositor_create_surface(compositor());
@@ -1530,6 +1630,11 @@ GHOST_IWindow *GHOST_SystemWayland::createWindow(const char *title,
const bool is_dialog,
const GHOST_IWindow *parentWindow)
{
/* globally store pointer to window manager */
if (!window_manager) {
window_manager = getWindowManager();
}
GHOST_WindowWayland *window = new GHOST_WindowWayland(
this,
title,
@@ -1574,6 +1679,21 @@ xdg_wm_base *GHOST_SystemWayland::shell()
return d->xdg_shell;
}
zxdg_decoration_manager_v1 *GHOST_SystemWayland::decoration_manager()
{
return d->xdg_decoration_manager;
}
const std::vector<output_t *> &GHOST_SystemWayland::outputs() const
{
return d->outputs;
}
wl_shm *GHOST_SystemWayland::shm() const
{
return d->shm;
}
void GHOST_SystemWayland::setSelection(const std::string &selection)
{
this->selection = selection;
@@ -1581,23 +1701,20 @@ void GHOST_SystemWayland::setSelection(const std::string &selection)
static void set_cursor_buffer(input_t *input, wl_buffer *buffer)
{
input->cursor.visible = (buffer != nullptr);
cursor_t *c = &input->cursor;
wl_surface_attach(input->cursor.surface, buffer, 0, 0);
wl_surface_commit(input->cursor.surface);
c->visible = (buffer != nullptr);
if (input->cursor.visible) {
wl_surface_damage(input->cursor.surface,
0,
0,
int32_t(input->cursor.image.width),
int32_t(input->cursor.image.height));
wl_pointer_set_cursor(input->pointer,
input->pointer_serial,
input->cursor.surface,
int32_t(input->cursor.image.hotspot_x),
int32_t(input->cursor.image.hotspot_y));
}
wl_surface_attach(c->surface, buffer, 0, 0);
wl_surface_damage(c->surface, 0, 0, int32_t(c->image.width), int32_t(c->image.height));
wl_pointer_set_cursor(input->pointer,
input->pointer_serial,
c->visible ? c->surface : nullptr,
int32_t(c->image.hotspot_x) / c->scale,
int32_t(c->image.hotspot_y) / c->scale);
wl_surface_commit(c->surface);
}
GHOST_TSuccess GHOST_SystemWayland::setCursorShape(GHOST_TStandardCursor shape)
@@ -1608,7 +1725,15 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorShape(GHOST_TStandardCursor shape)
const std::string cursor_name = cursors.count(shape) ? cursors.at(shape) :
cursors.at(GHOST_kStandardCursorDefault);
wl_cursor *cursor = wl_cursor_theme_get_cursor(d->cursor_theme, cursor_name.c_str());
input_t *input = d->inputs[0];
cursor_t *c = &input->cursor;
if (!c->theme) {
/* The cursor surface hasn't entered an output yet. Initialize theme with scale 1. */
c->theme = wl_cursor_theme_load(c->theme_name.c_str(), c->size, d->inputs[0]->system->shm());
}
wl_cursor *cursor = wl_cursor_theme_get_cursor(c->theme, cursor_name.c_str());
if (!cursor) {
GHOST_PRINT("cursor '" << cursor_name << "' does not exist" << std::endl);
@@ -1620,11 +1745,11 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorShape(GHOST_TStandardCursor shape)
if (!buffer) {
return GHOST_kFailure;
}
cursor_t *c = &d->inputs[0]->cursor;
c->buffer = buffer;
c->image = *image;
set_cursor_buffer(d->inputs[0], buffer);
set_cursor_buffer(input, buffer);
return GHOST_kSuccess;
}
@@ -1735,6 +1860,11 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorVisibility(bool visible)
GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mode,
wl_surface *surface)
{
/* ignore, if the required protocols are not supported */
if (!d->relative_pointer_manager || !d->pointer_constraints) {
return GHOST_kFailure;
}
if (d->inputs.empty()) {
return GHOST_kFailure;
}
@@ -1754,6 +1884,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mo
break;
case GHOST_kGrabNormal:
break;
case GHOST_kGrabWrap:
input->relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
d->relative_pointer_manager, input->pointer);

View File

@@ -26,6 +26,7 @@
#include "GHOST_WindowWayland.h"
#include <wayland-client.h>
#include <xdg-decoration-client-protocol.h>
#include <xdg-shell-client-protocol.h>
#include <string>
@@ -34,6 +35,16 @@ class GHOST_WindowWayland;
struct display_t;
struct output_t {
struct wl_output *output;
int32_t width_pxl, height_pxl; // dimensions in pixel
int32_t width_mm, height_mm; // dimensions in millimeter
int transform;
int scale;
std::string make;
std::string model;
};
class GHOST_SystemWayland : public GHOST_System {
public:
GHOST_SystemWayland();
@@ -84,6 +95,12 @@ class GHOST_SystemWayland : public GHOST_System {
xdg_wm_base *shell();
zxdg_decoration_manager_v1 *decoration_manager();
const std::vector<output_t *> &outputs() const;
wl_shm *shm() const;
void setSelection(const std::string &selection);
GHOST_TSuccess setCursorShape(GHOST_TStandardCursor shape);

View File

@@ -0,0 +1,130 @@
/*
* 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
*/
#pragma once
#include <dbus/dbus.h>
#include <string>
static DBusMessage *get_setting_sync(DBusConnection *const connection,
const char *key,
const char *value)
{
DBusError error;
dbus_bool_t success;
DBusMessage *message;
DBusMessage *reply;
dbus_error_init(&error);
message = dbus_message_new_method_call("org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.Settings",
"Read");
success = dbus_message_append_args(
message, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID);
if (!success) {
return NULL;
}
reply = dbus_connection_send_with_reply_and_block(
connection, message, DBUS_TIMEOUT_USE_DEFAULT, &error);
dbus_message_unref(message);
if (dbus_error_is_set(&error)) {
return NULL;
}
return reply;
}
static bool parse_type(DBusMessage *const reply, const int type, void *value)
{
DBusMessageIter iter[3];
dbus_message_iter_init(reply, &iter[0]);
if (dbus_message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_VARIANT) {
return false;
}
dbus_message_iter_recurse(&iter[0], &iter[1]);
if (dbus_message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_VARIANT) {
return false;
}
dbus_message_iter_recurse(&iter[1], &iter[2]);
if (dbus_message_iter_get_arg_type(&iter[2]) != type) {
return false;
}
dbus_message_iter_get_basic(&iter[2], value);
return true;
}
static bool get_cursor_settings(std::string &theme, int &size)
{
static const char name[] = "org.gnome.desktop.interface";
static const char key_theme[] = "cursor-theme";
static const char key_size[] = "cursor-size";
DBusError error;
DBusConnection *connection;
DBusMessage *reply;
const char *value_theme = NULL;
dbus_error_init(&error);
connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
if (dbus_error_is_set(&error)) {
return false;
}
reply = get_setting_sync(connection, name, key_theme);
if (!reply) {
return false;
}
if (!parse_type(reply, DBUS_TYPE_STRING, &value_theme)) {
dbus_message_unref(reply);
return false;
}
theme = std::string(value_theme);
dbus_message_unref(reply);
reply = get_setting_sync(connection, name, key_size);
if (!reply) {
return false;
}
if (!parse_type(reply, DBUS_TYPE_INT32, &size)) {
dbus_message_unref(reply);
return false;
}
dbus_message_unref(reply);
return true;
}

View File

@@ -29,11 +29,19 @@
#include <wayland-egl.h>
static constexpr size_t base_dpi = 96;
struct window_t {
GHOST_WindowWayland *w;
wl_surface *surface;
// outputs on which the window is currently shown on
std::unordered_set<const output_t *> outputs;
GHOST_TUns16 dpi = 0;
int scale = 1;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration = nullptr;
enum zxdg_toplevel_decoration_v1_mode decoration_mode;
wl_egl_window *egl_window;
int32_t pending_width, pending_height;
bool is_maximised;
@@ -93,17 +101,30 @@ static const xdg_toplevel_listener toplevel_listener = {
toplevel_close,
};
static void toplevel_decoration_configure(
void *data,
struct zxdg_toplevel_decoration_v1 * /*zxdg_toplevel_decoration_v1*/,
uint32_t mode)
{
static_cast<window_t *>(data)->decoration_mode = zxdg_toplevel_decoration_v1_mode(mode);
}
static const zxdg_toplevel_decoration_v1_listener toplevel_decoration_v1_listener = {
toplevel_decoration_configure,
};
static void surface_configure(void *data, xdg_surface *xdg_surface, uint32_t serial)
{
window_t *win = static_cast<window_t *>(data);
int w, h;
wl_egl_window_get_attached_size(win->egl_window, &w, &h);
if (win->pending_width != 0 && win->pending_height != 0 && win->pending_width != w &&
win->pending_height != h) {
win->width = win->pending_width;
win->height = win->pending_height;
wl_egl_window_resize(win->egl_window, win->pending_width, win->pending_height, 0, 0);
if (win->xdg_surface != xdg_surface) {
return;
}
if (win->pending_width != 0 && win->pending_height != 0) {
win->width = win->scale * win->pending_width;
win->height = win->scale * win->pending_height;
wl_egl_window_resize(win->egl_window, win->width, win->height, 0, 0);
win->pending_width = 0;
win->pending_height = 0;
win->w->notify_size();
@@ -123,6 +144,52 @@ static const xdg_surface_listener surface_listener = {
surface_configure,
};
static bool update_scale(GHOST_WindowWayland *window)
{
int scale = 0;
for (const output_t *output : window->outputs_active()) {
if (output->scale > scale)
scale = output->scale;
}
if (scale > 0 && window->scale() != scale) {
window->scale() = scale;
// using the real DPI will cause wrong scaling of the UI
// use a multiplier for the default DPI as workaround
window->dpi() = scale * base_dpi;
wl_surface_set_buffer_scale(window->surface(), scale);
return true;
}
return false;
}
static void surface_enter(void *data, struct wl_surface * /*wl_surface*/, struct wl_output *output)
{
GHOST_WindowWayland *w = static_cast<GHOST_WindowWayland *>(data);
for (const output_t *reg_output : w->outputs()) {
if (reg_output->output == output) {
w->outputs_active().insert(reg_output);
}
}
update_scale(w);
}
static void surface_leave(void *data, struct wl_surface * /*wl_surface*/, struct wl_output *output)
{
GHOST_WindowWayland *w = static_cast<GHOST_WindowWayland *>(data);
for (const output_t *reg_output : w->outputs()) {
if (reg_output->output == output) {
w->outputs_active().erase(reg_output);
}
}
update_scale(w);
}
struct wl_surface_listener wl_surface_listener = {
surface_enter,
surface_leave,
};
/** \} */
/* -------------------------------------------------------------------- */
@@ -161,17 +228,28 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
/* Window surfaces. */
w->surface = wl_compositor_create_surface(m_system->compositor());
wl_surface_add_listener(w->surface, &wl_surface_listener, this);
w->egl_window = wl_egl_window_create(w->surface, int(width), int(height));
w->xdg_surface = xdg_wm_base_get_xdg_surface(m_system->shell(), w->surface);
w->xdg_toplevel = xdg_surface_get_toplevel(w->xdg_surface);
if (m_system->decoration_manager()) {
w->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
m_system->decoration_manager(), w->xdg_toplevel);
zxdg_toplevel_decoration_v1_add_listener(
w->xdg_toplevel_decoration, &toplevel_decoration_v1_listener, w);
zxdg_toplevel_decoration_v1_set_mode(w->xdg_toplevel_decoration,
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
wl_surface_set_user_data(w->surface, this);
xdg_surface_add_listener(w->xdg_surface, &surface_listener, w);
xdg_toplevel_add_listener(w->xdg_toplevel, &toplevel_listener, w);
if (parentWindow) {
if (parentWindow && is_dialog) {
xdg_toplevel_set_parent(
w->xdg_toplevel, dynamic_cast<const GHOST_WindowWayland *>(parentWindow)->w->xdg_toplevel);
}
@@ -192,6 +270,9 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
if (setDrawingContextType(type) == GHOST_kFailure) {
GHOST_PRINT("Failed to create EGL context" << std::endl);
}
/* set swap interval to 0 to prevent blocking */
setSwapInterval(0);
}
GHOST_TSuccess GHOST_WindowWayland::close()
@@ -226,6 +307,31 @@ GHOST_TSuccess GHOST_WindowWayland::notify_size()
new GHOST_Event(m_system->getMilliSeconds(), GHOST_kEventWindowSize, this));
}
wl_surface *GHOST_WindowWayland::surface() const
{
return w->surface;
}
const std::vector<output_t *> &GHOST_WindowWayland::outputs() const
{
return m_system->outputs();
}
std::unordered_set<const output_t *> &GHOST_WindowWayland::outputs_active()
{
return w->outputs;
}
uint16_t &GHOST_WindowWayland::dpi()
{
return w->dpi;
}
int &GHOST_WindowWayland::scale()
{
return w->scale;
}
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
{
return m_system->setCursorGrab(mode, w->surface);
@@ -310,6 +416,9 @@ GHOST_WindowWayland::~GHOST_WindowWayland()
releaseNativeHandles();
wl_egl_window_destroy(w->egl_window);
if (w->xdg_toplevel_decoration) {
zxdg_toplevel_decoration_v1_destroy(w->xdg_toplevel_decoration);
}
xdg_toplevel_destroy(w->xdg_toplevel);
xdg_surface_destroy(w->xdg_surface);
wl_surface_destroy(w->surface);
@@ -317,6 +426,11 @@ GHOST_WindowWayland::~GHOST_WindowWayland()
delete w;
}
GHOST_TUns16 GHOST_WindowWayland::getDPIHint()
{
return w->dpi;
}
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorVisibility(bool visible)
{
return m_system->setCursorVisibility(visible);

View File

@@ -24,9 +24,14 @@
#include "GHOST_Window.h"
#include <unordered_set>
#include <vector>
class GHOST_SystemWayland;
struct window_t;
struct wl_surface;
struct output_t;
class GHOST_WindowWayland : public GHOST_Window {
public:
@@ -47,6 +52,8 @@ class GHOST_WindowWayland : public GHOST_Window {
~GHOST_WindowWayland() override;
GHOST_TUns16 getDPIHint() override;
GHOST_TSuccess close();
GHOST_TSuccess activate();
@@ -55,6 +62,16 @@ class GHOST_WindowWayland : public GHOST_Window {
GHOST_TSuccess notify_size();
wl_surface *surface() const;
const std::vector<output_t *> &outputs() const;
std::unordered_set<const output_t *> &outputs_active();
uint16_t &dpi();
int &scale();
protected:
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override;

View File

@@ -198,6 +198,7 @@ def _clean_utf8(name):
_display_name_literals = {
":": "_colon_",
"+": "_plus_",
"/": "_slash_",
}

View File

@@ -560,9 +560,17 @@ class Text(bpy_types.ID):
self.write(string)
def as_module(self):
from os.path import splitext
import bpy
from os.path import splitext, join
from types import ModuleType
mod = ModuleType(splitext(self.name)[0])
name = self.name
mod = ModuleType(splitext(name)[0])
# This is a fake file-path, set this since some scripts check `__file__`,
# error messages may include this as well.
# NOTE: the file path may be a blank string if the file hasn't been saved.
mod.__dict__.update({
"__file__": join(bpy.data.filepath, name),
})
# TODO: We could use Text.compiled (C struct member)
# if this is called often it will be much faster.
exec(self.as_string(), mod.__dict__)

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 6.16
bpy.context.camera.sensor_height = 4.62
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 13.2
bpy.context.camera.sensor_height = 8.80
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 7.18
bpy.context.camera.sensor_height = 5.32
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 6.17
bpy.context.camera.sensor_height = 4.55
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 5.76
bpy.context.camera.sensor_height = 4.29
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 5.37
bpy.context.camera.sensor_height = 4.04
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,5 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 4.54
bpy.context.camera.sensor_height = 3.42
bpy.context.camera.lens = 3.85
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 9.6
bpy.context.camera.sensor_height = 5.4
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 8.8
bpy.context.camera.sensor_height = 6.6
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 17.31
bpy.context.camera.sensor_height = 12.98
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 23.6
bpy.context.camera.sensor_height = 15.6
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 22.30
bpy.context.camera.sensor_height = 14.90
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 27.90
bpy.context.camera.sensor_height = 18.60
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 10.26
bpy.context.camera.sensor_height = 7.49
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 22
bpy.context.camera.sensor_height = 16
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 52.45
bpy.context.camera.sensor_height = 23.01
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 71.41
bpy.context.camera.sensor_height = 52.63
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 12.35
bpy.context.camera.sensor_height = 7.42
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 24.89
bpy.context.camera.sensor_height = 18.66
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 23.760
bpy.context.camera.sensor_height = 13.365
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 54.12
bpy.context.camera.sensor_height = 25.58
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 36.70
bpy.context.camera.sensor_height = 25.54
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 29.90
bpy.context.camera.sensor_height = 15.77
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 15.81
bpy.context.camera.sensor_height = 8.88
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 12.48
bpy.context.camera.sensor_height = 7.02
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 18.96
bpy.context.camera.sensor_height = 10.00
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 23.10
bpy.context.camera.sensor_height = 12.99
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 21.12
bpy.context.camera.sensor_height = 11.88
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 25.34
bpy.context.camera.sensor_height = 14.25
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 32
bpy.context.camera.sensor_height = 18
bpy.context.camera.sensor_fit = 'AUTO'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 22.2
bpy.context.camera.sensor_height = 14.7
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 22.3
bpy.context.camera.sensor_height = 14.9
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 24.4
bpy.context.camera.sensor_height = 13.5
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 20.70
bpy.context.camera.sensor_height = 13.80
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 36
bpy.context.camera.sensor_height = 24
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,6 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 6.16
bpy.context.camera.sensor_height = 4.62
bpy.context.camera.lens = 2.77
bpy.context.camera.sensor_fit = 'AUTO'

View File

@@ -1,6 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 5.371
bpy.context.camera.sensor_height = 4.035
bpy.context.camera.lens = 2.77
bpy.context.camera.sensor_fit = 'AUTO'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 17.3
bpy.context.camera.sensor_height = 13.0
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 44
bpy.context.camera.sensor_height = 33
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,5 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 4.5
bpy.context.camera.sensor_height = 3.37
bpy.context.camera.lens = 3.91
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 23.1
bpy.context.camera.sensor_height = 15.4
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 23.6
bpy.context.camera.sensor_height = 15.8
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 4.68
bpy.context.camera.sensor_height = 2.633
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 8.5
bpy.context.camera.sensor_height = 4.78
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 25.60
bpy.context.camera.sensor_height = 13.5
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 30.70
bpy.context.camera.sensor_height = 15.80
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 29.90
bpy.context.camera.sensor_height = 15.77
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 40.96
bpy.context.camera.sensor_height = 21.60
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 30.0
bpy.context.camera.sensor_height = 15.0
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 11.1
bpy.context.camera.sensor_height = 6.24
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 16.65
bpy.context.camera.sensor_height = 9.36
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 22.2
bpy.context.camera.sensor_height = 12.6
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,5 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 4.8
bpy.context.camera.sensor_height = 3.6
bpy.context.camera.lens = 3.70
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,5 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 4.8
bpy.context.camera.sensor_height = 3.6
bpy.context.camera.lens = 4.20
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 23.4
bpy.context.camera.sensor_height = 15.6
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 6.97
bpy.context.camera.sensor_height = 3.92
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 24.33
bpy.context.camera.sensor_height = 12.83
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,4 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 12.52
bpy.context.camera.sensor_height = 7.41
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,5 +0,0 @@
import bpy
bpy.context.camera.sensor_width = 4.54
bpy.context.camera.sensor_height = 3.42
bpy.context.camera.lens = 4.10
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1079,10 +1079,11 @@ def km_view3d(params):
("view3d.view_all", {"type": 'C', "value": 'PRESS', "shift": True},
{"properties": [("center", True)]}),
op_menu_pie("VIEW3D_MT_view_pie", {"type": 'D', "value": 'CLICK_DRAG'}),
("view3d.navigate", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "shift": True}, None),
# Numpad views.
("view3d.view_camera", {"type": 'NUMPAD_0', "value": 'PRESS'}, None),
("view3d.view_axis", {"type": 'NUMPAD_1', "value": 'PRESS'},
{"properties": [("type", 'FRONT')]}),
("view3d.view_axis", {"type": 'NUMPAD_1', "value": 'PRESS'},
{"properties": [("type", 'FRONT')]}),
("view3d.view_orbit", {"type": 'NUMPAD_2', "value": 'PRESS', "repeat": True},
{"properties": [("type", 'ORBITDOWN')]}),
("view3d.view_axis", {"type": 'NUMPAD_3', "value": 'PRESS'},
@@ -2543,6 +2544,7 @@ def km_sequencercommon(params):
{"properties": [("data_path", 'scene.sequence_editor.show_overlay')]}),
("wm.context_toggle_enum", {"type": 'TAB', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'space_data.view_type'), ("value_1", 'SEQUENCER'), ("value_2", 'PREVIEW')]}),
("sequencer.refresh_all", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
])
if params.select_mouse == 'LEFTMOUSE' and not params.legacy:
@@ -2583,7 +2585,6 @@ def km_sequencer(params):
("sequencer.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None),
("sequencer.reload", {"type": 'R', "value": 'PRESS', "shift": True, "alt": True},
{"properties": [("adjust_length", True)]}),
("sequencer.refresh_all", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
("sequencer.offset_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None),
("sequencer.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("sequencer.delete", {"type": 'X', "value": 'PRESS'}, None),
@@ -2591,7 +2592,7 @@ def km_sequencer(params):
("sequencer.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True, "shift": True},
{"properties": [("keep_offset", True)]}),
{"properties": [("keep_offset", True)]}),
("sequencer.images_separate", {"type": 'Y', "value": 'PRESS'}, None),
("sequencer.meta_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
("sequencer.meta_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),

View File

@@ -1,9 +0,0 @@
import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 6.16
camera.units = 'MILLIMETERS'
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -1,9 +0,0 @@
import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 5.76
camera.units = 'MILLIMETERS'
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 13.2
bpy.context.camera.sensor_height = 8.80
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 7.18
bpy.context.camera.sensor_height = 5.32
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 6.17
bpy.context.camera.sensor_height = 4.55
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,6 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 5.76
bpy.context.camera.sensor_height = 4.29
bpy.context.camera.lens = 2.77
bpy.context.camera.sensor_fit = 'AUTO'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 5.37
bpy.context.camera.sensor_height = 4.04
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,5 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 4.54
bpy.context.camera.sensor_height = 3.42
bpy.context.camera.lens = 4.28
bpy.context.camera.sensor_fit = 'HORIZONTAL'
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,9 +0,0 @@
import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 9.6
camera.units = 'MILLIMETERS'
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 8.8
bpy.context.camera.sensor_height = 6.6
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -1,9 +0,0 @@
import bpy
camera = bpy.context.edit_movieclip.tracking.camera
camera.sensor_width = 17.31
camera.units = 'MILLIMETERS'
camera.pixel_aspect = 1
camera.k1 = 0.0
camera.k2 = 0.0
camera.k3 = 0.0

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 23.6
bpy.context.camera.sensor_height = 15.6
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 22.30
bpy.context.camera.sensor_height = 14.90
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 27.90
bpy.context.camera.sensor_height = 18.60
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 10.26
bpy.context.camera.sensor_height = 7.49
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 22
bpy.context.camera.sensor_height = 16
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 52.45
bpy.context.camera.sensor_height = 23.01
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 71.41
bpy.context.camera.sensor_height = 52.63
bpy.context.camera.sensor_fit = 'HORIZONTAL'

View File

@@ -0,0 +1,4 @@
import bpy
bpy.context.camera.sensor_width = 12.35
bpy.context.camera.sensor_height = 7.42
bpy.context.camera.sensor_fit = 'HORIZONTAL'

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