27#if defined(_DEBUG) || defined(WITH_DRAW_DEBUG)
42 constexpr int circle_resolution = 16;
44 for (
auto edge :
IndexRange(circle_resolution)) {
46 const float angle = (2 *
M_PI) * (edge + vert) /
float(circle_resolution);
54 constexpr int point_resolution = 4;
56 for (
auto edge :
IndexRange(point_resolution)) {
58 const float angle = (2 *
M_PI) * (edge + vert) /
float(point_resolution);
69 cpu_print_buf_.
command.vertex_len = 0;
70 cpu_print_buf_.command.vertex_first = 0;
71 cpu_print_buf_.command.instance_len = 1;
72 cpu_print_buf_.command.instance_first_array = 0;
74 cpu_draw_buf_.command.vertex_len = 0;
75 cpu_draw_buf_.command.vertex_first = 0;
76 cpu_draw_buf_.command.instance_len = 1;
77 cpu_draw_buf_.command.instance_first_array = 0;
79 gpu_print_buf_.command.vertex_len = 0;
80 gpu_print_buf_.command.vertex_first = 0;
81 gpu_print_buf_.command.instance_len = 1;
82 gpu_print_buf_.command.instance_first_array = 0;
83 gpu_print_buf_used =
false;
85 gpu_draw_buf_.command.vertex_len = 0;
86 gpu_draw_buf_.command.vertex_first = 0;
87 gpu_draw_buf_.command.instance_len = 1;
88 gpu_draw_buf_.command.instance_first_array = 0;
89 gpu_draw_buf_used =
false;
109 if (!gpu_draw_buf_used) {
110 gpu_draw_buf_used =
true;
111 gpu_draw_buf_.push_update();
113 return gpu_draw_buf_;
118 if (!gpu_print_buf_used) {
119 gpu_print_buf_used =
true;
120 gpu_print_buf_.push_update();
122 return gpu_print_buf_;
142 for (
auto vert : face_verts) {
188 const float min[3] = {-1.0f, -1.0f, -1.0f},
max[3] = {1.0f, 1.0f, 1.0f};
199 for (
auto i :
IndexRange(sphere_verts_.size() / 2)) {
200 float3 v0 = sphere_verts_[i * 2] * radius + center;
201 float3 v1 = sphere_verts_[i * 2 + 1] * radius + center;
209 for (
auto i :
IndexRange(point_verts_.size() / 2)) {
210 float3 v0 = point_verts_[i * 2] * radius + center;
211 float3 v1 = point_verts_[i * 2 + 1] * radius + center;
222template<>
void DebugDraw::print_value<uint>(
const uint &value)
224 print_value_uint(value,
false,
false,
true);
226template<>
void DebugDraw::print_value<int>(
const int &value)
228 print_value_uint(
uint(
abs(value)),
false, (value < 0),
false);
230template<>
void DebugDraw::print_value<bool>(
const bool &value)
232 print_string(value ?
"true " :
"false");
234template<>
void DebugDraw::print_value<float>(
const float &val)
236 std::stringstream ss;
237 ss << std::setw(12) << std::to_string(val);
238 print_string(ss.str());
240template<>
void DebugDraw::print_value<double>(
const double &val)
242 print_value(
float(val));
245template<>
void DebugDraw::print_value_hex<uint>(
const uint &value)
247 print_value_uint(value,
true,
false,
false);
249template<>
void DebugDraw::print_value_hex<int>(
const int &value)
251 print_value_uint(
uint(value),
true,
false,
false);
253template<>
void DebugDraw::print_value_hex<float>(
const float &value)
255 print_value_uint(*
reinterpret_cast<const uint *
>(&value),
true,
false,
false);
257template<>
void DebugDraw::print_value_hex<double>(
const double &val)
259 print_value_hex(
float(val));
262template<>
void DebugDraw::print_value_binary<uint>(
const uint &value)
264 print_value_binary(value);
266template<>
void DebugDraw::print_value_binary<int>(
const int &value)
268 print_value_binary(
uint(value));
270template<>
void DebugDraw::print_value_binary<float>(
const float &value)
272 print_value_binary(*
reinterpret_cast<const uint *
>(&value));
274template<>
void DebugDraw::print_value_binary<double>(
const double &val)
276 print_value_binary(
float(val));
279template<>
void DebugDraw::print_value<float2>(
const float2 &value)
283template<>
void DebugDraw::print_value<float3>(
const float3 &value)
285 print_no_endl(
"float3(", value[0],
", ", value[1],
", ", value[1],
")");
287template<>
void DebugDraw::print_value<float4>(
const float4 &value)
289 print_no_endl(
"float4(", value[0],
", ", value[1],
", ", value[2],
", ", value[3],
")");
292template<>
void DebugDraw::print_value<int2>(
const int2 &value)
296template<>
void DebugDraw::print_value<int3>(
const int3 &value)
298 print_no_endl(
"int3(", value[0],
", ", value[1],
", ", value[1],
")");
300template<>
void DebugDraw::print_value<int4>(
const int4 &value)
302 print_no_endl(
"int4(", value[0],
", ", value[1],
", ", value[2],
", ", value[3],
")");
305template<>
void DebugDraw::print_value<uint2>(
const uint2 &value)
309template<>
void DebugDraw::print_value<uint3>(
const uint3 &value)
311 print_no_endl(
"uint3(", value[0],
", ", value[1],
", ", value[1],
")");
313template<>
void DebugDraw::print_value<uint4>(
const uint4 &value)
315 print_no_endl(
"uint4(", value[0],
", ", value[1],
", ", value[2],
", ", value[3],
")");
329 DebugDrawBuf &buf = cpu_draw_buf_;
334 buf.command.vertex_len += 2;
361void DebugDraw::print_newline()
364 print_row_ = ++cpu_print_buf_.command.instance_first_array;
367void DebugDraw::print_string_start(
uint len)
376void DebugDraw::print_string(std::string
str)
378 size_t len_before_pad =
str.length();
380 while (
str.length() % 4 != 0) {
384 print_string_start(len_before_pad);
385 for (
size_t i = 0; i < len_before_pad; i += 4) {
391 chars[0] = *(
reinterpret_cast<const uint8_t *
>(
str.c_str()) + i + 0);
392 chars[1] = *(
reinterpret_cast<const uint8_t *
>(
str.c_str()) + i + 1);
393 chars[2] = *(
reinterpret_cast<const uint8_t *
>(
str.c_str()) + i + 2);
394 chars[3] = *(
reinterpret_cast<const uint8_t *
>(
str.c_str()) + i + 3);
396 if (i + 4 > len_before_pad) {
397 chars[len_before_pad - i] =
'\0';
404void DebugDraw::print_char4(
uint data)
414 uint cursor = cpu_print_buf_.command.vertex_len++;
419 uint print_header = (flags << 24u) | (print_row_ << 16u) | (
col << 8u);
420 cpu_print_buf_.char_array[cursor] = print_header | char1;
436 const uint char_A = 0x41u;
437 const uint char_0 = 0x30u;
438 bool is_hexadecimal = digit > 9u;
439 char4 = (
char4 << 8u) | (is_hexadecimal ? (char_A + digit - 10u) : (char_0 + digit));
442void DebugDraw::print_append_space(
uint &
char4)
447void DebugDraw::print_value_binary(
uint value)
450 print_string_start(10u * 4u);
451 uint digits[10] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
453 for (
uint i = 0u; i < 32u; i++) {
454 print_append_digit(((value >> i) & 1u), digits[digit / 4u]);
456 if ((i % 4u) == 3u) {
457 print_append_space(digits[digit / 4u]);
462 for (
int j = 9; j >= 0; j--) {
463 print_char4(digits[j]);
467void DebugDraw::print_value_uint(
uint value,
470 const bool is_unsigned)
472 print_string_start(3u * 4u);
473 const uint blank_value =
hex ? 0x30303030u : 0x20202020u;
474 const uint prefix =
hex ? 0x78302020u : 0x20202020u;
475 uint digits[3] = {blank_value, blank_value, prefix};
476 const uint base =
hex ? 16u : 10u;
480 print_append_char(
'u', digits[digit / 4u]);
484 for (; value != 0u || digit ==
uint(is_unsigned); value /= base) {
485 print_append_digit(value % base, digits[digit / 4u]);
490 print_append_char(
'-', digits[digit / 4u]);
494 for (
uint i = digit % 4u; i < 4u && i > 0u; i++) {
495 print_append_space(digits[digit / 4u]);
499 for (
int j = 2; j >= 0; j--) {
500 print_char4(digits[j]);
510void DebugDraw::display_lines()
512 if (cpu_draw_buf_.command.vertex_len == 0 && gpu_draw_buf_used ==
false) {
516 cpu_draw_buf_.push_update();
529 if (gpu_draw_buf_used) {
546void DebugDraw::display_prints()
548 if (cpu_print_buf_.command.vertex_len == 0 && gpu_print_buf_used ==
false) {
552 cpu_print_buf_.push_update();
563 if (gpu_print_buf_used) {
615 if (
DST.debug ==
nullptr) {
631 if (
DST.debug ==
nullptr) {
General operations, lookup, etc. for blender objects.
void BKE_boundbox_init_from_minmax(BoundBox *bb, const float min[3], const float max[3])
Single link-list utility macros. (header only api).
void mul_project_m4_v3(const float mat[4][4], float vec[3])
void GPU_batch_draw_indirect(blender::gpu::Batch *batch, GPUStorageBuf *indirect_buf, intptr_t offset)
void GPU_batch_set_shader(blender::gpu::Batch *batch, GPUShader *shader)
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])
void GPU_shader_uniform_mat4(GPUShader *sh, const char *name, const float data[4][4])
void GPU_viewport_size_get_f(float coords[4])
void GPU_storagebuf_bind(GPUStorageBuf *ssbo, int slot)
void GPU_storagebuf_unbind(GPUStorageBuf *ssbo)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
struct GPUShader GPUShader
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr const T & last(const int64_t n=0) const
constexpr bool is_empty() const
void modelmat_set(const float modelmat[4][4])
void print_no_endl(std::string arg)
void draw_matrix(const float4x4 &m4)
void draw_polygon(Span< float3 > face_verts, float4 color={1, 0, 0, 1})
void draw_matrix_as_bbox(const float4x4 &mat, const float4 color={1, 0, 0, 1})
void draw_sphere(const float3 center, float radius, const float4 color={1, 0, 0, 1})
void draw_bbox(const BoundBox &bbox, const float4 color={1, 0, 0, 1})
GPUStorageBuf * gpu_print_buf_get()
GPUStorageBuf * gpu_draw_buf_get()
void draw_line(float3 v1, float3 v2, float4 color={1, 0, 0, 1})
void draw_point(const float3 center, float radius=0.01f, const float4 color={1, 0, 0, 1})
blender::gpu::Batch * drw_cache_procedural_lines_get()
blender::gpu::Batch * drw_cache_procedural_points_get()
GPUStorageBuf * drw_debug_gpu_print_buf_get()
void DRW_debug_modelmat(const float modelmat[4][4])
blender::draw::DebugDraw * DRW_debug_get()
void DRW_debug_sphere(const float center[3], float radius, const float color[4])
void DRW_debug_m4(const float m[4][4])
void drw_debug_module_free(DRWDebugModule *module)
void DRW_debug_line_v3v3(const float v1[3], const float v2[3], const float color[4])
void DRW_debug_modelmat_reset()
void DRW_debug_bbox(const BoundBox *bbox, const float color[4])
GPUStorageBuf * drw_debug_gpu_draw_buf_get()
void DRW_debug_polygon_v3(const float(*v)[3], int vert_len, const float color[4])
void DRW_debug_m4_as_bbox(const float m[4][4], bool invert, const float color[4])
Simple API to draw debug shapes and log in the viewport.
Simple API to draw debug shapes in the viewport. IMPORTANT: This is the legacy API for C....
#define DRW_DEBUG_DRAW_SLOT
#define DRW_DEBUG_PRINT_SLOT
void drw_state_set(DRWState state)
void DRW_view_persmat_get(const DRWView *view, float mat[4][4], bool inverse)
const DRWView * DRW_view_get_active()
GPUShader * DRW_shader_debug_draw_display_get()
GPUShader * DRW_shader_debug_print_display_get()
#define DRW_DEBUG_PRINT_WORD_WRAP_COLUMN
#define DRW_DEBUG_PRINT_MAX
#define DRW_DEBUG_DRAW_VERT_MAX
@ DRW_STATE_PROGRAM_POINT_SIZE
draw_view in_light_buf[] float
struct @157336070235062372277311340362362342103123126032::@262166344314164341202215145112231240022370055142 batch
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
T clamp(const T &a, const T &min, const T &max)
bool is_negative(const MatBase< T, Size, Size > &mat)
T min(const T &a, const T &b)
CartesianBasis invert(const CartesianBasis &basis)
T max(const T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
VecBase< uint32_t, 2 > uint2
VecBase< int32_t, 4 > int4
VecBase< uint32_t, 4 > uint4
VecBase< uint32_t, 3 > uint3
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
blender::VecBase< int8_t, 4 > char4
MatView< float, 4, 4, 4, 4, 0, 0, alignof(float)> float4x4_view
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
static struct PyModuleDef module
const c_style_mat & ptr() const
static MatBase identity()
static const char hex[17]