33 for (
int i = 0; i < 2; i++) {
36 if (cpu_draw_buf_.current() ==
nullptr) {
37 cpu_draw_buf_.current() = MEM_new<DebugDrawBuf>(
"DebugDrawBuf-CPU",
"DebugDrawBuf-CPU");
38 gpu_draw_buf_.current() = MEM_new<DebugDrawBuf>(
"DebugDrawBuf-GPU",
"DebugDrawBuf-GPU");
41 cpu_draw_buf_.current()->command.array.vertex_len = 0;
42 cpu_draw_buf_.current()->command.array.vertex_first = 0;
43 cpu_draw_buf_.current()->command.array.instance_len = 1;
44 cpu_draw_buf_.current()->command.array.instance_first = 0;
46 gpu_draw_buf_.current()->command.array.vertex_len = 0;
47 gpu_draw_buf_.current()->command.array.vertex_first = 0;
48 gpu_draw_buf_.current()->command.array.instance_len = 1;
49 gpu_draw_buf_.current()->command.array.instance_first = 0;
50 gpu_draw_buf_.current()->push_update();
56 gpu_draw_buf_used =
false;
62 gpu_draw_buf_used =
true;
63 return *gpu_draw_buf_.current();
69void DebugDraw::clear_gpu_data()
71 for (
int i = 0; i < 2; i++) {
72 MEM_SAFE_DELETE(cpu_draw_buf_.current());
73 MEM_SAFE_DELETE(gpu_draw_buf_.current());
103 for (
auto vert : face_verts) {
134 for (
auto edge :
IndexRange(circle_resolution)) {
136 const float angle = (2 *
M_PI) * (edge + vert) /
float(circle_resolution);
138 result.append(
float3(point[(0 + axis) % 3], point[(1 + axis) % 3], point[(2 + axis) % 3]));
153 float3 v0 = sphere_verts[i * 2] * radius + center;
154 float3 v1 = sphere_verts[i * 2 + 1] * radius + center;
166 float3 v0 = point_verts[i * 2] * rad + pos;
167 float3 v1 = point_verts[i * 2 + 1] * rad + pos;
207 DebugDrawBuf &buf = *cpu_draw_buf_.current();
218 buf.
command.array.vertex_len += 2;
228void DebugDraw::display_lines(
View &view)
233 const bool cpu_draw_buf_used = vertex_len_.load() != 0;
235 if (!cpu_draw_buf_used && !gpu_draw_buf_used) {
241 float viewport_size[4];
250 if (gpu_draw_buf_used) {
253 gpu_draw_buf_.next()->command.array.vertex_len = 0;
254 gpu_draw_buf_.next()->push_update();
268 cpu_draw_buf_.current()->command.array.vertex_len = vertex_len_.load();
269 cpu_draw_buf_.current()->push_update();
271 cpu_draw_buf_.next()->command.array.vertex_len = 0;
272 cpu_draw_buf_.next()->push_update();
281 cpu_draw_buf_.next()->read();
287 gpu_draw_buf_.swap();
288 cpu_draw_buf_.swap();
General operations, lookup, etc. for blender objects.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
constexpr IndexRange()=default
constexpr const T & last(const int64_t n=0) const
constexpr bool is_empty() const
gpu::StorageBuf * gpu_draw_buf_get()
void display_to_view(View &view)
void draw_line(float3 v1, float3 v2, uint color, uint lifetime=1)
const float4x4 persmat(int view_id=0) const
Simple API to draw debug shapes and log in the viewport.
#define DRW_DEBUG_DRAW_VERT_MAX
#define DRW_DEBUG_DRAW_SLOT
#define DRW_DEBUG_DRAW_FEEDBACK_SLOT
std::array< VecBase< T, 3 >, 8 > corners(const Bounds< VecBase< T, 3 > > &bounds)
void drw_debug_bbox(const BoundBox &bbox, const float4 color, const uint lifetime)
void drw_debug_matrix_as_bbox(const float4x4 &mat, const float4 color, const uint lifetime)
void drw_debug_sphere(const float3 center, float radius, const float4 color, const uint lifetime)
void drw_debug_matrix(const float4x4 &m4, const uint lifetime)
void drw_debug_line(const float3 v1, const float3 v2, const float4 color, const uint lifetime)
static Vector< float3 > precompute_sphere_points(int circle_resolution)
void drw_debug_polygon(Span< float3 > face_verts, const float4 color, const uint lifetime)
void drw_debug_point(const float3 pos, float rad, const float4 col, const uint lifetime)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void GPU_batch_draw_indirect(gpu::Batch *batch, gpu::StorageBuf *indirect_buf, intptr_t offset)
void GPU_shader_uniform_2f(gpu::Shader *sh, const char *name, float x, float y)
void GPU_shader_uniform_mat4(gpu::Shader *sh, const char *name, const float data[4][4])
gpu::Shader * DRW_shader_debug_draw_display_get()
void mul_project_m4_v3(const float mat[4][4], float vec[3])
bool GPU_vertex_pipeline_stores_and_atomics_support()
void GPU_batch_set_shader(gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
MINLINE unsigned int float_as_uint(float f)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
void GPU_viewport_size_get_f(float coords[4])
void GPU_storagebuf_bind(gpu::StorageBuf *ssbo, int slot)
void GPU_storagebuf_unbind(gpu::StorageBuf *ssbo)
void GPU_debug_group_end()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
uint debug_color_pack(float4 v_color)
VecBase< float, 3 > float3
MINLINE int min_ii(int a, int b)
DRWDebugVertPair debug_line_make(uint in_pos1_x, uint in_pos1_y, uint in_pos1_z, uint in_pos2_x, uint in_pos2_y, uint in_pos2_z, uint in_vert_color, uint in_lifetime)
gpu::Batch * GPU_batch_procedural_lines_get()
void GPU_debug_group_begin(const char *name)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct DRWDebugVertPair verts[DRW_DEBUG_DRAW_VERT_MAX]
struct DrawCommand command
const c_style_mat & ptr() const
static void set(DRWState state=DRW_STATE_DEFAULT)