Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-03-02 17:10:26 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-03-02 17:19:55 +0300
commit6883c47bb5930be5a95d1c2e8e06fce2d3b68681 (patch)
tree9c5fc32c03e6994a33827f2e7eaaa6d857f5554d /source/blender/draw/intern/draw_subdivision.h
parent4a95c3466fafcd3e9116cd0d7fdcc63f2dc38bd2 (diff)
Fix T94729: GPU subdivision does not support meshes without polygons
There are two issues revealed in the bug report: - the GPU subdivision does not support meshes with only loose geometry - the loose geometry is not subdivided For the first case, checks are added to ensure we still fill the buffers with loose geometry even if no polygons are present. For the second case, this adds `BKE_subdiv_mesh_interpolate_position_on_edge` which encapsulates the loose vertex interpolation mechanism previously found in `subdiv_mesh_vertex_of_loose_edge`. The subdivided loose geometry is stored in a new specific data structure `DRWSubdivLooseGeom` so as to not pollute `MeshExtractLooseGeom`. These structures store the corresponding coarse element data, which will be used for filling GPU buffers appropriately. Differential Revision: https://developer.blender.org/D14171
Diffstat (limited to 'source/blender/draw/intern/draw_subdivision.h')
-rw-r--r--source/blender/draw/intern/draw_subdivision.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_subdivision.h b/source/blender/draw/intern/draw_subdivision.h
index 5942797ef8f..a2ca1c1735c 100644
--- a/source/blender/draw/intern/draw_subdivision.h
+++ b/source/blender/draw/intern/draw_subdivision.h
@@ -56,6 +56,56 @@ typedef struct DRWPatchMap {
/** \} */
/* -------------------------------------------------------------------- */
+/** \name DRWSubdivLooseEdge
+ *
+ * This stores information about a subdivided loose edge.
+ * \{ */
+
+typedef struct DRWSubdivLooseEdge {
+ /* The corresponding coarse edge, this is always valid. */
+ int coarse_edge_index;
+ /* Pointers into #DRWSubdivLooseGeom.verts. */
+ int loose_subdiv_v1_index;
+ int loose_subdiv_v2_index;
+} DRWSubdivLooseEdge;
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name DRWSubdivLooseVertex
+ *
+ * This stores information about a subdivided loose vertex, that may or may not come from a loose
+ * edge.
+ * \{ */
+
+typedef struct DRWSubdivLooseVertex {
+ /* The corresponding coarse vertex, or -1 if this vertex is the result
+ * of subdivision. */
+ unsigned int coarse_vertex_index;
+ /* Position and normal of the vertex. */
+ float co[3];
+ float nor[3];
+} DRWSubdivLooseVertex;
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name DRWSubdivLooseGeom
+ *
+ * This stores the subdivided vertices and edges of loose geometry from #MeshExtractLooseGeom.
+ * \{ */
+
+typedef struct DRWSubdivLooseGeom {
+ DRWSubdivLooseEdge *edges;
+ DRWSubdivLooseVertex *verts;
+ int edge_len;
+ int vert_len;
+ int loop_len;
+} DRWSubdivLooseGeom;
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name DRWSubdivCache
*
* This holds the various buffers used to evaluate and render subdivision through OpenGL.
@@ -84,6 +134,11 @@ typedef struct DRWSubdivCache {
uint num_subdiv_verts;
uint num_subdiv_quads;
+ /* We only do the subdivision traversal for full faces, however we may have geometries that only
+ * have loose edges (e.g. a custom bone shape). This flag is used to detect those cases, as the
+ * counters above will all be set to zero if we do not have subdivision loops. */
+ bool may_have_loose_geom;
+
/* Number of polygons in the coarse mesh, notably used to compute a coarse polygon index given a
* subdivision loop index. */
int num_coarse_poly;
@@ -128,6 +183,8 @@ typedef struct DRWSubdivCache {
DRWPatchMap gpu_patch_map;
+ DRWSubdivLooseGeom loose_geom;
+
/* UBO to store settings for the various compute shaders. */
struct GPUUniformBuf *ubo;
} DRWSubdivCache;
@@ -243,3 +300,15 @@ void draw_subdiv_build_edituv_stretch_angle_buffer(const DRWSubdivCache *cache,
#ifdef __cplusplus
}
#endif
+
+#ifdef __cplusplus
+# include "BLI_span.hh"
+
+/* Helper to access the loose edges. */
+blender::Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache *cache);
+
+/* Helper to access only the loose vertices, i.e. not the ones attached to loose edges. To access
+ * loose vertices of loose edges #draw_subdiv_cache_get_loose_edges should be used. */
+blender::Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCache *cache);
+
+#endif