Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_subdivision.h
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | typedef struct DRWPatchMap { | ||||
| int max_patch_face; | int max_patch_face; | ||||
| int max_depth; | int max_depth; | ||||
| int patches_are_triangular; | int patches_are_triangular; | ||||
| } DRWPatchMap; | } 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 | /** \name DRWSubdivCache | ||||
| * | * | ||||
| * This holds the various buffers used to evaluate and render subdivision through OpenGL. | * This holds the various buffers used to evaluate and render subdivision through OpenGL. | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct DRWSubdivCache { | typedef struct DRWSubdivCache { | ||||
| struct Mesh *mesh; | struct Mesh *mesh; | ||||
| struct BMesh *bm; | struct BMesh *bm; | ||||
| Show All 12 Lines | typedef struct DRWSubdivCache { | ||||
| /* Number of subdivided loops, also the number of patch coordinates since we have one coordinate | /* Number of subdivided loops, also the number of patch coordinates since we have one coordinate | ||||
| * but quad corner/vertex. */ | * but quad corner/vertex. */ | ||||
| uint num_subdiv_loops; | uint num_subdiv_loops; | ||||
| uint num_subdiv_edges; | uint num_subdiv_edges; | ||||
| uint num_subdiv_triangles; | uint num_subdiv_triangles; | ||||
| uint num_subdiv_verts; | uint num_subdiv_verts; | ||||
| uint num_subdiv_quads; | 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 | /* Number of polygons in the coarse mesh, notably used to compute a coarse polygon index given a | ||||
| * subdivision loop index. */ | * subdivision loop index. */ | ||||
| int num_coarse_poly; | int num_coarse_poly; | ||||
| /* Maps subdivision loop to subdivided vertex index. */ | /* Maps subdivision loop to subdivided vertex index. */ | ||||
| int *subdiv_loop_subdiv_vert_index; | int *subdiv_loop_subdiv_vert_index; | ||||
| /* Maps subdivision loop to original coarse poly index. */ | /* Maps subdivision loop to original coarse poly index. */ | ||||
| int *subdiv_loop_poly_index; | int *subdiv_loop_poly_index; | ||||
| Show All 28 Lines | typedef struct DRWSubdivCache { | ||||
| /* Material offsets. */ | /* Material offsets. */ | ||||
| int *mat_start; | int *mat_start; | ||||
| int *mat_end; | int *mat_end; | ||||
| struct GPUVertBuf *polygon_mat_offset; | struct GPUVertBuf *polygon_mat_offset; | ||||
| DRWPatchMap gpu_patch_map; | DRWPatchMap gpu_patch_map; | ||||
| DRWSubdivLooseGeom loose_geom; | |||||
| /* UBO to store settings for the various compute shaders. */ | /* UBO to store settings for the various compute shaders. */ | ||||
| struct GPUUniformBuf *ubo; | struct GPUUniformBuf *ubo; | ||||
| } DRWSubdivCache; | } DRWSubdivCache; | ||||
| /* Only frees the data of the cache, caller is responsible to free the cache itself if necessary. | /* Only frees the data of the cache, caller is responsible to free the cache itself if necessary. | ||||
| */ | */ | ||||
| void draw_subdiv_cache_free(DRWSubdivCache *cache); | void draw_subdiv_cache_free(DRWSubdivCache *cache); | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | void draw_subdiv_build_edituv_stretch_angle_buffer(const DRWSubdivCache *cache, | ||||
| struct GPUVertBuf *pos_nor, | struct GPUVertBuf *pos_nor, | ||||
| struct GPUVertBuf *uvs, | struct GPUVertBuf *uvs, | ||||
| int uvs_offset, | int uvs_offset, | ||||
| struct GPUVertBuf *stretch_angles); | struct GPUVertBuf *stretch_angles); | ||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #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 | |||||