Cleanup: Remove inline functions and extra includes from draw extraction

This commit is contained in:
Hans Goudey 2023-12-12 20:08:30 -05:00
parent 79ade784b8
commit 768cd9b763
16 changed files with 126 additions and 117 deletions

@ -17,11 +17,8 @@
#include "BKE_attribute.h"
#include "BLI_sys_types.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "GPU_shader.h"
#include "GPU_vertex_format.h"
struct DRW_AttributeRequest {
eCustomDataType cd_type;
@ -50,7 +47,7 @@ struct DRW_MeshCDMask {
/* Keep `DRW_MeshCDMask` struct within a `uint32_t`.
* bit-wise and atomic operations are used to compare and update the struct.
* See `mesh_cd_layers_type_*` functions. */
BLI_STATIC_ASSERT(sizeof(DRW_MeshCDMask) <= sizeof(uint32_t), "DRW_MeshCDMask exceeds 32 bits")
static_assert(sizeof(DRW_MeshCDMask) <= sizeof(uint32_t), "DRW_MeshCDMask exceeds 32 bits");
void drw_attributes_clear(DRW_Attributes *attributes);

@ -8,24 +8,15 @@
#pragma once
#include <algorithm>
#include "BLI_utildefines.h"
#include "DNA_customdata_types.h"
#include "DNA_mesh_types.h"
#include "DNA_view3d_enums.h"
#include "BKE_attribute.h"
#include "BKE_object.hh"
#include "GPU_batch.h"
#include "GPU_index_buffer.h"
#include "GPU_vertex_buffer.h"
#include "GPU_shader.h"
#include "draw_attributes.hh"
struct DRWSubdivCache;
struct GPUBatch;
struct GPUIndexBuf;
struct MeshRenderData;
struct TaskGraph;
@ -73,16 +64,7 @@ enum eMRDataType {
};
ENUM_OPERATORS(eMRDataType, MR_DATA_POLYS_SORTED)
BLI_INLINE int mesh_render_mat_len_get(const Object *object, const Mesh *mesh)
{
if (mesh->edit_mesh != NULL) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object);
if (editmesh_eval_final != NULL) {
return std::max<int>(1, editmesh_eval_final->totcol);
}
}
return std::max<int>(1, mesh->totcol);
}
int mesh_render_mat_len_get(const Object *object, const Mesh *mesh);
struct MeshBufferList {
/* Every VBO below contains at least enough data for every loop in the mesh
@ -256,7 +238,7 @@ struct MeshBufferCache {
mbc == &batch_cache.final || mbc == &batch_cache.cage || mbc == &batch_cache.uv_cage; \
mbc = (mbc == &batch_cache.final) ? \
&batch_cache.cage : \
((mbc == &batch_cache.cage) ? &batch_cache.uv_cage : NULL))
((mbc == &batch_cache.cage) ? &batch_cache.uv_cage : nullptr))
struct MeshBatchCache {
MeshBufferCache final, cage, uv_cage;

@ -22,6 +22,7 @@
#include "BLI_vector.hh"
#include "BKE_editmesh.hh"
#include "BKE_object.hh"
#include "GPU_capabilities.h"
@ -37,6 +38,17 @@
# include "PIL_time_utildefines.h"
#endif
int mesh_render_mat_len_get(const Object *object, const Mesh *mesh)
{
if (mesh->edit_mesh != nullptr) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object);
if (editmesh_eval_final != nullptr) {
return std::max<int>(1, editmesh_eval_final->totcol);
}
}
return std::max<int>(1, mesh->totcol);
}
namespace blender::draw {
/* ---------------------------------------------------------------------- */

@ -23,6 +23,7 @@
#include "BKE_editmesh_cache.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_object.hh"
#include "GPU_batch.h"
@ -337,6 +338,82 @@ void mesh_render_data_update_faces_sorted(MeshRenderData &mr,
/** \name Mesh/BMesh Interface (indirect, partially cached access to complex data).
* \{ */
const Mesh *editmesh_final_or_this(const Object *object, const Mesh *mesh)
{
if (mesh->edit_mesh != nullptr) {
Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object);
if (editmesh_eval_final != nullptr) {
return editmesh_eval_final;
}
}
return mesh;
}
const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->loop_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->ldata;
break;
}
BLI_assert(0);
return &mesh->loop_data;
}
const CustomData *mesh_cd_pdata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->face_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->pdata;
break;
}
BLI_assert(0);
return &mesh->face_data;
}
const CustomData *mesh_cd_edata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->edge_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->edata;
break;
}
BLI_assert(0);
return &mesh->edge_data;
}
const CustomData *mesh_cd_vdata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->vert_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->vdata;
break;
}
BLI_assert(0);
return &mesh->vert_data;
}
void mesh_render_data_update_looptris(MeshRenderData &mr,
const eMRIterType iter_type,
const eMRDataType data_flag)

@ -40,6 +40,7 @@
#include "BKE_mesh_runtime.hh"
#include "BKE_mesh_tangent.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_object_deform.h"
#include "BKE_paint.hh"
#include "BKE_pbvh_api.hh"

@ -13,19 +13,23 @@
#include "BLI_math_vector_types.hh"
#include "BLI_virtual_array.hh"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_customdata.hh"
#include "BKE_editmesh.hh"
#include "BKE_editmesh_cache.hh"
#include "BKE_mesh.hh"
#include "bmesh.hh"
#include "GPU_vertex_buffer.h"
#include "GPU_vertex_format.h"
#include "draw_cache_extract.hh"
struct DRWSubdivCache;
struct BMVert;
struct BMEdge;
struct BMFace;
struct BMLoop;
#define MIN_RANGE_LEN 1024
@ -113,81 +117,11 @@ struct MeshRenderData {
const char *default_color_name;
};
BLI_INLINE const Mesh *editmesh_final_or_this(const Object *object, const Mesh *mesh)
{
if (mesh->edit_mesh != nullptr) {
Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object);
if (editmesh_eval_final != nullptr) {
return editmesh_eval_final;
}
}
return mesh;
}
BLI_INLINE const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->loop_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->ldata;
break;
}
BLI_assert(0);
return &mesh->loop_data;
}
BLI_INLINE const CustomData *mesh_cd_pdata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->face_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->pdata;
break;
}
BLI_assert(0);
return &mesh->face_data;
}
BLI_INLINE const CustomData *mesh_cd_edata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->edge_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->edata;
break;
}
BLI_assert(0);
return &mesh->edge_data;
}
BLI_INLINE const CustomData *mesh_cd_vdata_get_from_mesh(const Mesh *mesh)
{
switch (mesh->runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->vert_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->edit_mesh->bm->vdata;
break;
}
BLI_assert(0);
return &mesh->vert_data;
}
const Mesh *editmesh_final_or_this(const Object *object, const Mesh *mesh);
const CustomData *mesh_cd_vdata_get_from_mesh(const Mesh *mesh);
const CustomData *mesh_cd_edata_get_from_mesh(const Mesh *mesh);
const CustomData *mesh_cd_pdata_get_from_mesh(const Mesh *mesh);
const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh);
BLI_INLINE BMFace *bm_original_face_get(const MeshRenderData &mr, int idx)
{

@ -6,10 +6,10 @@
* \ingroup draw
*/
#include "BLI_bitmap.h"
#include "extract_mesh.hh"
#include "GPU_index_buffer.h"
#include "draw_subdivision.hh"
namespace blender::draw {

@ -6,7 +6,7 @@
* \ingroup draw
*/
#include "BLI_bitmap.h"
#include "GPU_index_buffer.h"
#include "extract_mesh.hh"

@ -6,7 +6,7 @@
* \ingroup draw
*/
#include "MEM_guardedalloc.h"
#include "GPU_index_buffer.h"
#include "extract_mesh.hh"

@ -12,6 +12,8 @@
#include "MEM_guardedalloc.h"
#include "GPU_index_buffer.h"
#include "draw_subdivision.hh"
#include "extract_mesh.hh"

@ -7,11 +7,12 @@
*/
#include "BLI_bitmap.h"
#include "BLI_vector.hh"
#include "atomic_ops.h"
#include "MEM_guardedalloc.h"
#include "GPU_index_buffer.h"
#include "draw_subdivision.hh"
#include "extract_mesh.hh"

@ -6,9 +6,7 @@
* \ingroup draw
*/
#include "BLI_vector.hh"
#include "MEM_guardedalloc.h"
#include "GPU_index_buffer.h"
#include "draw_subdivision.hh"
#include "extract_mesh.hh"

@ -6,7 +6,9 @@
* \ingroup draw
*/
#include "MEM_guardedalloc.h"
#include "BKE_editmesh.hh"
#include "GPU_index_buffer.h"
#include "extract_mesh.hh"

@ -21,6 +21,8 @@
#include "draw_subdivision.hh"
#include "extract_mesh.hh"
#include "GPU_vertex_buffer.h"
namespace blender::draw {
/* ---------------------------------------------------------------------- */

@ -6,7 +6,7 @@
* \ingroup draw
*/
#include "BLI_bitmap.h"
#include "GPU_index_buffer.h"
#include "extract_mesh.hh"

@ -14,6 +14,7 @@
#include "BLI_ordered_edge.hh"
#include "BKE_bvhutils.hh"
#include "BKE_editmesh.hh"
#include "BKE_editmesh_bvh.h"
#include "BKE_editmesh_cache.hh"