Data Transfer modifier's Max Distance field working strangely #54526
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
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#54526
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Using Blender 2.89b. EVGA GTX1070. Win10. All non-default add-ons disabled and new scene loaded.
Attached demonstration file contains a cube using a data transfer with max distance enabled to copy weights from a nearby plane, and an armature for that cube. Max Distance settings should put four verts in the domain of the modifier; as you can see, seven verts are affected.
Problem encountered in less abstract situations as well, this is just my simplest reduction of the problem in order to verify that it's an issue and make it plain to see and reproduce.
For reference, official documentation reads, "This allows to transfer a small sub-detailed mesh onto a more complete one (e.g. from a “hand” mesh towards a “full body” one)," which would be useful if it were working properly.
DataDistance1.blend
Added subscriber: @vasiln
Added subscriber: @lichtwerk
Confirming on first sight, having a closer look now...
Added subscriber: @mont29
I'll claim for the time being and do some further investiagtion. If that doesnt succeed, I'll get @mont29 on board to help me out...
Coming back to add that there's a reasonable workaround, which is to use a vertex weight proximity modifier to determine the distance from each vertex before the weight transfer, use a custom (constant) curve to modulate that vertex group, and then use it to modulate the data transfer. It's a bit more work for the end user, but perfectly reasonable, and it wouldn't seem unreasonable to just drop support for max distance from the data transfer.
Added subscriber: @angavrilov
Had a look at this again and here are some findings:
BKE_mesh_remap_calc_verts_from_mesh
/mesh_remap_bvhtree_query_nearest
is where things happennearest.index
to -1]BLI_bvhtree_find_nearest()
is called with a "nearest" provided, code will not update anything on "nearest" (esp. notindex
, notdist_sq
) if it fails to find something.index
is not neccessarily -1 if it fails to find something.nearest.index
non-zero], and then for the next vertex dont find anything, we still have a non-zeroindex
leading to false positives in the following code.It actually works fine if the index is reset to -1 for each vert.
Could be like this (would have to be done for a couple of other loops as well):
P967: T54526_snippet_1
Or more general like:
P968: T54526_snippet_2
@angavrilov, @mont29: what do you think?
@lichtwerk nice catch. Wouldn’t it be even simpler to always reset that
nearest->index
directly inBLI_bvhtree_find_nearest_ex()
? Keeping previous nearest distance there if provided makes sense, but I think item index should be always reset, at least I cannot see a case where keeping previous value would be useful?Added subscribers: @mano-wii, @brecht
I went over usages of
BLI_bvhtree_find_nearest
/BLI_bvhtree_find_nearest_projected
and here are some findings:these are the ones that always set item index to -1 before calling, it looks like an index of -1 ALWAYS should be OK:
dynamic_paint_paint_mesh_cell_point_cb_ex
(called in a loop, item index set to -1 prior every time)BKE_bmbvh_find_vert_closest
(called once, item index set to -1 prior)BKE_bmbvh_find_face_closest
(called once, item index set to -1 prior)closest_point_on_surface
(called once, item index set to -1 prior)obstacles_from_mesh_task_cb
(smoke code, called in a loop, item index set to -1 prior every time)sample_mesh
(smoke code, called once, item index set to -1 prior)remap_hair_emitter
(called in a loop, item index set to -1 prior every time)rna_Object_closest_point_on_mesh
(called once, item index set to -1 prior)nearestVert
(surface deform modifier, called once, item index set to -1 prior)vert2geom_task_cb_ex
(weight proximity modifier, called once, item index set to -1 prior every time)py_bvhtree_find_nearest
(called once, item index set to -1 prior)find_nearest_points_test
(called with NULL)snapping: these are the ones that set item index to -1 before calling but then could enter multiple times (vert, edge, ...), not sure if an index of -1 ALWAYS would be OK? maybe @mano-wii knows more?:
snapMesh
(item index set to -1 prior, but multiple usages here which could all be entered?... not sure)snapEditMesh
(item index set to -1 prior, but multiple usages here which could all be entered?... not sure)shrinkwrap: not 100% sure, but it looks like an index of -1 ALWAYS should be OK
shrinkwrap_calc_nearest_vertex_cb_ex
(resets index to -1, but in ParallelRangeSettings, seeshrinkwrap_calc_nearest_surface_point
, not 100% sure...)BKE_shrinkwrap_find_nearest_surface
(does not reset index to -1, needs checking, called fromshrinkwrap_get_tarmat
[where index is set to -1] /shrinkwrap_calc_nearest_vertex_cb_ex
[see above])our candidate for this report:), looks like an index of -1 ALWAYS should be OK
mesh_remap_bvhtree_query_nearest
(does not reset index to -1 atm., results in bug)Will also subscribe @brecht as lead architect here, but if we want to have this in for RC1, propose to actually play safe and go with D5206?
Keeping the previous search result when doing multiple nearest searches is a very important heuristic optimization. Not doing that in shrinkwrap for instance will absolutely butcher performance.
This heuristic however obviously relies on the previous search result being a valid candidate for the new search (i.e. it can be reused as is if it's still the nearest point).
More specifically, BVH nearest search code by default doesn't bother to ensure an optimal search order through the tree, because using the previous search result to prime the search and prune the tree works out to be faster. When implementing the new more complicated shrinkwrap mode that can't use this heuristic, I had to add
BLI_bvhtree_find_nearest_ex
andBVH_NEAREST_OPTIMAL_ORDER
to get good performance.Perhaps
BVH_NEAREST_OPTIMAL_ORDER
should be the default behavior instead (and also ignore the previous result), while the heuristic behavior should be invoked throughBVH_NEAREST_REUSE_RESULT
or something like that. I did it the way it is currently to avoid changing old code all over the place.@angavrilov : thx for the heads up, will check on this (might take a bit to go over all cases), for the "quick fix": D5206 should still be fine, right?
These are cases where changing the nearest.index to -1 between calls would result in problems.
Still an issue. Will have to go through the points raised here (and in D5206) again
This issue was referenced by
3b84dce969
Changed status from 'Confirmed' to: 'Resolved'