This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/draw/DRW_pbvh.h
Hans Goudey 6514bb05ea Mesh: Store active & default color attributes with strings
Attributes are unifying around a name-based API, and we would like to
be able to move away from CustomData in the future. This patch moves
the identification of active and fallback (render) color attributes
to strings on the mesh from flags on CustomDataLayer. This also
removes some ugliness used to retrieve these attributes and maintain
the active status.

The design is described more here: T98366

The patch keeps forward compatibility working until 4.0 with
the same method as the mesh struct of array refactors (T95965).

The strings are allowed to not correspond to an attribute, to allow
setting the active/default attribute independently of actually filling
its data. When applying a modifier, if the strings don't match an
attribute, they will be removed.

The realize instances / join node and join operator take the names from
the first / active input mesh. While other heuristics may be helpful
(and could be a future improvement), just using the first is simple
and predictable.

Differential Revision: https://developer.blender.org/D15169
2022-12-15 14:21:35 -06:00

104 lines
2.5 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. */
/** \file
* \ingroup draw
*/
#pragma once
/* Needed for BKE_ccg.h. */
#include "BLI_assert.h"
#include "BLI_bitmap.h"
#include "BKE_ccg.h"
#ifdef __cplusplus
extern "C" {
#endif
struct GPUViewport;
struct PBVHAttrReq;
struct GPUBatch;
struct PBVHNode;
struct GSet;
struct DMFlagMat;
struct Object;
struct Mesh;
struct MLoopTri;
struct CustomData;
struct MVert;
struct MEdge;
struct MLoop;
struct MPoly;
struct SubdivCCG;
struct BMesh;
typedef struct PBVHBatches PBVHBatches;
typedef struct PBVH_GPU_Args {
int pbvh_type;
struct BMesh *bm;
const struct Mesh *me;
const struct MVert *mvert;
const struct MLoop *mloop;
const struct MPoly *mpoly;
int mesh_verts_num, mesh_faces_num, mesh_grids_num;
struct CustomData *vdata, *ldata, *pdata;
const float (*vert_normals)[3];
const char *active_color;
const char *render_color;
int face_sets_color_seed, face_sets_color_default;
int *face_sets; /* for PBVH_FACES and PBVH_GRIDS */
struct SubdivCCG *subdiv_ccg;
const struct DMFlagMat *grid_flag_mats;
const int *grid_indices;
CCGKey ccg_key;
CCGElem **grids;
void **gridfaces;
BLI_bitmap **grid_hidden;
int *prim_indices;
int totprim;
bool *hide_poly;
int node_verts_num;
const struct MLoopTri *mlooptri;
struct PBVHNode *node;
/* BMesh. */
struct GSet *bm_unique_vert, *bm_other_verts, *bm_faces;
int cd_mask_layer;
} PBVH_GPU_Args;
typedef struct PBVHGPUFormat PBVHGPUFormat;
void DRW_pbvh_node_update(PBVHBatches *batches, PBVH_GPU_Args *args);
void DRW_pbvh_update_pre(PBVHBatches *batches, PBVH_GPU_Args *args);
void DRW_pbvh_node_gpu_flush(PBVHBatches *batches);
struct PBVHBatches *DRW_pbvh_node_create(PBVH_GPU_Args *args);
void DRW_pbvh_node_free(PBVHBatches *batches);
struct GPUBatch *DRW_pbvh_tris_get(PBVHBatches *batches,
struct PBVHAttrReq *attrs,
int attrs_num,
PBVH_GPU_Args *args,
int *r_prim_count,
bool do_coarse_grids);
struct GPUBatch *DRW_pbvh_lines_get(struct PBVHBatches *batches,
struct PBVHAttrReq *attrs,
int attrs_num,
PBVH_GPU_Args *args,
int *r_prim_count,
bool do_coarse_grids);
#ifdef __cplusplus
}
#endif