GPv3: Weight proximity modifier #118363

Merged
Falk David merged 10 commits from ChengduLittleA/blender:gp3-mod-wproximity into main 2024-02-19 11:16:48 +01:00
Member

Weight proximity modifier migrated to GPv3.

图片

Weight proximity modifier migrated to GPv3. ![图片](/attachments/22182e4e-30aa-4fa8-8f17-e7de62119bef)
YimingWu added the
Interest
Grease Pencil
Module
Grease Pencil
labels 2024-02-16 09:46:50 +01:00
YimingWu added 3 commits 2024-02-16 09:47:00 +01:00
YimingWu added this to the Grease Pencil project 2024-02-16 09:47:17 +01:00
YimingWu added 1 commit 2024-02-16 09:50:42 +01:00
Falk David requested review from Falk David 2024-02-16 10:52:38 +01:00
Falk David requested changes 2024-02-16 11:08:30 +01:00
Falk David left a comment
Member

First pass. Generally, this looks really good already.

First pass. Generally, this looks really good already.
@ -2870,0 +2884,4 @@
struct Object *object;
} GreasePencilWeightProximityModifierData;
typedef enum eGreasePencilWeightProximityFlag {
Member

There is no need for the e prefix anymore.

There is no need for the `e` prefix anymore.
ChengduLittleA marked this conversation as resolved
@ -0,0 +111,4 @@
float3 target_pos, float4x4 obmat, float3 pos, const float dist_min, const float dist_max)
{
float weight;
const float3 gvert = (obmat * float4(pos, 1.0f)).xyz();
Member

Use math::transform_point(obmat, pos);

Use `math::transform_point(obmat, pos);`
ChengduLittleA marked this conversation as resolved
@ -0,0 +112,4 @@
{
float weight;
const float3 gvert = (obmat * float4(pos, 1.0f)).xyz();
const float dist = math::length(target_pos - gvert);
Member

Use math::distance(traget_pos, gvert);

Use `math::distance(traget_pos, gvert);`
ChengduLittleA marked this conversation as resolved
@ -0,0 +115,4 @@
const float dist = math::length(target_pos - gvert);
if (dist > dist_max) {
weight = 1.0f;
Member

Instead of setting weight, just return the value directly.

Instead of setting `weight`, just return the value directly.
ChengduLittleA marked this conversation as resolved
@ -0,0 +117,4 @@
if (dist > dist_max) {
weight = 1.0f;
}
else if (dist <= dist_max && dist > dist_min) {
Member

else if -> if (with changes above)

`else if` -> `if` (with changes above)
ChengduLittleA marked this conversation as resolved
@ -0,0 +120,4 @@
else if (dist <= dist_max && dist > dist_min) {
weight = 1.0f - ((dist_max - dist) / math::max((dist_max - dist_min), 0.0001f));
}
else {
Member

-> return 0.0f

-> `return 0.0f`
ChengduLittleA marked this conversation as resolved
@ -0,0 +179,4 @@
const VArray<float> vgroup_weights = modifier::greasepencil::get_influence_vertex_weights(
curves, mmd.influence);
const Span<float3> positions = curves.positions_for_write();
Member

Since we're not writing to the positions, use curves.positions();

Since we're not writing to the positions, use `curves.positions();`
ChengduLittleA marked this conversation as resolved
@ -0,0 +184,4 @@
const float3 target_pos = mmd.object ? mmd.object->object_to_world().location() : float3(0.0f);
threading::parallel_for(positions.index_range(), 1024, [&](const IndexRange range) {
for (const int point : range) {
Member

point -> point_i

`point` -> `point_i`
ChengduLittleA marked this conversation as resolved
@ -0,0 +185,4 @@
threading::parallel_for(positions.index_range(), 1024, [&](const IndexRange range) {
for (const int point : range) {
const float vgroup_fac = vgroup_weights[point];
Member

vgroup_fac -> weight

`vgroup_fac` -> `weight`
ChengduLittleA marked this conversation as resolved
@ -0,0 +195,4 @@
target_pos, obmat, positions[point], mmd.dist_start, mmd.dist_end) :
1.0f;
if (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_INVERT_OUTPUT) {
Member

To make this a bit cleaner, I'd move this out of the loop and just use if (invert) ... here.

const bool invert = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_INVERT_OUTPUT) != 0;
To make this a bit cleaner, I'd move this out of the loop and just use `if (invert) ...` here. ``` const bool invert = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_INVERT_OUTPUT) != 0; ```
ChengduLittleA marked this conversation as resolved
@ -0,0 +199,4 @@
dist_fac = 1.0f - dist_fac;
}
dst_weights.span[point] = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_MULTIPLY_DATA) ?
Member

Same as above.

const bool use_distance_as_factor = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_MULTIPLY_DATA) != 0;
Same as above. ``` const bool use_distance_as_factor = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_MULTIPLY_DATA) != 0; ```
ChengduLittleA marked this conversation as resolved
YimingWu added 1 commit 2024-02-16 11:56:01 +01:00
Falk David approved these changes 2024-02-16 12:21:37 +01:00
Falk David left a comment
Member

One more comment, rest looks good to me.

One more comment, rest looks good to me.
@ -0,0 +141,4 @@
{
const int def_nr = BLI_findstringindex(
&vertex_group_names, name.c_str(), offsetof(bDeformGroup, name));
if (def_nr < 0)
Member

Always use { ... }

Always use `{ ... } `
ChengduLittleA marked this conversation as resolved
Member

@LukasTonne Could you take a quick look too?

@LukasTonne Could you take a quick look too?
Falk David requested review from Lukas Tönne 2024-02-16 12:22:20 +01:00
YimingWu added 1 commit 2024-02-16 12:23:39 +01:00
YimingWu added 2 commits 2024-02-16 14:58:48 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
88ca79d02e
format
Author
Member

@blender-bot build

@blender-bot build
Falk David reviewed 2024-02-16 17:13:51 +01:00
@ -0,0 +290,4 @@
ModifierTypeInfo modifierType_GreasePencilWeightProximity = {
/*idname*/ "GreasePencilWeightProximityModifier",
/*name*/ N_("Weight Angle"),
Member

While testing I noticed the name was not correct.

While testing I noticed the name was not correct.
ChengduLittleA marked this conversation as resolved
Falk David approved these changes 2024-02-16 17:20:46 +01:00
Falk David left a comment
Member

Once the name is changed, I think this is ready.

Once the name is changed, I think this is ready.
Lukas Tönne approved these changes 2024-02-16 18:41:20 +01:00
Lukas Tönne left a comment
Member

Looks good!

Looks good!
@ -0,0 +64,4 @@
modifier::greasepencil::free_influence_data(&mmd->influence);
}
static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/)
Member

I'm assuming the GPv2 modifier also worked with the object being null? Otherwise might want to disable the modifier when the object is null.

I'm assuming the GPv2 modifier also worked with the object being null? Otherwise might want to disable the modifier when the object is null.
Author
Member

Huh... The one in v2 does seems to disable when object is not present, but the logic in deform_stroke does take object==null into account, which is kinda weird.

I'll add that check in is_disabled then.

Huh... The one in v2 does seems to disable when object is not present, but the logic in `deform_stroke` does take `object==null` into account, which is kinda weird. I'll add that check in `is_disabled` then.
LukasTonne marked this conversation as resolved
YimingWu added 1 commit 2024-02-18 05:27:57 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
04dc76d451
Cleanups
Author
Member

@blender-bot build

@blender-bot build
Falk David added 1 commit 2024-02-19 10:54:14 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
3330cdfeb3
Merge branch 'main' into gp3-mod-wproximity
Member

@blender-bot build

@blender-bot build
Falk David merged commit ae20873250 into main 2024-02-19 11:16:48 +01: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#118363
No description provided.