GPv3: Subdivide modifier #117056
No reviewers
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#117056
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChengduLittleA/blender:gp3-mod-subdiv"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ported stroke subdivide modifier to GPv3.
Note: catmull smooth is not present in this modifier, all it does is to subdivide strokes. In versioning, the old subdiv modifier probably should be replaced into two modifiers Subdiv+Smooth combo using the new curve subdiv/smooth functions.
WIP: GPv3: Subdivide modifierto GPv3: Subdivide modifierSome comments.
@ -1129,12 +1129,12 @@ static int add_material_from_template(Main &bmain, Object &ob, const ColorTempla
return index;
}
static bke::CurvesGeometry create_drawing_data(const Span<float3> positions,
These changes shouldn't be in the PR.
@ -200,6 +200,13 @@ IndexMask retrieve_editable_and_selected_elements(Object &object,
bke::AttrDomain selection_domain,
IndexMaskMemory &memory);
bke::CurvesGeometry create_drawing_data(const Span<float3> positions,
These changes shouldn't be in the PR.
Should I create a separate PR for exposing thiscreate_drawing_data
function?Wait.. Ignore, I don't know why this is here...
@ -2486,6 +2487,7 @@ typedef enum VolumeToMeshFlag {
VOLUME_TO_MESH_USE_SMOOTH_SHADE = 1 << 0,
} VolumeToMeshFlag;
/* enum is kept in legacy dna. */
What is this comment for?
@ -2550,0 +2555,4 @@
GreasePencilModifierInfluenceData influence;
/** `GreasePencilSubdivModifierFlag`. */
int flag;
/** Factor of subdivision. */
Factor of subdivision
->Number of subdivisions
@ -0,0 +98,4 @@
static void deform_stroke(ModifierData *md,
Depsgraph * /*depsgraph*/,
Object *ob,
bke::greasepencil::Drawing *drawing)
Pass the drawing by reference:
bke::greasepencil::Drawing &drawing
@ -0,0 +102,4 @@
{
GreasePencilSubdivModifierData *mmd = (GreasePencilSubdivModifierData *)md;
if (mmd->level < 1) {
Shouldn't this check be in
modify_geometry_set
?@ -0,0 +122,4 @@
bke::GeometrySet *geometry_set)
{
GreasePencilSubdivModifierData *mmd = (GreasePencilSubdivModifierData *)md;
GreasePencil *gp = geometry_set->get_grease_pencil_for_write();
Put this after the check below and use a reference like so:
@ -0,0 +123,4 @@
{
GreasePencilSubdivModifierData *mmd = (GreasePencilSubdivModifierData *)md;
GreasePencil *gp = geometry_set->get_grease_pencil_for_write();
const int frame = DEG_get_evaluated_scene(ctx->depsgraph)->r.cfra;
frame
->current_frame
@ -0,0 +125,4 @@
GreasePencil *gp = geometry_set->get_grease_pencil_for_write();
const int frame = DEG_get_evaluated_scene(ctx->depsgraph)->r.cfra;
if (!gp) {
Use
!geometry_set->has_grease_pencil()
@ -0,0 +130,4 @@
}
IndexMaskMemory mask_memory;
IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
const IndexMask
@ -0,0 +174,4 @@
}
ModifierTypeInfo modifierType_GreasePencilSubdiv = {
/*idname*/ "Grese Pencil Subdiv Modifier",
"Grese Pencil Subdiv Modifier"
->"GreasePencilSubdivModifier"
@ -0,0 +175,4 @@
ModifierTypeInfo modifierType_GreasePencilSubdiv = {
/*idname*/ "Grese Pencil Subdiv Modifier",
/*name*/ N_("Subdiv Modifier"),
"Subdivide"
@ -0,0 +123,4 @@
return;
}
GreasePencil *gp = geometry_set->get_grease_pencil_for_write();
GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write();
This looks very close now!
@ -0,0 +55,4 @@
static void init_data(ModifierData *md)
{
GreasePencilSubdivModifierData *gpmd = (GreasePencilSubdivModifierData *)md;
C++ casts, same for the rest of the file
@ -0,0 +95,4 @@
modifier::greasepencil::read_influence_data(reader, &mmd->influence);
}
static void deform_stroke(ModifierData *md,
I guess this function should now be named
deform_drawing
since it acts on one drawing at a time.Nice! Looks good!
@ -7680,0 +7708,4 @@
prop = RNA_def_property(srna, "open_influence_panel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(
prop, nullptr, "flag", MOD_GREASE_PENCIL_OPACITY_OPEN_INFLUENCE_PANEL);
This can use
rna_def_modifier_panel_open_prop
@ -0,0 +8,4 @@
#include "BLI_array.hh"
#include "BLI_index_mask.hh"
#include "BLI_math_matrix.h"
Looks like some unused includes here
@ -0,0 +97,4 @@
modifier::greasepencil::read_influence_data(reader, &mmd->influence);
}
static void deform_drawing(ModifierData *md,
Use references for pointer arguments that shouldn't be null
@ -0,0 +108,4 @@
const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask(
ob, drawing.strokes_for_write(), mmd->influence, memory);
VArray<int> cuts = VArray<int>::ForSingle(mmd->level, drawing.strokes().points_num());
Seems like this should use something more like
2^mmd->level
, otherwise this changes behavior compared to GPv2Although this is true, I would like to keep this the way it is now and handle old values during versioning.
Sounds good. That can be mentioned in the commit message then.
Yes, there is also #114419 where I try to document this :D
@ -7680,0 +7713,4 @@
prop = RNA_def_property(srna, "level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "level");
RNA_def_property_range(prop, 0, 16);
RNA_def_property_ui_range(prop, 0.0, 5.0, 1, 0);
soft min/max should be int values, no? :)
humm looks like everywhere else uses float so I'm not sure. It's just what the function accepts
@ -7680,0 +7701,4 @@
rna_def_modifier_grease_pencil_layer_filter(srna);
rna_def_modifier_grease_pencil_material_filter(
srna, "rna_GreasePencilOpacityModifier_material_filter_set");
This looks wrong. Should be
rna_GreasePencilSubdivModifier_material_filter_set
. Same for vgroupAnd possibly also need to include
RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilSubdiv)
if I understood correctly.Wait but I haven't tested your PR locally yet, will do that :)
Yepp thanks for pointing that out. I thought it was for a generic function. Looks like I need to rename that.
Looks good otherwise 😅
@ -7680,0 +7715,4 @@
prop = RNA_def_property(srna, "level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "level");
RNA_def_property_range(prop, 0, 16);
RNA_def_property_ui_range(prop, 0.0, 5.0, 1, 0);
Hm I don't think these ranges make sense anymore (because of the 2^n thing previously). Have you tested the modifier with these limits? I think we should go up to 32 (2^5) and make the maximum 65536 (2^16).
Good point... since the algorithm is different now.
Tested this locally and found some issues.
@ -7680,0 +7717,4 @@
/* Since the new subdiv algorithm uses linear cut count, we set the limits as 2^n the old value
* to get the same range as before. */
RNA_def_property_range(prop, 0, 2 ^ 16);
RNA_def_property_ui_range(prop, 0, 2 ^ 5, 1, 0);
😅 This won't work. The
^
is the bitwise xor operator. You should just write in the values.65536
and32
.@ -0,0 +174,4 @@
/*struct_name*/ "GreasePencilSubdivModifierData",
/*struct_size*/ sizeof(GreasePencilSubdivModifierData),
/*srna*/ &RNA_GreasePencilSubdivModifier,
/*type*/ ModifierTypeType::Nonconstructive,
The type is not right, this should be
ModifierTypeType::Constructive
.But this modifier essentially deletes previous strokes and create new ones?
Hm maybe @JacquesLucke can clarify what should be used?
Constructive
seems right. Also seemodifierType_Subsurf
.@ -0,0 +175,4 @@
/*struct_size*/ sizeof(GreasePencilSubdivModifierData),
/*srna*/ &RNA_GreasePencilSubdivModifier,
/*type*/ ModifierTypeType::Nonconstructive,
/*flags*/ eModifierTypeFlag_AcceptsGreasePencil,
There are some missing flags here. Use
7d94c0c64b
tod703724517
@blender-bot build
Alright, accepting this 👍 Will kick a build and when that goes through I think we're ready to merge.