Mesh: Remove unnecessary mesh position copying #105756

Merged
Hans Goudey merged 6 commits from sixthat/blender:remove-unneccessary-vert-pos-copy into main 2023-03-19 00:26:41 +01:00
Contributor

I identified code fragments where BKE_mesh_vert_coords_alloc had been used to temporarily copy vertex coordinates of a mesh (see #103789) and provided pointers to the mesh's stored vertex positions instead.

I identified code fragments where `BKE_mesh_vert_coords_alloc` had been used to temporarily copy vertex coordinates of a mesh (see #103789) and provided pointers to the mesh's stored vertex positions instead.
sixthat added 1 commit 2023-03-14 11:12:14 +01:00
sixthat added 1 commit 2023-03-14 12:03:17 +01:00

Hey, it makes sense to make the description more descriptive about what's going on in the code. You can simply refer to the task so as not to duplicate its text.

Hey, it makes sense to make the description more descriptive about what's going on in the code. You can simply refer to the task so as not to duplicate its text.
Author
Contributor

Thanks for the feedback! I edited the description. Does this suffice? :)

Thanks for the feedback! I edited the description. Does this suffice? :)
sixthat changed title from WIP: Mesh: Remove unnecessary mesh position copying to Mesh: Remove unnecessary mesh position copying 2023-03-14 16:32:51 +01:00
Iliya Katushenock added this to the Modeling project 2023-03-14 16:58:10 +01:00
Iliya Katushenock requested review from Hans Goudey 2023-03-14 16:58:15 +01:00
Hans Goudey requested changes 2023-03-15 02:23:14 +01:00
Hans Goudey left a comment
Member

Thanks! Just noticed a few things looking at the code.

Thanks! Just noticed a few things looking at the code.
@ -749,2 +746,2 @@
BKE_mesh_vert_coords_apply(mesh, vertex_coords);
MEM_freeN(vertex_coords);
mti->deformVerts(
md, &mectx_deform, mesh, BKE_mesh_vert_positions_for_write(mesh), mesh->totvert);
Member

This needs a call to BKE_mesh_tag_positions_changed, otherwise various caches that depend on mesh positions won't be properly updated after the deformation.

This needs a call to `BKE_mesh_tag_positions_changed`, otherwise various caches that depend on mesh positions won't be properly updated after the deformation.
sixthat marked this conversation as resolved
@ -69,3 +66,1 @@
depsgraph, dst, mmd, deformed_verts, num_deformed_verts);
MEM_freeN(deformed_verts);
depsgraph, dst, mmd, BKE_mesh_vert_positions(src_mesh_eval), src_mesh_eval->totvert);
Member

I'm not sure this one is right, since the deformed positions weren't applied back to the mesh afterwards before. If I'm right about that, feel free to leave this out, it can be tweaked more in the future.

I'm not sure this one is right, since the deformed positions weren't applied back to the mesh afterwards before. If I'm right about that, feel free to leave this out, it can be tweaked more in the future.
sixthat marked this conversation as resolved
@ -3504,0 +3499,4 @@
sim->scene,
sim->ob,
psys->hair_in_mesh,
BKE_mesh_vert_positions_for_write(psys->hair_in_mesh));
Member

The update tag from BKE_mesh_vert_coords_apply is missing here too.

The update tag from `BKE_mesh_vert_coords_apply` is missing here too.
sixthat marked this conversation as resolved
@ -1548,0 +1546,4 @@
nullptr,
-1,
BKE_mesh_vert_positions_for_write(src_me),
src_me->totvert);
Member

Same here

Same here
sixthat marked this conversation as resolved
sixthat added 2 commits 2023-03-15 11:08:34 +01:00
sixthat requested review from Hans Goudey 2023-03-15 11:09:22 +01:00
Author
Contributor

I just found a failing test and I'm going to investigate it now. Didn't see a way to withdraw the review request so I just put this in WIP again.

I just found a failing test and I'm going to investigate it now. Didn't see a way to withdraw the review request so I just put this in WIP again.
sixthat changed title from Mesh: Remove unnecessary mesh position copying to WIP: Mesh: Remove unnecessary mesh position copying 2023-03-15 11:58:12 +01:00
sixthat added 1 commit 2023-03-15 21:58:27 +01:00
Author
Contributor

I managed to identify my mistake. The particle_system needed the original vertex positions to stay untouched while computing the deformation. That's why it made a working copy.

Also: I tried to reply to your comments on the code but I cannot see my replies.

I managed to identify my mistake. The particle_system needed the original vertex positions to stay untouched while computing the deformation. That's why it made a working copy. Also: I tried to reply to your comments on the code but I cannot see my replies.
sixthat changed title from WIP: Mesh: Remove unnecessary mesh position copying to Mesh: Remove unnecessary mesh position copying 2023-03-15 22:17:47 +01:00
Member

Hey, thanks for the updates! Could you merge main into this branch and press "Resolve Conversation" on the comments you addressed?

Hey, thanks for the updates! Could you merge main into this branch and press "Resolve Conversation" on the comments you addressed?
sixthat added 1 commit 2023-03-18 22:25:38 +01:00
Author
Contributor

Hey, thanks for the updates! Could you merge main into this branch and press "Resolve Conversation" on the comments you addressed?

Sure! main is merged now and I have closed all conversations that I have addressed :)

> Hey, thanks for the updates! Could you merge main into this branch and press "Resolve Conversation" on the comments you addressed? Sure! main is merged now and I have closed all conversations that I have addressed :)
Hans Goudey approved these changes 2023-03-18 23:28:54 +01:00
Hans Goudey left a comment
Member

Looks good, thanks!

Looks good, thanks!
Member

@blender-bot build

@blender-bot build
Hans Goudey merged commit 3048d9e99c into main 2023-03-19 00:26:41 +01:00
sixthat deleted branch remove-unneccessary-vert-pos-copy 2023-03-21 15:54:35 +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#105756
No description provided.