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 .
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.
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.
- 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
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
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.
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.
- 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.
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
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.
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.
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
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
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
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
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.
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`.
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.
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.
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
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.
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
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