Lattice with modifier (show in editmode enabled) does not show original editlattice -- or misses editpoints on the deformed lattice #95574

Open
opened 2022-02-07 06:10:33 +01:00 by Campbell Barton · 11 comments

Since 2.8x, lattices have not been displaying selected vertices when the modifier option "Edit Mode" id enabled.

This is easy to test:

  • add a new lattice object
  • add a wave deform modifier.
  • enter edit-mode.
  • enable "Edit Mode" toggle for the modifier.

This test file shows the problem too, open it and toggle the "Edit Mode" modifier button.

#77184.blend


Reporting this to keep track of the issue: BKE_lattice_modifiers_calc is making a copy of the lattice lt_eval which doesn't contain an edit-lattice, which is then used for drawing.

Since 2.8x, lattices have not been displaying selected vertices when the modifier option "Edit Mode" id enabled. This is easy to test: - add a new lattice object - add a wave deform modifier. - enter edit-mode. - enable "Edit Mode" toggle for the modifier. This test file shows the problem too, open it and toggle the "Edit Mode" modifier button. [#77184.blend](https://archive.blender.org/developer/F8571609/T77184.blend) ---- Reporting this to keep track of the issue: `BKE_lattice_modifiers_calc` is making a copy of the lattice `lt_eval` which doesn't contain an edit-lattice, which is then used for drawing.
Author
Owner

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:12:54 +01:00

version:3.6.2
after my test, even I chose "show in front", vertices of the lattice will still get covered by mesh

version:3.6.2 after my test, even I chose "show in front", vertices of the lattice will still get covered by mesh
Member

As mentioned in #119268, shouldnt this draw the (editable -- with points) undeformed editlattice? Plus the (deformed) version as wires only?

As mentioned in #119268, shouldnt this draw the (editable -- with points) undeformed editlattice? Plus the (deformed) version as wires only?
Member

If we just show the points on the deformed version, it would be like show_in_editmode plus show_on_cage ...

If we just show the points on the deformed version, it would be like `show_in_editmode` plus `show_on_cage` ...
Member

Reporting this to keep track of the issue: BKE_lattice_modifiers_calc is making a copy of the lattice lt_eval which doesn't contain an edit-lattice, which is then used for drawing.

I tried looking at this for a bit, and it seems we could share the editlattice with something like the following (but then again we would be only showing the original [undeformed] editlattice -- and would be loosing the evaluated version for drawing -- think this burried deeper / or just missing in the way LatticeRenderData works).

diff --git a/source/blender/blenkernel/intern/lattice.cc b/source/blender/blenkernel/intern/lattice.cc
index fde95d5aa45..9c219a9a705 100644
--- a/source/blender/blenkernel/intern/lattice.cc
+++ b/source/blender/blenkernel/intern/lattice.cc
@@ -559,7 +559,8 @@ void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
   Lattice *lt_eval = BKE_object_get_evaluated_lattice(ob);
   if (lt_eval == nullptr) {
     BKE_id_copy_ex(nullptr, &lt->id, (ID **)&lt_eval, LIB_ID_COPY_LOCALIZE);
-    BKE_object_eval_assign_data(ob, &lt_eval->id, true);
+    lt_eval->editlatt = lt->editlatt;
+    BKE_object_eval_assign_data(ob, &lt_eval->id, false);
   }
 
   BKE_lattice_vert_coords_apply(lt_eval, vert_coords);

Subscribing @Sergey @dr.sybren here since they might be interested (and will close #119268 as a duplicate)

>Reporting this to keep track of the issue: BKE_lattice_modifiers_calc is making a copy of the lattice lt_eval which doesn't contain an edit-lattice, which is then used for drawing. I tried looking at this for a bit, and it seems we could share the editlattice with something like the following (but then again we would be only showing the original [undeformed] editlattice -- and would be loosing the evaluated version for drawing -- think this burried deeper / or just missing in the way `LatticeRenderData` works). ```diff diff --git a/source/blender/blenkernel/intern/lattice.cc b/source/blender/blenkernel/intern/lattice.cc index fde95d5aa45..9c219a9a705 100644 --- a/source/blender/blenkernel/intern/lattice.cc +++ b/source/blender/blenkernel/intern/lattice.cc @@ -559,7 +559,8 @@ void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob) Lattice *lt_eval = BKE_object_get_evaluated_lattice(ob); if (lt_eval == nullptr) { BKE_id_copy_ex(nullptr, &lt->id, (ID **)&lt_eval, LIB_ID_COPY_LOCALIZE); - BKE_object_eval_assign_data(ob, &lt_eval->id, true); + lt_eval->editlatt = lt->editlatt; + BKE_object_eval_assign_data(ob, &lt_eval->id, false); } BKE_lattice_vert_coords_apply(lt_eval, vert_coords); ``` Subscribing @Sergey @dr.sybren here since they might be interested (and will close #119268 as a duplicate)
Philipp Oeser changed title from Lattices don't display selected vertices with modifier "Edit Mode" enabled to Lattice with modifier (show in editmode enabled) does not show original editlattice -- or misses editpoints on the deformed lattice 2024-03-15 17:06:09 +01:00
Philipp Oeser added the
Interest
Animation & Rigging
Interest
Dependency Graph
labels 2024-03-15 17:08:05 +01:00

@lichtwerk Assigning lt_eval->editlatt = lt->editlatt; seems correct to me.
The change to the non-owning evaluated result (true -> false in the BKE_object_eval_assign_data(ob, &lt_eval->id, false);) seems strange as the lt_eval is allocated by the BKE_id_copy_ex(nullptr, &lt->id, (ID **)&lt_eval, LIB_ID_COPY_LOCALIZE); above. So intuitively this cases a leak.

Maybe you can move the patch to a PR, so we can discuss details there instead of a bug report?

@lichtwerk Assigning `lt_eval->editlatt = lt->editlatt;` seems correct to me. The change to the non-owning evaluated result (`true` -> `false` in the `BKE_object_eval_assign_data(ob, &lt_eval->id, false);`) seems strange as the `lt_eval` is allocated by the `BKE_id_copy_ex(nullptr, &lt->id, (ID **)&lt_eval, LIB_ID_COPY_LOCALIZE);` above. So intuitively this cases a leak. Maybe you can move the patch to a PR, so we can discuss details there instead of a bug report?
Member

@Sergey : just sharing the editlatt leads to crashes in lattice_free_data when show_in_editmode is used and you switch modes.

Think I need to dig a bit more wrt ownership etc. before I can put up a PR

@Sergey : just sharing the `editlatt` leads to crashes in `lattice_free_data` when `show_in_editmode` is used and you switch modes. Think I need to dig a bit more wrt ownership etc. before I can put up a PR

@lichtwerk Ah, indeed. Because Lattice is owning the EditLatt. Perhaps the EditLatt should have something similar to BMEditMesh::is_shallow_copy.

@lichtwerk Ah, indeed. Because `Lattice` is owning the `EditLatt`. Perhaps the `EditLatt` should have something similar to `BMEditMesh::is_shallow_copy`.

@Sergey wrote:
Assigning lt_eval->editlatt = lt->editlatt; seems correct to me.

I'm not intimately familiar with the lattice data structures. At first glance I wonder whether this wouldn't be a case of an evaluated copy pointing to non-evaluated data?

> @Sergey wrote: > Assigning `lt_eval->editlatt = lt->editlatt;` seems correct to me. I'm not intimately familiar with the lattice data structures. At first glance I wonder whether this wouldn't be a case of an evaluated copy pointing to non-evaluated data?

@dr.sybren The edit mode is the source of truth, and is shared between original and evaluated state. You can see mesh_final->edit_mesh manipulation in the editbmesh_calc_modifiers.

@dr.sybren The edit mode is the source of truth, and is shared between original and evaluated state. You can see `mesh_final->edit_mesh` manipulation in the `editbmesh_calc_modifiers`.
Sign in to join this conversation.
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
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#95574
No description provided.