This changes the include directive to use the standard C preprocessor `#include` directive. The regex to applied to all glsl sources is: `pragma BLENDER_REQUIRE\((\w+\.glsl)\)` `include "$1"` This allow C++ linter to parse the code and allow easier codebase traversal. However there is a small catch. While it does work like a standard include directive when the code is treated as C++, it doesn't when compiled by our shader backends. In this case, we still use our dependency concatenation approach instead of file injection. This means that included files will always be prepended when compiled to GLSL and a file cannot be appended more than once. This is why all GLSL lib file should have the `#pragma once` directive and always be included at the start of the file. These requirements are actually already enforced by our code-style in practice. On the implementation, the source needed to be mutated to comment the `#pragma once` and `#include`. This is needed to avoid GLSL compiler error out as this is an extension that not all vendor supports. Rel #127983 Pull Request: https://projects.blender.org/blender/blender/pulls/128076
63 lines
1.9 KiB
GLSL
63 lines
1.9 KiB
GLSL
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* Debug drawing of shapes.
|
|
*/
|
|
|
|
#include "common_debug_draw_lib.glsl"
|
|
#include "common_shape_lib.glsl"
|
|
|
|
void drw_debug(Box shape, vec4 color)
|
|
{
|
|
drw_debug_quad(shape.corners[0], shape.corners[1], shape.corners[2], shape.corners[3], color);
|
|
drw_debug_line(shape.corners[0], shape.corners[4], color);
|
|
drw_debug_line(shape.corners[1], shape.corners[5], color);
|
|
drw_debug_line(shape.corners[2], shape.corners[6], color);
|
|
drw_debug_line(shape.corners[3], shape.corners[7], color);
|
|
drw_debug_quad(shape.corners[4], shape.corners[5], shape.corners[6], shape.corners[7], color);
|
|
}
|
|
void drw_debug(Box shape)
|
|
{
|
|
drw_debug(shape, drw_debug_default_color);
|
|
}
|
|
|
|
void drw_debug(Frustum shape, vec4 color)
|
|
{
|
|
drw_debug_quad(shape.corners[0], shape.corners[1], shape.corners[2], shape.corners[3], color);
|
|
drw_debug_line(shape.corners[0], shape.corners[4], color);
|
|
drw_debug_line(shape.corners[1], shape.corners[5], color);
|
|
drw_debug_line(shape.corners[2], shape.corners[6], color);
|
|
drw_debug_line(shape.corners[3], shape.corners[7], color);
|
|
drw_debug_quad(shape.corners[4], shape.corners[5], shape.corners[6], shape.corners[7], color);
|
|
}
|
|
void drw_debug(Frustum shape)
|
|
{
|
|
drw_debug(shape, drw_debug_default_color);
|
|
}
|
|
|
|
void drw_debug(Pyramid shape, vec4 color)
|
|
{
|
|
drw_debug_line(shape.corners[0], shape.corners[1], color);
|
|
drw_debug_line(shape.corners[0], shape.corners[2], color);
|
|
drw_debug_line(shape.corners[0], shape.corners[3], color);
|
|
drw_debug_line(shape.corners[0], shape.corners[4], color);
|
|
drw_debug_quad(shape.corners[1], shape.corners[2], shape.corners[3], shape.corners[4], color);
|
|
}
|
|
void drw_debug(Pyramid shape)
|
|
{
|
|
drw_debug(shape, drw_debug_default_color);
|
|
}
|
|
|
|
void drw_debug(Sphere shape, vec4 color)
|
|
{
|
|
drw_debug_sphere(shape.center, shape.radius, color);
|
|
}
|
|
void drw_debug(Sphere shape)
|
|
{
|
|
drw_debug(shape, drw_debug_default_color);
|
|
}
|