15#define NOR_AND_FLAG_DEFAULT 0
16#define NOR_AND_FLAG_SELECT 1
17#define NOR_AND_FLAG_ACTIVE -1
18#define NOR_AND_FLAG_HIDDEN -2
20template<
typename GPUType>
26 for (const int i : range) {
27 const BMFace *face = bm_original_face_get(mr, i);
28 if (!face || BM_elem_flag_test(face, BM_ELEM_HIDDEN)) {
29 normals[i] = invalid_normal;
30 normals[i].w = NOR_AND_FLAG_HIDDEN;
32 else if (BM_elem_flag_test(face, BM_ELEM_SELECT)) {
33 normals[i].w = (face == mr.efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT;
39template<
typename GPUType>
44 for (const int i : range) {
45 BMFace *face = BM_face_at_index(mr.bm, i);
46 if (BM_elem_flag_test(face, BM_ELEM_HIDDEN)) {
47 normals[i] = invalid_normal;
48 normals[i].w = NOR_AND_FLAG_HIDDEN;
51 normals[i] = gpu::convert_normal<GPUType>(bm_face_no_get(mr, face));
52 normals[i].w = (BM_elem_flag_test(face, BM_ELEM_SELECT) ?
53 ((face == mr.efa_act) ? NOR_AND_FLAG_ACTIVE : NOR_AND_FLAG_SELECT) :
54 NOR_AND_FLAG_DEFAULT);
64 "norAndFlag", gpu::VertAttrType::SNORM_16_16_16_16);
78 "norAndFlag", gpu::VertAttrType::SNORM_10_10_10_2);
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
constexpr T * data() const
static float normals[][3]
VecBase< float, 3 > float3
static void extract_face_dot_normals_mesh(const MeshRenderData &mr, MutableSpan< GPUType > normals)
gpu::VertBufPtr extract_face_dot_normals(const MeshRenderData &mr, bool use_hq)
void extract_face_dot_normals_bm(const MeshRenderData &mr, MutableSpan< GPUType > normals)
GPUType convert_normal(const float3 &src)
void convert_normals(Span< float3 > src, MutableSpan< GPUType > dst)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
blender::VecBase< int16_t, 4 > short4
VecBase< float, 3 > float3
MeshExtractType extract_type
Span< float3 > face_normals