17template<
typename GPUType>
21 for (const int i : range) {
22 dst[i] = convert_normal<GPUType>(src[i]);
36template<
typename GPUType>
43 array_utils::gather(vert_normals_converted.
as_span(), corner_verts, normals);
46template<
typename GPUType>
51 threading::parallel_for(faces.index_range(), 4096, [&](
const IndexRange range) {
52 for (const int face : range) {
53 normals.slice(faces[face]).fill(convert_normal<GPUType>(face_normals[face]));
58template<
typename GPUType>
79 threading::parallel_for(faces.index_range(), 2048, [&](
const IndexRange range) {
80 for (const int face : range) {
81 if (sharp_faces[face]) {
82 normals.slice(faces[face]).fill(convert_normal<GPUType>(face_normals[face]));
85 for (const int corner : faces[face]) {
86 normals[corner] = convert_normal<GPUType>(vert_normals[corner_verts[corner]]);
94template<
typename GPUType>
109 threading::parallel_for(faces.index_range(), 1024, [&](
const IndexRange range) {
110 if (!selection.is_empty()) {
111 if (use_face_select) {
112 for (const int face : range) {
113 if (selection[face]) {
114 for (const int corner : faces[face]) {
115 normals[corner].w = 1;
121 const Span<int> corner_verts = mr.corner_verts;
122 for (const int face : range) {
123 for (const int corner : faces[face]) {
124 if (selection[corner_verts[corner]]) {
125 normals[corner].w = 1;
132 const Span<bool> hide_poly = mr.hide_poly;
133 for (const int face : range) {
134 if (hide_poly[face]) {
135 for (const int corner : faces[face]) {
136 normals[corner].w = -1;
141 if (mr.edit_bmesh && mr.orig_index_vert) {
142 const Span<int> corner_verts = mr.corner_verts;
143 const Span<int> orig_indices(mr.orig_index_vert, mr.verts_num);
144 for (const int face : range) {
145 for (const int corner : faces[face]) {
146 if (orig_indices[corner_verts[corner]] == ORIGINDEX_NONE) {
147 normals[corner].w = -1;
155template<
typename GPUType>
162 for (const int face_index : range) {
163 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
164 if (BM_elem_flag_test(&face, BM_ELEM_HIDDEN)) {
165 const IndexRange face_range(BM_elem_index_get(BM_FACE_FIRST_LOOP(&face)), face.len);
166 for (GPUType &value : normals.slice(face_range)) {
176 for (const int face_index : range) {
177 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
178 const BMLoop *loop = BM_FACE_FIRST_LOOP(&face);
179 const IndexRange face_range(BM_elem_index_get(loop), face.len);
181 if (domain == bke::MeshNormalDomain::Face || !BM_elem_flag_test(&face, BM_ELEM_SMOOTH)) {
182 normals.slice(face_range).fill(convert_normal<GPUType>(bm_face_no_get(mr, &face)));
185 for ([[maybe_unused]] const int i : IndexRange(face.len)) {
186 const int index = BM_elem_index_get(loop);
187 normals[index] = convert_normal<GPUType>(bm_vert_no_get(mr, loop->v));
192 if (BM_elem_flag_test(&face, BM_ELEM_HIDDEN)) {
193 for (GPUType &value : normals.slice(face_range)) {
207 if (
format.attr_len == 0) {
229 if (
format.attr_len == 0) {
254 if (
format.attr_len == 0) {
278 const float4 default_normal(0.0f, 0.0f, 0.0f, 0.0f);
279 for (
const int i : IndexRange::from_begin_end(loose_geom_start, vbo_size)) {
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)
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)
ATTR_WARN_UNUSED_RESULT BMesh * bm
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
constexpr MutableSpan take_back(const int64_t n) const
constexpr void fill(const T &value) const
constexpr MutableSpan take_front(const int64_t n) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
static const GPUVertFormat & get_subdiv_lnor_format()
void convert_normals(Span< float3 > src, MutableSpan< GPUType > dst)
void extract_normals(const MeshRenderData &mr, bool use_hq, gpu::VertBuf &vbo)
void extract_normals_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, gpu::VertBuf &pos_nor, gpu::VertBuf &lnor)
void draw_subdiv_build_lnor_buffer(const DRWSubdivCache &cache, gpu::VertBuf *pos_nor, gpu::VertBuf *lnor)
int subdiv_full_vbo_size(const MeshRenderData &mr, const DRWSubdivCache &cache)
static void extract_paint_overlay_flags(const MeshRenderData &mr, MutableSpan< GPUType > normals)
static void extract_normals_mesh(const MeshRenderData &mr, MutableSpan< GPUType > normals)
static void extract_normals_bm(const MeshRenderData &mr, MutableSpan< GPUType > normals)
static void extract_face_normals(const MeshRenderData &mr, MutableSpan< GPUType > normals)
void extract_vert_normals(const MeshRenderData &mr, gpu::VertBuf &vbo)
static void convert_normals_impl(const Span< float3 > src, MutableSpan< GPUType > dst)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type pos vertex_in(1, Type::UINT, "data") .vertex_out(overlay_edit_curve_handle_iface) .geometry_layout(PrimitiveIn Frequency::GEOMETRY storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) .push_constant(Type Frequency::GEOMETRY selection[]
const int * orig_index_vert
VArraySpan< bool > select_vert
VArraySpan< bool > sharp_faces
VArraySpan< bool > select_poly
eMRExtractType extract_type
Span< float3 > face_normals
Span< float3 > corner_normals
VArraySpan< bool > hide_poly
OffsetIndices< int > faces
bke::MeshNormalDomain normals_domain
Array< float3 > bm_loop_normals