31 for (
int i = 0;
i < 2;
i++) {
34 if (cpu_draw_buf_.current() ==
nullptr) {
35 cpu_draw_buf_.current() = MEM_new<DebugDrawBuf>(
"DebugDrawBuf-CPU",
"DebugDrawBuf-CPU");
36 gpu_draw_buf_.current() = MEM_new<DebugDrawBuf>(
"DebugDrawBuf-GPU",
"DebugDrawBuf-GPU");
39 cpu_draw_buf_.current()->command.vertex_len = 0;
40 cpu_draw_buf_.current()->command.vertex_first = 0;
41 cpu_draw_buf_.current()->command.instance_len = 1;
42 cpu_draw_buf_.current()->command.instance_first_array = 0;
44 gpu_draw_buf_.current()->command.vertex_len = 0;
45 gpu_draw_buf_.current()->command.vertex_first = 0;
46 gpu_draw_buf_.current()->command.instance_len = 1;
47 gpu_draw_buf_.current()->command.instance_first_array = 0;
48 gpu_draw_buf_.current()->push_update();
54 gpu_draw_buf_used =
false;
60 gpu_draw_buf_used =
true;
61 return *gpu_draw_buf_.current();
67void DebugDraw::clear_gpu_data()
69 for (
int i = 0;
i < 2;
i++) {
70 MEM_SAFE_DELETE(cpu_draw_buf_.current());
71 MEM_SAFE_DELETE(gpu_draw_buf_.current());
101 for (
auto vert : face_verts) {
132 for (
auto edge :
IndexRange(circle_resolution)) {
134 const float angle = (2 *
M_PI) * (edge + vert) /
float(circle_resolution);
136 result.append(
float3(point[(0 + axis) % 3], point[(1 + axis) % 3], point[(2 + axis) % 3]));
151 float3 v0 = sphere_verts[
i * 2] * radius + center;
152 float3 v1 = sphere_verts[
i * 2 + 1] * radius + center;
165 float3 v1 = point_verts[
i * 2 + 1] * rad +
pos;
202 DebugDrawBuf &buf = *cpu_draw_buf_.current();
203 uint index = vertex_len_.fetch_add(2);
223void DebugDraw::display_lines(
View &
view)
225 const bool cpu_draw_buf_used = vertex_len_.load() != 0;
227 if (!cpu_draw_buf_used && !gpu_draw_buf_used) {
233 float viewport_size[4];
242 if (gpu_draw_buf_used) {
245 gpu_draw_buf_.next()->command.vertex_len = 0;
246 gpu_draw_buf_.next()->push_update();
260 cpu_draw_buf_.current()->command.vertex_len = vertex_len_.load();
261 cpu_draw_buf_.current()->push_update();
263 cpu_draw_buf_.next()->command.vertex_len = 0;
264 cpu_draw_buf_.next()->push_update();
273 cpu_draw_buf_.next()->read();
278 gpu_draw_buf_.swap();
279 cpu_draw_buf_.swap();
General operations, lookup, etc. for blender objects.
MINLINE int min_ii(int a, int b)
MINLINE unsigned int float_as_uint(float f)
void mul_project_m4_v3(const float mat[4][4], float vec[3])
int BLI_thread_is_main(void)
blender::gpu::Batch * GPU_batch_procedural_lines_get()
void GPU_batch_draw_indirect(blender::gpu::Batch *batch, blender::gpu::StorageBuf *indirect_buf, intptr_t offset)
void GPU_batch_set_shader(blender::gpu::Batch *batch, blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
void GPU_shader_uniform_mat4(blender::gpu::Shader *sh, const char *name, const float data[4][4])
void GPU_shader_uniform_2f(blender::gpu::Shader *sh, const char *name, float x, float y)
void GPU_viewport_size_get_f(float coords[4])
void GPU_storagebuf_bind(blender::gpu::StorageBuf *ssbo, int slot)
void GPU_storagebuf_unbind(blender::gpu::StorageBuf *ssbo)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
constexpr const T & last(const int64_t n=0) const
constexpr bool is_empty() const
void display_to_view(View &view)
gpu::StorageBuf * gpu_draw_buf_get()
void draw_line(float3 v1, float3 v2, uint color, uint lifetime=1)
Simple API to draw debug shapes and log in the viewport.
#define DRW_DEBUG_DRAW_SLOT
#define DRW_DEBUG_DRAW_FEEDBACK_SLOT
blender::gpu::Shader * DRW_shader_debug_draw_display_get()
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)
uint debug_color_pack(float4 v_color)
#define DRW_DEBUG_DRAW_VERT_MAX
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
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)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< float, 3 > float3
DRWDebugVertPair verts[DRW_DEBUG_DRAW_VERT_MAX]
const c_style_mat & ptr() const
static void set(DRWState state=DRW_STATE_DEFAULT)