39 float fac = (200 * (cosine - 1.0f)) + 1.0f;
40 CLAMP(fac, 0.0f, 1.0f);
42 constexpr float factor = 254.0f / 255.0f;
51 float fac = (200 * (cosine - 1.0f)) + 1.0f;
52 CLAMP(fac, 0.0f, 1.0f);
68 for (
const int face : faces.index_range()) {
69 for (
const int corner : faces[face]) {
70 const int edge = corner_edges[corner];
71 if (!optimal_display_edges.
is_empty() && !optimal_display_edges[edge]) {
72 if constexpr (std::is_same_v<T, float>) {
73 vbo_data[corner] = 1.0f;
83 const int8_t face_count = edge_face_count[edge];
86 if (face_count == 0) {
91 else if (face_count == 1) {
93 const int other_face = medata->
data;
96 vbo_data[corner] = factor;
99 medata->
data = corner;
103 const int corner_a = medata->
corner_a;
104 const int corner_b = medata->
data;
105 vbo_data[corner_a] = 0;
106 vbo_data[corner_b] = 0;
109 edge_face_count[edge]++;
120 for (const int face_index : range) {
121 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
122 const BMLoop *loop = BM_FACE_FIRST_LOOP(&face);
123 for ([[maybe_unused]] const int i : IndexRange(face.len)) {
124 const int index = BM_elem_index_get(loop);
125 if (BM_edge_is_manifold(loop->e)) {
126 const BMFace *other_face = loop->radial_next->f;
127 vbo_data[index] = edge_factor_calc<T>(float3(bm_face_no_get(mr, &face)),
128 float3(bm_face_no_get(mr, other_face)));
131 vbo_data[index] = T(0);
143 if (
format.attr_len == 0) {
159 if (
format.attr_len == 0) {
180 if (
format.attr_len == 0) {
196 if (
format.attr_len == 0) {
209 const int edge = subdiv_loop_subdiv_edge_index[corner];
210 const int quad = corner / 4;
211 const int corner_count = tmp_edge_corner_count[edge]++;
213 vbo_data[corner] = -1;
214 if (corner_count == 0) {
215 edge_data[edge].corner_a = corner;
218 else if (corner_count == 1) {
219 const int corner_a = edge_data[edge].corner_a;
220 const int quad_a = edge_data[edge].data;
221 vbo_data[corner_a] =
quad;
222 vbo_data[corner] = quad_a;
223 edge_data[edge].
data = corner;
225 else if (corner_count == 2) {
226 const int corner_a = edge_data[edge].corner_a;
227 const int corner_b = edge_data[edge].data;
228 vbo_data[corner_a] = -1;
229 vbo_data[corner_b] = -1;
250 subdiv_cache, &pos_nor, subdiv_cache.
edges_draw_flag, poly_other_map, &vbo);
256 if (loose_edges_num == 0) {
265 const float values[2] = {1.0f, 1.0f};
266 for (
const int i :
IndexRange(loose_edges_num)) {
271 const uint8_t values[2] = {255, 255};
272 for (
const int i :
IndexRange(loose_edges_num)) {
int GPU_minimum_per_vertex_stride()
bool GPU_crappy_amd_driver()
void GPU_vertbuf_init_build_on_device(blender::gpu::VertBuf &verts, const GPUVertFormat &format, uint v_len)
void GPU_vertbuf_use(blender::gpu::VertBuf *)
#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 *)
ATTR_WARN_UNUSED_RESULT BMesh * bm
constexpr MutableSpan take_back(const int64_t n) const
constexpr T * data() const
constexpr void fill(const T &value) const
local_group_size(16, 16) .push_constant(Type b
blender::gpu::Batch * quad
void extract_edge_factor_subdiv(const DRWSubdivCache &subdiv_cache, const MeshRenderData &mr, gpu::VertBuf &pos_nor, gpu::VertBuf &vbo)
int subdiv_loose_edges_num(const MeshRenderData &mr, const DRWSubdivCache &cache)
void draw_subdiv_build_edge_fac_buffer(const DRWSubdivCache &cache, gpu::VertBuf *pos_nor, gpu::VertBuf *edge_draw_flag, gpu::VertBuf *poly_other_map, gpu::VertBuf *edge_fac)
T edge_factor_calc(const float3 &a, const float3 &b)
void extract_edge_factor(const MeshRenderData &mr, gpu::VertBuf &vbo)
float edge_factor_calc< float >(const float3 &a, const float3 &b)
uint8_t edge_factor_calc< uint8_t >(const float3 &a, const float3 &b)
static void extract_edge_factor_mesh(const MeshRenderData &mr, MutableSpan< T > vbo_data)
static void extract_edge_factor_bm(const MeshRenderData &mr, MutableSpan< T > vbo_data)
static const GPUVertFormat & get_subdiv_edge_fac_format()
static gpu::VertBuf * build_poly_other_map_vbo(const DRWSubdivCache &subdiv_cache)
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))
MeshRuntimeHandle * runtime
int * subdiv_loop_subdiv_edge_index
gpu::VertBuf * edges_draw_flag
eMRExtractType extract_type
Span< float3 > face_normals
OffsetIndices< int > faces