diff options
Diffstat (limited to 'source/blender/draw/intern/draw_subdivision.h')
-rw-r--r-- | source/blender/draw/intern/draw_subdivision.h | 69 |
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 bd02df6d48b..41d177a644a 100644 --- a/source/blender/draw/intern/draw_subdivision.h +++ b/source/blender/draw/intern/draw_subdivision.h @@ -41,6 +41,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. @@ -69,6 +119,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; @@ -113,6 +168,8 @@ typedef struct DRWSubdivCache { DRWPatchMap gpu_patch_map; + DRWSubdivLooseGeom loose_geom; + /* UBO to store settings for the various compute shaders. */ struct GPUUniformBuf *ubo; } DRWSubdivCache; @@ -228,3 +285,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 |