Loose edges do not initially render after creating new mesh object #92394

Open
opened 2021-10-21 20:43:08 +02:00 by jon denning · 7 comments
Member

System Information
Operating system: Linux-5.11.0-37-generic-x86_64-with-glibc2.33 64 Bits
Graphics card: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.63.01

Blender Version
Broken: version: 2.93.5, branch: master, commit date: 2021-10-05 12:04, hash: blender/blender@a791bdabd0
Worked: not sure when it ever worked

Short description of error
When creating a new mesh object with loose edges, the edges do not render initially. Must add modifier that changes the mesh or tab into edit mode.

Exact steps for others to reproduce the error
Create a new mesh object using Python that contains loose edges.

Easiest way to reproduce is to import the attached PLY file. This file is just a cube with the top five faces removed (deleted faces only).

cube.ply

After importing, you will see only the bottom face---no edges.

cube_ply_0.png

Tabbing into edit mode shows the face and 8 loose edges as expected.

cube_ply_1.png

Tabbing back into object mode shows the mesh correctly now.

cube_ply_2.png

I've tested this in 2.93.5, 2.92, 2.91, 2.90, 2.83, and today's build of 3.0.0 alpha, and all have this same issue.

The Triangulate and Bevel modifiers do cause the loose edges to show, but once you delete the added modifier the loose edges disappear again. Other modifiers like Mirror does not cause loose edges to appear.

Changing viewport display settings like Wireframe and All Edges for the object does not cause loose edges to appear. It seems that the mesh data needs to be reprocessed (edit mode, mesh-altering modifier, etc.) before it will show correctly.

**System Information** Operating system: Linux-5.11.0-37-generic-x86_64-with-glibc2.33 64 Bits Graphics card: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.63.01 **Blender Version** Broken: version: 2.93.5, branch: master, commit date: 2021-10-05 12:04, hash: `blender/blender@a791bdabd0` Worked: not sure when it ever worked **Short description of error** When creating a new mesh object with loose edges, the edges do not render initially. Must add modifier that changes the mesh or tab into edit mode. **Exact steps for others to reproduce the error** Create a new mesh object using Python that contains loose edges. Easiest way to reproduce is to import the attached PLY file. This file is just a cube with the top five faces removed (deleted faces only). [cube.ply](https://archive.blender.org/developer/F11370143/cube.ply) After importing, you will see *only* the bottom face---no edges. ![cube_ply_0.png](https://archive.blender.org/developer/F11370240/cube_ply_0.png) Tabbing into edit mode shows the face and 8 loose edges as expected. ![cube_ply_1.png](https://archive.blender.org/developer/F11370247/cube_ply_1.png) Tabbing back into object mode shows the mesh correctly now. ![cube_ply_2.png](https://archive.blender.org/developer/F11370254/cube_ply_2.png) I've tested this in 2.93.5, 2.92, 2.91, 2.90, 2.83, and today's build of 3.0.0 alpha, and all have this same issue. The Triangulate and Bevel modifiers do cause the loose edges to show, but once you delete the added modifier the loose edges disappear again. Other modifiers like Mirror does *not* cause loose edges to appear. Changing viewport display settings like Wireframe and All Edges for the object does *not* cause loose edges to appear. It seems that the mesh data needs to be reprocessed (edit mode, mesh-altering modifier, etc.) before it will show correctly.
Author
Member

Added subscriber: @gfxcoder

Added subscriber: @gfxcoder

Added subscriber: @scurest

Added subscriber: @scurest

It does work but you have to explicitly request it with mesh.update(calc_edges=True, calc_edges_loose=True) (see docs). The PLY importer is doing just mesh.update().

Incidentally I thought only calc_edges_loose=True was necessary but one edge in this PLY import won't show up unless you also pass calc_edges=True...

It does work but you have to explicitly request it with `mesh.update(calc_edges=True, calc_edges_loose=True)` (see [docs](https://docs.blender.org/api/current/bpy.types.Mesh.html#bpy.types.Mesh.update)). The PLY importer is doing just `mesh.update()`. Incidentally I thought only `calc_edges_loose=True` was necessary but one edge in this PLY import won't show up unless you also pass `calc_edges=True`...
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

@scurest : exactly.

@scurest : exactly.

Investigated a little more. The missing edge only happens when doing update -> validate in that order. If you do it in the order validate -> update, calc_edges_loose is enough (dunno why though). That's also the order the OBJ importer uses FWIW.

So this fixes the PLY importer

--- a/import_ply.py     2021-10-22 09:35:35.849122529 -0500
+++ b/import_ply.py     2021-10-22 09:36:10.234279777 -0500
@@ -393,8 +393,8 @@
                 col.color[2] = mesh_colors[i][2]
                 col.color[3] = mesh_colors[i][3]
 
-    mesh.update()
     mesh.validate()
+    mesh.update(calc_edges_loose=b'edge' in obj)
 
     if texture and uvindices:
         pass
Investigated a little more. The missing edge only happens when doing update -> validate in that order. If you do it in the order validate -> update, `calc_edges_loose` is enough (dunno why though). That's also the order the OBJ importer uses FWIW. So this fixes the PLY importer ``` --- a/import_ply.py 2021-10-22 09:35:35.849122529 -0500 +++ b/import_ply.py 2021-10-22 09:36:10.234279777 -0500 @@ -393,8 +393,8 @@ col.color[2] = mesh_colors[i][2] col.color[3] = mesh_colors[i][3] - mesh.update() mesh.validate() + mesh.update(calc_edges_loose=b'edge' in obj) if texture and uvindices: pass ```
Sign in to join this conversation.
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-addons#92394
No description provided.