diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-03-02 17:22:19 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-03-02 17:22:19 +0300 |
commit | 3a0df7d37bcf55b2b0f9a070d5c80f908e46ebc4 (patch) | |
tree | 01e256d9f853dbed48217c0ce95b8cc2946a3031 /source/blender/draw/intern/draw_subdivision.h | |
parent | 47396ea81edba585cc69c5760703cde727bc08a6 (diff) | |
parent | 6883c47bb5930be5a95d1c2e8e06fce2d3b68681 (diff) |
Merge remote-tracking branch 'origin/blender-v3.1-release'
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 |