Commit Graph

126354 Commits

Author SHA1 Message Date
Sergey Sharybin
45f58a5b5f Cleanup: Remove extern "C" from C++ only header 2023-07-27 12:37:06 +02:00
Sybren A. Stüvel
3a89ffc99c Refactor: anim, make ArmatureDrawContext *ctx parameters const
In the Armature drawing code, make `ArmatureDrawContext *ctx` parameters
`const` wherever possible.

No functional changes.
2023-07-27 12:29:36 +02:00
Falk David
610834540a GPv3: Return correct mode in BKE_paintmode_get_active_from_context
Previously this function would return `PAINT_MODE_TEXTURE_2D`.
This would result `paint_space_stroke_enabled` to return true, when it
shouldn't for Grease Pencil .
2023-07-27 12:22:47 +02:00
Sybren A. Stüvel
4aef0204ac Refactor: anim, drawing code, split up get_pchan_color into three funcs
In the Armature drawing code, split up `get_pchan_color()` into three
separate functions. It was basically one big `switch` with three
`case`s, and there were three calls of the function, each with its own
hard-coded parameter value, one for each `case`.

This now also makes it clear that two of those functions always write to
their return parameter, and thus copying a default color 'just in case'
is no longer necessary, reducing the parameter counts even more.

No functional changes.
2023-07-27 12:14:00 +02:00
Sybren A. Stüvel
725542cf42 Refactor: anim, avoid passing constflag everywhere
Add a `UnifiedBonePtr::constflag()` function to grab the `constflag` from
the bone, so that it doesn't have to be passed as a separate parameter
to every drawing-related function.

No functional changes.
2023-07-27 12:14:00 +02:00
Pratik Borhade
4c12801532 GPv3: Send notifiers and undo push when changing the active layer
Use RNA to update the active layer and also do an undo
push in `on_activate` function of tree-view. This is now
possible after recent refactor: 741c684bf6, 2e9bc6373c

Part of: https://projects.blender.org/blender/blender/pulls/110133

Pull Request: https://projects.blender.org/blender/blender/pulls/110378
2023-07-27 11:37:45 +02:00
Sybren A. Stüvel
69150a35ba Refactor: anim, small refactor of armature drawing code
- Introduce `UnifiedBonePtr` to avoid having to pass `(EditBone *eBone,
  pPoseChannel *pchan)` everywhere.
- Introduce `eArmatureDrawMode` and store that on the
  `ArmatureDrawContext`, to avoid having to pass `bArmature *arm` and
  then doing `arm->flag & ARM_POSEMODE` everywhere.
- Use the `eBone_Flag` type instead of `int`.
- Deprecate the `ARM_POSEMODE` armature flag. It is no longer necessary,
  and also it was changing DNA data from the draw functions. The flag
  was basically purely runtime-only, to pass some information to
  lower-level drawing code, yet it was stored in DNA. It has been
  replaced by the `eArmatureDrawMode`  on the context.

Note that some comparisons `eBone != nullptr` (often using the implicit
conversion of pointer to boolean) have been replaced by a comparison to
`ctx->draw_mode`. This is used in cases where the pointer comparison was
actually indicative of the draw mode, and to help get the `else if
(draw_mode == ARM_DRAW_MODE_POSE)` symmetrical.

Disclaimer: this `UnifiedBonePtr` can probably be used in many other
places in Blender as well. We might move it somewhere else in the
future, but to keep things simple I just want to see how it behaves
locally first.

Pull Request: https://projects.blender.org/blender/blender/pulls/110424
2023-07-27 11:32:11 +02:00
Amelie Fondevilla
b195f9a3da GPv3: Cleanup: Looping over frames in a layer
Use structured binding declaration to unwrap the item into `frame_number` and `frame`.
Makes the code more readable.

Pull Request: https://projects.blender.org/blender/blender/pulls/110525
2023-07-27 11:29:13 +02:00
Christoph Lendenfeld
f7570c5ef4 Animation: Disable NLA mapping if no NLA tracks are present
The drawing code executed NLA mapping code
even though there were no tracks to be mapped.

Disabling this takes the `draw_fcurve` function
from ~1130μs to ~985μs (heavy example scene with dense data)
~13% faster
Of course this only applies when not using the NLA.
And the performance benefit is larger, the more curves are on screen

Pull Request: https://projects.blender.org/blender/blender/pulls/110306
2023-07-27 09:31:43 +02:00
Campbell Barton
1339400845 Cleanup: quite pylint keymap warnings 2023-07-27 16:54:09 +10:00
Julien Kaspar
a7dd864dcf Keymap: simplify default keymap for paint modes
Part of design task #105298 to improve overall consistency.

This removes various shortcuts unused or blocking shortcuts:

- Brush tool shortcuts
  - Mesh sculpt mode shortcuts
     - `X` = Draw
     - `Shift S` = Smooth
     - `P` = Pinch
     - `I` = Inflate
     - `G` = Grab
     - `L` - Layer
     - `Shift T` = Flatten
     - `C` = Clay
     - `Shift C` = Crease
     - `K` = Snake Hook
     - `M` = Mask
  - `D` = Gpencil Vertex Paint - Draw brush

- Duplicate dyntopo shortcut for editing detail size

- Grease Pencil: Undocumented draw tool specific guide shortcuts:
  - `O`, `J`, `Alt J`, `K`, `Alt K`, `Shift K`, `L`, `Alt L`, `Ctrl L`,
    `V`, `M`, `C` & `Alt C`

- `L` = Gpencil: "Alternate" operator shortcut

Also moved erasing box and lasso gesture shortcuts out of specific tools
and into the Draw mode overall.

Ref !108712.
2023-07-27 16:42:17 +10:00
Campbell Barton
98ed1fd011 Fix region toggle pie menu exception on unknown regions
Loading a blend file with unknown regions would raise an exception.
Also remove exception where channels were skipped when the attribute
isn't found as it's no longer needed.
2023-07-27 16:16:23 +10:00
Campbell Barton
3857668756 Remove duplicate keymap item in c14a43acce 2023-07-27 16:00:53 +10:00
Campbell Barton
c14a43acce Fix paint stroke "mode" property being reused when weight painting
Binding a key to weight-paint with mode set (invert/smooth for e.g.)
caused regular weight painting to reuse this setting.

Don't reuse paint "mode" between strokes.
This also allows the default to be removed from the key-map.
2023-07-27 15:58:50 +10:00
Campbell Barton
bdd09a16ef Cleanup: internal keymap function names
- Use km_edit_ prefix for edit-modes.
- Rename "curve" to "curve_legacy".
- Consistent naming for naming for vertex/face selection mask.
- Group object/grease-pencil/paint/edit mode key-map functions together.
2023-07-27 15:17:12 +10:00
Campbell Barton
c7595272eb RNA: fail with an error when unused callbacks are assigned
Exit and fail when set callbacks are assigned to read-only properties
as well as array callbacks for non-array properties.
2023-07-27 15:07:39 +10:00
Campbell Barton
2f39d8df59 Cleanup: remove unused rna_Main_filepath_set callback 2023-07-27 15:07:20 +10:00
Campbell Barton
3da47a6084 Cleanup: remove unused set callbacks from readonly RNA properties
Oversight in 8d9422cfe3.
2023-07-27 14:32:40 +10:00
Harley Acheson
8d9422cfe3 Fix #110508: Text Object Select Attributes in Object Mode
Status of selected bold, italics, underline, and small caps requires
that the curve have an editfont object. Not checking for this works
interactively but can cause errors in Python. This PR adds explicit
getters and setters that check for editfont.

Pull Request: https://projects.blender.org/blender/blender/pulls/110513
2023-07-27 05:31:08 +02:00
Hans Goudey
f557222a7b Fix: Mesh face normal calculation can give zero vectors
Triangles and quads don't check for degenerate faces (where the normal
might be zero), while ngons already set the Z component to 1 for that,
which is also what we do for vertex normals.

Also reorder the face size checks to put quads and triangles before
N-gons, since they are typically more common on high-poly meshes.
And change the check for 2 sided faces into an assert.
2023-07-26 22:53:25 -04:00
Campbell Barton
7548059886 Keymap: restore mirror transform shortcut in weight paint mode
Unintentionally removed in [0]. Weight paint transform should always
follow pose-mode transform.

[0]: d7558a243c
2023-07-27 12:30:44 +10:00
Campbell Barton
cc892efcd4 Cleanup: use snake case, especially for structs that define callbacks
Use snake case for ShaderFxTypeInfo, ModifierTypeInfo,
GpencilModifierTypeInfo & bConstraintTypeInfo.
2023-07-27 12:21:06 +10:00
Campbell Barton
d4b2054f1f Cleanup: various C++ cleanups
- Use C++ headers.
- Use function style cast.
- Use boolean literals.
- Remove redundant struct, void.
- Correct struct comment ID's.
2023-07-27 12:21:06 +10:00
Campbell Barton
27cb0e18b7 code_clean: skip "parenthesis_cleanup" in macro definitions
Don't remove parenthesis in macro definitions as it's important to keep
parenthesis around arguments.
2023-07-27 12:10:14 +10:00
Lukas Stockner
4bd8f24b81 Update OBJ parser tests for Principled BSDF Sheen versioning change
Eventually this will need to be updated for the new Sheen in general,
but we should probably wait with that until all breaking changes for
the Principled BSDF are done.
2023-07-27 03:20:55 +02:00
Campbell Barton
a838e141fe Cleanup: quiet compiler warnings 2023-07-27 10:51:33 +10:00
Lukas Stockner
c66a694056 Cycles: Replace Sheen model in the Principled BSDF
This replaces the Sheen model used in the Principled BSDF with the
model from #108869 that is already used in the Sheen BSDF now.

The three notable differences are:
- At full intensity (Sheen = 1.0), the new model is significantly
  stronger than the old one. For existing files, the intensity is
  adjusted to keep the overall look similar.
- The Sheen Tint input is now a color input, instead of the
  previous blend factor between white and the base color.
- There is now a Sheen roughness control, which can be used to
  tweak the look between velvet-like and dust-like.

Pull Request: https://projects.blender.org/blender/blender/pulls/109949
2023-07-27 02:17:44 +02:00
Jacques Lucke
234f866db2 RNA: move rna_test.c to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110505
2023-07-26 19:27:56 +02:00
Brecht Van Lommel
b3223d3f4f Fix #110426: render hanging when drawing metadata in the image editor
Release must be called regardless if the returned image buffer pointer
is null.
2023-07-26 18:48:24 +02:00
Amelie Fondevilla
0c07fb50c8 GPv3: Keyframe on-click selection
Implementation of the click-selection operator of keyframes in the dopesheet, along with its alternatives : deselect all when no frames is hit, extend selection with shift, column selection with alt, select all keyframes on current channel with ctrl+alt.

Includes the new following API functions :
 * `select_frame_at` : selects a frame in a layer at a specific time (if such frame exists),
 * `select_all_frames` : selects all frames of a layer,
 * `select_layer_channel` : selects a layer, and sets it as active (if layer is not null, otherwise the active layer is set null),
 * `layer_has_frame_selected` : checks if any of the frames in the layer is selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/110492
2023-07-26 17:59:09 +02:00
Brecht Van Lommel
0fab1f4f68 Fix #110170: Cycles CUDA cloud rendering artifacts with spatial splits
The fix in commit d9273d857 exposed a pre-existing issue in the code.
2023-07-26 17:18:45 +02:00
Falk David
d6aa9906fd Modifiers: Add idname field to ModifierTypeInfo
Previously the panel type name of a modifier (e.g. "MOD_PT_Smooth") was
created by copying from the ModifierTypeInfos name.
This meant that modifiers with the same default name would use
the same identifier for the panels.

Since different object types (e.g. OB_GREASE_PENCIL and OB_MESH)
might want to use the same default modifier name, this PR introduces
an idname field in the ModifierTypeInfo struct. This is then used to
generate the panel type name.

For compatibility reasons, the idname is the same as the name for now.

Note: Because the name was used previously, this means that some
modifiers have spaces in their panel type name.
E.g. "MOD_PT_Volume to Mesh".

Pull Request: https://projects.blender.org/blender/blender/pulls/110468
2023-07-26 17:08:14 +02:00
Hans Goudey
580833165c Fix #109583: Avoid non-threadsafe writing to custom normals data
Currently, while calculating face corner normals, Blender retrieves
custom normal data with write access. When the the custom normals in a
single smooth corner fan don't match, they are reset to the average
value.

This behavior is very old, but it comes from when Blender didn't have a
strong idea of const correctness. Indeed, modifying custom normal data
while calculating normals isn't threadsafe, which is important because
normals are calculated for viewport drawing, for example. And in the
future, properly caching face corner normals (see #93551) will require
the ability to calculate normals on a properly const mesh.

The fix is to still use the average of custom normals in a fan, but
not write that back to the custom data array. In my testing the results
are the same. Setting custom normals still fills the same value for all
corners in a fan.

Pull Request: https://projects.blender.org/blender/blender/pulls/110478
2023-07-26 17:04:13 +02:00
Julian Eisel
741c684bf6 Refactor: Pass context to UI view item activate function
The `on_activate()` function is expected to do undo pushes, call
operators, send notifiers and things like that as needed. Context is
necessary for such things, so seems reasonable to provide it as
argument.

Also needed for #110378.
2023-07-26 16:50:17 +02:00
Julian Eisel
2e9bc6373c Refactor: Deduplicate view item active state logic
Much of this was duplicated between grid view and tree view items which
keeping them in sync was becoming a hassle already. Now the logic is
shared via the base class. I find this makes the interfaces easier to
scan through visually as well.

Had to add a virtual iterator function that can be called on an
`AbstractView`.
2023-07-26 16:45:14 +02:00
Jacques Lucke
29aa89e4ec Fix: build error in windows debug builds 2023-07-26 16:39:48 +02:00
Jacques Lucke
932332ad6e BMesh: move bmesh module to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110489
2023-07-26 16:12:55 +02:00
Jacques Lucke
325acb51df Grease Pencil: move legacy grease pencil editors code to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110495
2023-07-26 16:12:48 +02:00
Julian Eisel
5f437908a2 Cleanup: Correct grid view comments 2023-07-26 15:39:47 +02:00
Julian Eisel
dedd55df33 Fix API design issue with activating UI view items
The `on_activate()` function of an item should only be called when the
item was activated through the view, not through an external data change
(e.g. changing an active item through Python). That is important because
`on_activate()` is expected to do things like sending an undo push. This
is now respected in tree and grid views.
2023-07-26 15:39:47 +02:00
Julian Eisel
add3ec71d2 Cleanup: Address clang-tidy warnings in UI views
Unused header warning and `modernize-use-override` warnings.

I would like to selectively disable warnings about redundant `virtual` and
`override` keywords, since both together are useful (`override` enables
important compiler warnings that can avoid bugs, `virtual` helps quickly
identifying API functions available for overriding). But this doesn't
seem to be possible, only all of `modernize-use-override` can be
disabled, so simply keep the `virtual` but comment it out.
2023-07-26 15:39:47 +02:00
Falk David
5846b9164a GeometrySet: Add new GreasePencilComponent
This is mostly boilerplate code to add a new `GeometryComponent` as well as making sure
the new `GeometryComponent::Type` is handled in all the `switch` statements.

Pull Request: https://projects.blender.org/blender/blender/pulls/110457
2023-07-26 13:59:37 +02:00
Campbell Barton
cda7e5af19 PyAPI: expose missing show_region_* properties
Add show_region_channels access for animation editors &
show_region_tools for the spreadsheet.

These could be hidden by resizing the region, there was just not way to
do this from Python.

Exposing these means they can be toggled from WM_MT_region_toggle_pie.
2023-07-26 21:55:26 +10:00
Campbell Barton
88dd1d4408 Keymap: rename "Toolbar Toggle" to "Region Toggle"
The toolbar is only one kind of region that can be toggled.
2023-07-26 21:52:37 +10:00
Jacques Lucke
00e6adb49c Grease Pencil: move legacy grease pencil modifiers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110493
2023-07-26 13:45:04 +02:00
Clément Foucault
38542ceeda DRW: Make tests pass
These were just changes that changed the test
output but not the behavior.
2023-07-26 12:42:36 +02:00
Clément Foucault
ad2771878d DRW: Add missing defines for tests
Prior to that, the Draw tests would be missing.
2023-07-26 11:45:36 +02:00
Clément Foucault
2a286ff0f1 GPU: Make shader tests pass on OpenGL
There was some inconsistencies between GLSL and MSL
regarding vector comparison.
2023-07-26 11:27:48 +02:00
Amelie
4c12988d5a GPv3: Add filtering for channels in the grease pencil dopesheet
Take into account the filtering flags while filtering grease pencil channels in the grease pencil dopesheet.
This PR also adds two API functions for layers :
* `is_empty` checks if a layer contains no frame, and
* `is_selected` checks if a layer is selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/110484
2023-07-26 11:06:36 +02:00
Amelie
8fc2b6ad06 GPv3: Prevent crashes from the dopesheet functions
Some animation operators are not yet implemented for Grease Pencil 3, and trigger asserts. This patch prevents the asserts to be triggered in case of grease pencil channels, so that  Grease Pencil 3 can be tested until the operators are properly implemented.

Pull Request: https://projects.blender.org/blender/blender/pulls/110486
2023-07-26 10:29:40 +02:00