37 float fac = (200 * (cosine - 1.0f)) + 1.0f;
38 CLAMP(fac, 0.0f, 1.0f);
40 constexpr float factor = 254.0f / 255.0f;
54 for (
const int face :
faces.index_range()) {
55 for (
const int corner :
faces[face]) {
56 const int edge = corner_edges[corner];
57 if (!optimal_display_edges.
is_empty() && !optimal_display_edges[edge]) {
58 vbo_data[corner] = 1.0f;
64 const int8_t face_count = edge_face_count[edge];
67 if (face_count == 0) {
72 else if (face_count == 1) {
74 const int other_face = medata->
data;
75 const float factor =
edge_factor_calc(face_normals[other_face], face_normals[face]);
77 vbo_data[corner] = factor;
80 medata->
data = corner;
84 const int corner_a = medata->
corner_a;
85 const int corner_b = medata->
data;
86 vbo_data[corner_a] = 0;
87 vbo_data[corner_b] = 0;
90 edge_face_count[edge]++;
100 for (const int face_index : range) {
101 const BMFace &face = *BM_face_at_index(&bm, face_index);
102 const BMLoop *loop = BM_FACE_FIRST_LOOP(&face);
103 for ([[maybe_unused]] const int i : IndexRange(face.len)) {
104 const int index = BM_elem_index_get(loop);
105 if (BM_edge_is_manifold(loop->e)) {
106 const BMFace *other_face = loop->radial_next->f;
107 vbo_data[index] = edge_factor_calc(float3(bm_face_no_get(mr, &face)),
108 float3(bm_face_no_get(mr, other_face)));
111 vbo_data[index] = 0.0f;
122 gpu::VertAttrType::SFLOAT_32);
141 gpu::VertAttrType::SINT_32);
152 const int edge = subdiv_loop_subdiv_edge_index[corner];
153 const int quad = corner / 4;
154 const int corner_count = tmp_edge_corner_count[edge]++;
156 vbo_data[corner] = -1;
157 if (corner_count == 0) {
158 edge_data[edge].corner_a = corner;
159 edge_data[edge].data =
quad;
161 else if (corner_count == 1) {
162 const int corner_a = edge_data[edge].corner_a;
163 const int quad_a = edge_data[edge].data;
164 vbo_data[corner_a] =
quad;
165 vbo_data[corner] = quad_a;
166 edge_data[edge].
data = corner;
168 else if (corner_count == 2) {
169 const int corner_a = edge_data[edge].corner_a;
170 const int corner_b = edge_data[edge].data;
171 vbo_data[corner_a] = -1;
172 vbo_data[corner_b] = -1;
191 subdiv_cache, &pos_nor, subdiv_cache.
edges_draw_flag, poly_other_map, vbo.get());
197 if (loose_edges_num == 0) {
205 const float values[2] = {1.0f, 1.0f};
blender::gpu::VertBuf * GPU_vertbuf_create_on_device(const GPUVertFormat &format, uint v_len)
void GPU_vertbuf_use(blender::gpu::VertBuf *)
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
#define GPU_vertbuf_init_with_format(verts, format)
blender::gpu::VertBuf * GPU_vertbuf_calloc()
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_update_sub(blender::gpu::VertBuf *verts, uint start, uint len, const void *data)
void GPU_vertbuf_discard(blender::gpu::VertBuf *)
constexpr MutableSpan take_back(const int64_t n) const
constexpr T * data() const
constexpr void fill(const T &value) const
blender::gpu::Batch * quad
float edge_factor_calc(const float3 &a, const float3 &b)
void draw_subdiv_build_edge_fac_buffer(const DRWSubdivCache &cache, gpu::VertBuf *pos, gpu::VertBuf *edge_draw_flag, gpu::VertBuf *poly_other_map, gpu::VertBuf *edge_fac)
int subdiv_loose_edges_num(const MeshRenderData &mr, const DRWSubdivCache &cache)
static void extract_edge_factor_mesh(const MeshRenderData &mr, MutableSpan< float > vbo_data)
gpu::VertBufPtr extract_edge_factor_subdiv(const DRWSubdivCache &subdiv_cache, const MeshRenderData &mr, gpu::VertBuf &pos)
static void extract_edge_factor_bm(const MeshRenderData &mr, MutableSpan< float > vbo_data)
gpu::VertBufPtr extract_edge_factor(const MeshRenderData &mr)
static gpu::VertBuf * build_poly_other_map_vbo(const DRWSubdivCache &subdiv_cache)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< float, 3 > float3
MeshRuntimeHandle * runtime
int * subdiv_loop_subdiv_edge_index
gpu::VertBuf * edges_draw_flag
MeshExtractType extract_type
Span< float3 > face_normals
OffsetIndices< int > faces