Skin Modifier not applied to Array Modifier Start & End Caps #74598

Closed
opened 2020-03-10 02:19:29 +01:00 by L Furneaux · 4 comments

Skin Modifier not applied to Array Modifier Start & End Caps

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.97

Blender Version
Broken: version: 2.82 (sub 7), branch: master, commit date: 2020-02-12 16:20, hash: 77d23b0bd7
Also tried in 2.83 alpha blender-2.83-fbe81db29a28-windows64, 2.81b and 2.79.
Worked: Not in any Blender version I have access to.

Short description of error
When adding a skin modifier to an array with start and end caps, the skin modifier does not extend around the caps.

Exact steps for others to reproduce the error
Default Blend file - add three planes.
Add array modifier to Plane.
Set array modifier start cap as Plane.001 and end cap as Plane.002 and enable Merge.
Add skin modifier.
Skin Modifier will only be applied to the arrayed object, not the start/end caps, with spears at the joins.

To see expected outcome: Apply array modifier. Remove and re-add Skin modifier.

Example blend file attached with fence model.
Maybe related to #59770 but Blender does not crash, it just doesn't add the skin properly.

Skin-Array Modifier Bug.png

Skin - Array End Caps Bug.blend

Skin Modifier not applied to Array Modifier Start & End Caps **System Information** Operating system: Windows-7-6.1.7601-SP1 64 Bits Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.97 **Blender Version** Broken: version: 2.82 (sub 7), branch: master, commit date: 2020-02-12 16:20, hash: `77d23b0bd7` Also tried in 2.83 alpha blender-2.83-fbe81db29a28-windows64, 2.81b and 2.79. Worked: Not in any Blender version I have access to. **Short description of error** When adding a skin modifier to an array with start and end caps, the skin modifier does not extend around the caps. **Exact steps for others to reproduce the error** Default Blend file - add three planes. Add array modifier to Plane. Set array modifier start cap as Plane.001 and end cap as Plane.002 and enable Merge. Add skin modifier. Skin Modifier will only be applied to the arrayed object, not the start/end caps, with spears at the joins. To see expected outcome: Apply array modifier. Remove and re-add Skin modifier. Example blend file attached with fence model. Maybe related to #59770 but Blender does not crash, it just doesn't add the skin properly. ![Skin-Array Modifier Bug.png](https://archive.blender.org/developer/F8398357/Skin-Array_Modifier_Bug.png) [Skin - Array End Caps Bug.blend](https://archive.blender.org/developer/F8398360/Skin_-_Array_End_Caps_Bug.blend)
Author

Added subscriber: @sherbert_lemon

Added subscriber: @sherbert_lemon

Added subscriber: @mano-wii

Added subscriber: @mano-wii

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

Changed status from 'Needs Triage' to: 'Archived'
Germano Cavalcante self-assigned this 2020-03-10 20:37:20 +01:00

The problem here is that the skin radius of the caps' vertices are not initialized.
This patch would allow them to be initialized:
P1292: Patch for #74598

diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index ae2f5231e25..34fb4fcacab 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -26,6 +26,7 @@
 /* defines BLI_INLINE */
 #include "BLI_compiler_compat.h"
 
+enum eCDAllocType;
 struct BLI_Stack;
 struct BMEditMesh;
 struct BMesh;
@@ -124,7 +125,8 @@ struct Mesh *BKE_mesh_new_nomain_from_template_ex(const struct Mesh *me_src,
                                                   int tessface_len,
                                                   int loops_len,
                                                   int polys_len,
-                                                  struct CustomData_MeshMasks mask);
+                                                  struct CustomData_MeshMasks mask,
+                                                  enum eCDAllocType alloctype);
 
 void BKE_mesh_eval_delete(struct Mesh *me_eval);
 
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 127acf0e464..aadd6d85293 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -727,7 +727,8 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
                                            int tessface_len,
                                            int loops_len,
                                            int polys_len,
-                                           CustomData_MeshMasks mask)
+                                           CustomData_MeshMasks mask,
+                                           enum eCDAllocType alloctype)
 {
   /* Only do tessface if we are creating tessfaces or copying from mesh with only tessfaces. */
   const bool do_tessface = (tessface_len || ((me_src->totface != 0) && (me_src->totpoly == 0)));
@@ -745,12 +746,12 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
   me_dst->cd_flag = me_src->cd_flag;
   BKE_mesh_copy_settings(me_dst, me_src);
 
-  CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, CD_CALLOC, verts_len);
-  CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, CD_CALLOC, edges_len);
-  CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, CD_CALLOC, loops_len);
-  CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, CD_CALLOC, polys_len);
+  CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, alloctype, verts_len);
+  CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, alloctype, edges_len);
+  CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, alloctype, loops_len);
+  CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, alloctype, polys_len);
   if (do_tessface) {
-    CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, CD_CALLOC, tessface_len);
+    CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, alloctype, tessface_len);
   }
   else {
     mesh_tessface_clear_intern(me_dst, false);
@@ -771,8 +772,14 @@ Mesh *BKE_mesh_new_nomain_from_template(const Mesh *me_src,
                                         int loops_len,
                                         int polys_len)
 {
-  return BKE_mesh_new_nomain_from_template_ex(
-      me_src, verts_len, edges_len, tessface_len, loops_len, polys_len, CD_MASK_EVERYTHING);
+  return BKE_mesh_new_nomain_from_template_ex(me_src,
+                                              verts_len,
+                                              edges_len,
+                                              tessface_len,
+                                              loops_len,
+                                              polys_len,
+                                              CD_MASK_EVERYTHING,
+                                              CD_CALLOC);
 }
 
 void BKE_mesh_eval_delete(struct Mesh *mesh_eval)
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index 6c9cd72363a..15173eb735e 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -506,8 +506,14 @@ static bool subdiv_mesh_topology_info(const SubdivForeachContext *foreach_contex
   mask.lmask &= ~CD_MASK_MULTIRES_GRIDS;
 
   SubdivMeshContext *subdiv_context = foreach_context->user_data;
-  subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(
-      subdiv_context->coarse_mesh, num_vertices, num_edges, 0, num_loops, num_polygons, mask);
+  subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(subdiv_context->coarse_mesh,
+                                                                     num_vertices,
+                                                                     num_edges,
+                                                                     0,
+                                                                     num_loops,
+                                                                     num_polygons,
+                                                                     mask,
+                                                                     CD_CALLOC);
   subdiv_mesh_ctx_cache_custom_data_layers(subdiv_context);
   subdiv_mesh_prepare_accumulator(subdiv_context, num_vertices);
   return true;
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index f8f8ea49676..729957949c6 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -499,9 +499,19 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
   result_nloops = chunk_nloops * count + start_cap_nloops + end_cap_nloops;
   result_npolys = chunk_npolys * count + start_cap_npolys + end_cap_npolys;
 
+  /* If there are caps, we need to initialize the customdata values since they may not be copied.
+   * TODO: Initialize only customdatas that are not in the caps. */
+  eCDAllocType alloctype = (start_cap_mesh || end_cap_mesh) ? CD_DEFAULT : CD_CALLOC;
+
   /* Initialize a result dm */
-  result = BKE_mesh_new_nomain_from_template(
-      mesh, result_nverts, result_nedges, 0, result_nloops, result_npolys);
+  result = BKE_mesh_new_nomain_from_template_ex(mesh,
+                                                result_nverts,
+                                                result_nedges,
+                                                0,
+                                                result_nloops,
+                                                result_npolys,
+                                                CD_MASK_EVERYTHING,
+                                                alloctype);
   result_dm_verts = result->mvert;
 
   if (use_merge) {

But then we would have another problem. You cannot edit the skin radius of the vertices in the caps.
image.png

So that would not bring any advantage.
So it seems that there is no simple solution to this. And the code works as designed.

The problem here is that the skin radius of the caps' vertices are not initialized. This patch would allow them to be initialized: [P1292: Patch for #74598](https://archive.blender.org/developer/P1292.txt) ```diff diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index ae2f5231e25..34fb4fcacab 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -26,6 +26,7 @@ /* defines BLI_INLINE */ #include "BLI_compiler_compat.h" +enum eCDAllocType; struct BLI_Stack; struct BMEditMesh; struct BMesh; @@ -124,7 +125,8 @@ struct Mesh *BKE_mesh_new_nomain_from_template_ex(const struct Mesh *me_src, int tessface_len, int loops_len, int polys_len, - struct CustomData_MeshMasks mask); + struct CustomData_MeshMasks mask, + enum eCDAllocType alloctype); void BKE_mesh_eval_delete(struct Mesh *me_eval); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 127acf0e464..aadd6d85293 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -727,7 +727,8 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src, int tessface_len, int loops_len, int polys_len, - CustomData_MeshMasks mask) + CustomData_MeshMasks mask, + enum eCDAllocType alloctype) { /* Only do tessface if we are creating tessfaces or copying from mesh with only tessfaces. */ const bool do_tessface = (tessface_len || ((me_src->totface != 0) && (me_src->totpoly == 0))); @@ -745,12 +746,12 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src, me_dst->cd_flag = me_src->cd_flag; BKE_mesh_copy_settings(me_dst, me_src); - CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, CD_CALLOC, verts_len); - CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, CD_CALLOC, edges_len); - CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, CD_CALLOC, loops_len); - CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, CD_CALLOC, polys_len); + CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, alloctype, verts_len); + CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, alloctype, edges_len); + CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, alloctype, loops_len); + CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, alloctype, polys_len); if (do_tessface) { - CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, CD_CALLOC, tessface_len); + CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, alloctype, tessface_len); } else { mesh_tessface_clear_intern(me_dst, false); @@ -771,8 +772,14 @@ Mesh *BKE_mesh_new_nomain_from_template(const Mesh *me_src, int loops_len, int polys_len) { - return BKE_mesh_new_nomain_from_template_ex( - me_src, verts_len, edges_len, tessface_len, loops_len, polys_len, CD_MASK_EVERYTHING); + return BKE_mesh_new_nomain_from_template_ex(me_src, + verts_len, + edges_len, + tessface_len, + loops_len, + polys_len, + CD_MASK_EVERYTHING, + CD_CALLOC); } void BKE_mesh_eval_delete(struct Mesh *mesh_eval) diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index 6c9cd72363a..15173eb735e 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -506,8 +506,14 @@ static bool subdiv_mesh_topology_info(const SubdivForeachContext *foreach_contex mask.lmask &= ~CD_MASK_MULTIRES_GRIDS; SubdivMeshContext *subdiv_context = foreach_context->user_data; - subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex( - subdiv_context->coarse_mesh, num_vertices, num_edges, 0, num_loops, num_polygons, mask); + subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(subdiv_context->coarse_mesh, + num_vertices, + num_edges, + 0, + num_loops, + num_polygons, + mask, + CD_CALLOC); subdiv_mesh_ctx_cache_custom_data_layers(subdiv_context); subdiv_mesh_prepare_accumulator(subdiv_context, num_vertices); return true; diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index f8f8ea49676..729957949c6 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -499,9 +499,19 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, result_nloops = chunk_nloops * count + start_cap_nloops + end_cap_nloops; result_npolys = chunk_npolys * count + start_cap_npolys + end_cap_npolys; + /* If there are caps, we need to initialize the customdata values since they may not be copied. + * TODO: Initialize only customdatas that are not in the caps. */ + eCDAllocType alloctype = (start_cap_mesh || end_cap_mesh) ? CD_DEFAULT : CD_CALLOC; + /* Initialize a result dm */ - result = BKE_mesh_new_nomain_from_template( - mesh, result_nverts, result_nedges, 0, result_nloops, result_npolys); + result = BKE_mesh_new_nomain_from_template_ex(mesh, + result_nverts, + result_nedges, + 0, + result_nloops, + result_npolys, + CD_MASK_EVERYTHING, + alloctype); result_dm_verts = result->mvert; if (use_merge) { ``` But then we would have another problem. You cannot edit the skin radius of the vertices in the caps. ![image.png](https://archive.blender.org/developer/F8399715/image.png) So that would not bring any advantage. So it seems that there is no simple solution to this. And the code works as designed.
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
2 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#74598
No description provided.