Commit Graph

5055 Commits

Author SHA1 Message Date
Campbell Barton
e6609ecfda Cleanup: use a const ImBuf for UI image references 2023-07-13 10:10:44 +10:00
Harley Acheson
b7a119c785 Fix #40059: Use Modifier Keys Between Windows on Win32
Use modifier keys that are pressed before activating a new window.
Allows call of `wm_window_update_eventstate_modifiers` on
`GHOST_kEventWindowActivate` by using `GetAsyncKeyState` instead of
`GetKeyState` in GHOST_SystemWin32::getModifierKeys, which retrieves
actual hardware state.

Pull Request: https://projects.blender.org/blender/blender/pulls/110020
2023-07-12 20:01:37 +02:00
Bastien Montagne
6f5f1737f3 Revert "LibOverride: Work around reset of system liboverrides on save."
This reverts commit 457b26aba3.

This change was not actually needed, actual issue was caused by
784d09a87c, and has been fixed by 1c0ffa1e18.
2023-07-12 17:26:13 +02:00
Jacques Lucke
3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Bastien Montagne
457b26aba3 LibOverride: Work around reset of system liboverrides on save.
Now that liboverride process on save (the diffing + pruning unused
override operations + reset of non-overridable changes) works better. it
leads to a bad side-effect: all system overrides data indirectly
modified through animation or drivers get reset.

Since in current system e.g. most objects of a rigged asset are system
overrides, but their transform is modified by bones animation, this
leads to entire overrides of assets being reset to their linked state
until next depsgraph evaluation.

While this is the expected and correct behavior in absolute, this is
very bad from a user experience PoV.

This commit address the issue by simply re-running a 'frame change'
despgraph update, to ensure all drivers, animations etc. are properly
re-applied after liboverride diffing cleanup & reset.
2023-07-11 15:30:30 +02:00
Julian Eisel
d31a0e8393 GPv3: Drag & drop reordering & inserting in the layer tree UI
Note: Change applies to Grease Pencil 3.0 only (experimental feature).

Enables use of drag & drop to reorder grease pencil layers through the layer
tree UI, as well as inserting layers into groups. This is an intuitive and
often requested method of managing such data-structures. Visual feedback should
be improved still, and the gap between items be removed, to reduce flickering
while dragging. These are general improvements for tree views however which
should be done separately.

There is no support yet for dragging layer groups, this requires further
changes in the internal grease pencil APIs.

#109825 introduced the necessary drag & drop support for tree views, #109824
prepared the internal grease pencil API for it.

Pull Request: https://projects.blender.org/blender/blender/pulls/109826
2023-07-11 15:05:17 +02:00
Clément Foucault
11e2ca4b70 GPU: Fix compilation warnings
Warnings caused by 1978b4fc92
2023-07-11 11:08:06 +02:00
Clément Foucault
1978b4fc92 GHOST: Replace WITH_OPENGL build option
Replaces it by WITH_OPENGL_BACKEND and cleanup its usage.
Limits visibility of opengl enums and cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/109947
2023-07-11 09:17:31 +02:00
Campbell Barton
4333051f4d WM: pass the window manager & window to WM_report_banner_show
Avoid potential problems when the active window is known but not
assigned to `wm->winactive`, where the first window would be used
as a fallback. Instead, take a window argument, a fallback is still
used as a last resort (when NULL).
2023-07-11 14:42:24 +10:00
Campbell Barton
36b2291610 Cleanup: spelling in comments 2023-07-11 14:40:47 +10:00
Campbell Barton
1ec1e783cc Cleanup: consistent naming for wmTimer API
Word ordering for wmTimer API wasn't consistent.

- Use "WM_event_timer_" / "WM_event_timers_" prefix.
- Rename "wm_window_timer" to "wm_window_timers_process"
  because it wasn't clear what the function did from its name.
- Rename "wm_window_process_events" to "wm_window_events_process"
  for consistency with "wm_window_timers_process".
2023-07-11 13:16:04 +10:00
Campbell Barton
6be0c90eab Fix #109953: Timers without an associated window leak memory on exit
Thanks to @mod_moder & @Harley for their investigation, see !109603.
2023-07-11 12:52:34 +10:00
Campbell Barton
8a73c36643 Fix #109952: Unknown engine warning only shown when loading from a popup
Displaying the warning on file load depended on `wm->winactive`
being set, and didn't work when loading a file from the file-open
window or when loading files using a command-line argument.

Resolve using the first window as a fallback.
This happens to resolve #109770, although not freeing timers on exit
is likely to be an issue under other circumstances.
2023-07-11 12:21:04 +10:00
Bastien Montagne
fa29d28d73 Fix #109889: Trying to append/link from the current file does give proper error message.
Logic in FileBrowser and/or `BKE_blendfile_library_path_explode`
probably changed at some point, and the generic 'invalid filetype' error
message was reached before the path is compared to current blendfile path.
2023-07-10 15:58:36 +02:00
Campbell Barton
0b5eb86e2c Cleanup: check the result of BLI_findindex against -1 instead of < 0
There is only one error value, prefer a specific check.
2023-07-10 12:37:44 +10:00
Campbell Barton
6290451712 Cleanup: spelling in comments 2023-07-09 21:22:45 +10:00
Pratik Borhade
b14435fd93 GPv3: Missing default tool for paint mode
This broke after introduction of new grease pencil
paint mode 3d99d05f00
Entry in `toolsystem_default_tool` was missing

Pull Request: https://projects.blender.org/blender/blender/pulls/109722
2023-07-05 12:03:51 +02:00
Campbell Barton
28c3a0a980 WM: quiet missing incremental properly warning for "Save As"
The incremental property doesn't exist for "Save As" so don't check
for it.
2023-07-05 14:30:17 +10:00
Campbell Barton
785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Hans Goudey
1b4b90f5f7 Cleanup: Remove unnecessary C API for asset representation
Now that almost all code is in C++, this is unnecessary and
just confuses things with multiple entry points to the same code.

Pull Request: https://projects.blender.org/blender/blender/pulls/109661
2023-07-04 14:46:19 +02:00
Falk David
3d99d05f00 GPv3: Add separate paint mode
This patch adds a separate paint mode for Grease Pencil 3.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/109453
2023-07-03 16:34:30 +02:00
Falk David
de95539ced Cleanup: Rename grease pencil modes to legacy
Renames `OB_MODE_EDIT_GPENCIL`, `OB_MODE_PAINT_GPENCIL`,  `OB_MODE_SCULPT_GPENCIL`,  `OB_MODE_WEIGHT_GPENCIL`, `OB_MODE_VERTEX_GPENCIL, and the context modes` to `*_LEGACY`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109648
2023-07-03 15:15:54 +02:00
Campbell Barton
6fbe467021 Cleanup: replace BLI_dynstr with a call to BLI_vsprintfN 2023-07-03 14:15:07 +10:00
Campbell Barton
4f3e2ee857 Refactor: split the animation players image buffer display context
Image buffer display in the animation player was difficult to reason
about because it could potentially access the entire play-state on load
(frame-step, modifier keys... etc) even though these are are only
intended to be used interactively.

Add playanim_toscreen_ex which is called by both
playanim_toscreen & playanim_toscreen_on_load which doesn't use the
PlayState struct.
2023-07-02 19:54:27 +10:00
Campbell Barton
f7d6b7973a Cleanup: minor C++ changes (use nullptr, correct parameter names) 2023-07-02 19:54:27 +10:00
Campbell Barton
69aee8ba6b Cleanup: remove redundant (void) for functions with no args in C++ 2023-07-02 19:54:27 +10:00
Campbell Barton
345d1a4b44 Cleanup: simplify struct declarations in C++
Replace `typedef struct X {} X;` with `struct X {};`

In some cases the first and last name didn't match although this
is rarely useful, even a typo in some cases, e.g. TrachPathPoint.
2023-07-02 19:54:26 +10:00
Bastien Montagne
f3c131adfe Fix #109422: Assertion triggered when opening a new file and "Load UI" is disabled in settings.
Small inconsistency leftover from ebb5643e59, 32bbfbb06e and 7ef8389dad
commits.

Weirdly enough that was not a problem on Linux X11, but did cause
issues at leaast on Windows and Linux Wayland.
2023-06-30 10:26:47 +02:00
Hans Goudey
f89b32382a Point Cloud: Add initial edit mode support
Similar to 5f16e24cc9, this adds support for edit mode
to the point cloud object type, which is currently hidden behind an
experimental option. No interaction is possible yet, for now this
can be used as a testing for a node-group-operator-only mode.
2023-06-28 12:52:55 -04:00
Campbell Barton
3ab8e9b144 PlayAnim: only load the built-in mono-space font
There is no need to load all fonts on startup when only the mono-spaced
font is used.
2023-06-28 13:46:26 +10:00
Campbell Barton
d1e6c8f5a6 Cleanup: spelling in comments 2023-06-28 12:27:48 +10:00
Damien Picard
9b4749e7c7 UI: replace "x" with multiplication sign when displaying calculations
The multiplication sign looks like an "x" but should be used in its
stead to display calculations and dimensions such as "1920x1080". It
is supported in many fonts including DejaVu Sans, the font currently
used for the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/106388
2023-06-27 21:03:05 +02:00
Campbell Barton
562aca75d3 Cleanup: split anim/sequence loading into two functions
Also simplify image sequence reading loop.
2023-06-27 10:42:18 +10:00
Campbell Barton
c761f5b6fb PlayAnim: scale the font by the window DPI 2023-06-27 10:08:17 +10:00
Campbell Barton
4bbbf9007b Refactor: split out buffer loading for the animation player
- Simplify freeing resources on error.
- Correct check for failure to access the file size.
- Print the `errno` on failure.
- Use logging.
2023-06-27 10:06:34 +10:00
Julian Eisel
adb370e6ba UI: Use new C++ button apply function
No user visible changes expected.

This function was added in 86b2cf4574 as a more type safe and more
convenient way of setting button callbacks. So use it for simple cases.
2023-06-26 16:56:05 +02:00
Harley Acheson
4a80d0b6d5 Refactor: UTF-8 Character Defines
Use defined UTF-8 Universal character names in place of byte escape
sequences and literals.

Pull Request: https://projects.blender.org/blender/blender/pulls/109163
2023-06-26 06:05:18 +02:00
Campbell Barton
b9bf639ba4 BLI_string: remove BLI_strcpy_rlen
Avoid BLI_strcpy_rlen use as this has the same problems as strcpy
(it just returned the length which is useful at times).
Use memcpy instead when the size is calculated immediately beforehand.

Other uses of have been replaced by BLI_string_join_array that prevents
buffer overruns by taking the destination buffer length.
2023-06-24 18:49:29 +10:00
Brecht Van Lommel
711fb3e386 Realtime Compositor: cache render compositor for repeated executions
This is cached in Render, and gets cleared along with render pass GPU
textures when there is no editor open using it, or a new final render is
started.

The context and texture pool are cached. But the evaluator is re-created
every time as this only runs on compositing node changes, which require
recreating it anyway (unlike the viewport where e.g. camera navigation
does not need a new evaluator).

Pull Request: https://projects.blender.org/blender/blender/pulls/108909
2023-06-23 20:13:21 +02:00
Sergey Sharybin
d8cc8fcf7f Refactor: Move color space information to ImBuf buffers
Before this change the ImBuf struct had dedicated fields for the
buffer data. Now the color space is stored inside of the struct
which wraps around the buffer information.

This only changes the field placement, without changing the way
it is handled. In the future one might imagine that operations
like stealing buffer data should null-ify the buffer colorspace
pointer. Such changes would need to have more accurate thinking
before implementation.

Should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109291
2023-06-23 15:55:42 +02:00
Falk David
bb041b3f48 Fix #109207: Can't select in gpencil edit mode
This was due to a wrong mapping of tools in the toolbar.

The fix makes sure that the correct selection tools are used for the
old grease pencil objects.
In order to accomplish this properly, the new grease pencil objects
use their own edit mode context.
This way the two objects are cleanly seperated.
2023-06-21 16:49:18 +02:00
Hans Goudey
7d935f94f3 Cleanup: Grammar: it's vs its 2023-06-13 14:51:49 -04:00
Brecht Van Lommel
a88114b35e Realtime Compositor: cache render pass GPU textures
* Store per RenderPass in RenderResult.
* Caches are cleared when starting rendering, to make more memory available
  to GPU rendering.
* Caches are cleared on UI changes, when no compositing node editor and no
  image editor with a render result or viewer node image is visible.
* Store 3 channel RGB passes as such, and set alpha 1 in shader.

This is an intermediate step before implementing GPU backed ImBuf, to
improve performance and figure out cache eviction.

Pull Request: https://projects.blender.org/blender/blender/pulls/108818
2023-06-12 19:49:18 +02:00
Julian Eisel
92ff750bbf Refactor: Get rid of asset handle for drag & drop
`AssetHandle` is meant as temporary design and should be replaced by
`AssetRepresentation`. This moves us another step closer to that.

Rather than taking data from the volatile asset handle and storing that
in the drag data, store the (more persistent) asset representation there
and access data from it where needed.
2023-06-09 15:19:41 +02:00
Bastien Montagne
7ef8389dad Fix #108746: Defaults / Save startup file don't save the window size.
Hopefully now the behavior is fully consistent with before the refactor,
current implemented one by this commit:

- When loading factory settings file on startup, go full-screen.
- In all other startup cases, use size as stored in the startup .blend
  file.

Regression from ebb5643e59 and 32bbfbb06e.
2023-06-09 11:29:15 +02:00
Brecht Van Lommel
a2bd080cf3 Cleanup: renaming of GPU contexts for clarity
* opengl_context -> system_gpu_context. This is the operating system OpenGL,
  Metal or Vulkan context provided by GHOST.
* gpu_context -> blender_gpu_context. This is the GPUContext provided by
  the Blender GPU module, which wraps the GHOST context and adds some state.
* Various functions create/destroy/enable/disable both contexts, these have
  just gpu_context in the name now.

Pull Request: https://projects.blender.org/blender/blender/pulls/108723
2023-06-08 15:46:53 +02:00
Campbell Barton
47189c5253 Docs: improve doc-strings for window size & startup file
Document the purpose of zero sized window & when wm_init_state is used.
Noticed when looking into #108643.
2023-06-08 10:32:00 +10:00
Campbell Barton
989b5de8e9 Cleanup: remove unused window states, add doc-strings
Note that the GHOST_TWindowState is stored in DNA & that
values shouldn't be changed.
2023-06-08 10:32:00 +10:00
Bastien Montagne
32bbfbb06e Fix #108643: Blender window does not open to full dimensions of the desktop.
When opening 'homefile' (i.e. startup or factory startup) at Blender
start (i.e. when there is no existing WM yet), the size of the windows
in the newly read WM is reset to zero, which will then cause `WM_check`
to re-size them the the maximum possible size on current monitor.

Regression from ebb5643e59.
2023-06-07 20:01:11 +02:00
Campbell Barton
6704881708 Cleanup: spelling in comments 2023-06-07 21:47:45 +10:00