GPv3: Initial modifier support #110500

Merged
Falk David merged 3 commits from filedescriptor/blender:gpv3-initial-modifier-support into main 2023-07-28 14:25:47 +02:00
Member

This commit adds modifier support for Grease Pencil 3.
The BKE_grease_pencil_data_update function evaluates the modifiers by
first creating a GeometrySet from the grease pencil data,
then evaluating the modifiers, and finally reading the
resulting GreasePencilComponent component and assigning
the evaluated object data.

This commit adds modifier support for Grease Pencil 3. The `BKE_grease_pencil_data_update` function evaluates the modifiers by first creating a `GeometrySet` from the grease pencil data, then evaluating the modifiers, and finally reading the resulting `GreasePencilComponent` component and assigning the evaluated object data.
Falk David added this to the Grease Pencil project 2023-07-26 16:51:08 +02:00
Falk David requested review from Jacques Lucke 2023-07-26 16:51:20 +02:00
Hans Goudey requested changes 2023-07-27 14:18:25 +02:00
Hans Goudey left a comment
Member

Great how simple the modifier stack can be without all the legacy stuff going on :)

Great how simple the modifier stack can be without all the legacy stuff going on :)
@ -1076,1 +1084,4 @@
blender::bke::GeometrySet &geometry_set)
{
/* Modifier evaluation modes. */
const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
Member

Picky, but these parentheses don't really help IMO

Picky, but these parentheses don't really help IMO
filedescriptor marked this conversation as resolved
@ -1076,1 +1085,4 @@
{
/* Modifier evaluation modes. */
const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime;
Member

Can you use the proper enum type for this variable?

Can you use the proper enum type for this variable?
filedescriptor marked this conversation as resolved
@ -1077,0 +1087,4 @@
const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime;
if (BKE_object_is_in_editmode(object)) {
required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode);
Member

This enum has ENUM_OPERATORS now, this casting shouldn't be necessary

This enum has `ENUM_OPERATORS` now, this casting shouldn't be necessary
filedescriptor marked this conversation as resolved
@ -1077,0 +1101,4 @@
/* Evaluate modifiers. */
for (; md; md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
Member

Use functional style cast for enum types

Use functional style cast for enum types
filedescriptor marked this conversation as resolved
@ -1083,2 +1125,4 @@
grease_pencil, GeometryOwnershipType::ReadOnly);
grease_pencil_evaluate_modifiers(depsgraph, scene, object, geometry_set);
/* Assign evaluated object. */
Member

Maybe reference the explanation for the const cast from another object type, since otherwise this raises some eyebrows

Maybe reference the explanation for the const cast from another object type, since otherwise this raises some eyebrows
filedescriptor marked this conversation as resolved
Falk David force-pushed gpv3-initial-modifier-support from cf37700e66 to 4d5f674205 2023-07-27 15:38:39 +02:00 Compare
Hans Goudey approved these changes 2023-07-27 15:42:20 +02:00
Hans Goudey left a comment
Member

Looks good, left one suggestion to simplify things inline

Looks good, left one suggestion to simplify things inline
@ -1086,3 +1133,1 @@
GreasePencil *grease_pencil_eval = reinterpret_cast<GreasePencil *>(
BKE_id_copy_ex(nullptr, &grease_pencil->id, nullptr, LIB_ID_COPY_LOCALIZE));
BKE_object_eval_assign_data(object, &grease_pencil_eval->id, true);
if (grease_pencil_eval == nullptr) {
Member

To make the geometry_set_eval and data_eval consistent, this second call to BKE_object_eval_assign_data could be replaced with:

if (!geometry_set.has_grease_pencil()) {
  geometry_set.replace_grease_pencil(BKE_grease_pencil_new_nomain());
}

Eventually it would be nice to remove data_eval completely for geometry object types, that gets us a bit closer.

To make the `geometry_set_eval` and `data_eval` consistent, this second call to `BKE_object_eval_assign_data` could be replaced with: ``` if (!geometry_set.has_grease_pencil()) { geometry_set.replace_grease_pencil(BKE_grease_pencil_new_nomain()); } ``` Eventually it would be nice to remove `data_eval` completely for geometry object types, that gets us a bit closer.
Author
Member

Do you mean the first call to BKE_object_eval_assign_data?
Wouldn't that mean that for the object we only change object->runtime.geometry_set_eval and not the other things that BKE_object_eval_assign_data changes?

Do you mean the first call to `BKE_object_eval_assign_data`? Wouldn't that mean that for the `object` we only change `object->runtime.geometry_set_eval` and not the other things that `BKE_object_eval_assign_data` changes?
Member

Yeah, like this:

if (!geometry_set.has_grease_pencil()) {
  geometry_set.replace_grease_pencil(BKE_grease_pencil_new_nomain());
}

GreasePencil *grease_pencil_eval = const_cast<GreasePencil *>(
    geometry_set.get_grease_pencil_for_read());
BKE_object_eval_assign_data(object, &grease_pencil_eval->id, false);

object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set));
Yeah, like this: ``` if (!geometry_set.has_grease_pencil()) { geometry_set.replace_grease_pencil(BKE_grease_pencil_new_nomain()); } GreasePencil *grease_pencil_eval = const_cast<GreasePencil *>( geometry_set.get_grease_pencil_for_read()); BKE_object_eval_assign_data(object, &grease_pencil_eval->id, false); object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set)); ```
filedescriptor marked this conversation as resolved
Falk David added 1 commit 2023-07-27 16:21:42 +02:00
Hans Goudey approved these changes 2023-07-27 16:35:04 +02:00
Jacques Lucke approved these changes 2023-07-28 13:42:51 +02:00
Falk David merged commit 20b1077097 into main 2023-07-28 14:25:47 +02:00
Falk David deleted branch gpv3-initial-modifier-support 2023-07-28 14:25:50 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#110500
No description provided.