Reimplement AABB debugging

This commit is contained in:
Vsevolod Kremianskii 2021-05-15 11:45:03 +07:00
parent a6c6230e2b
commit eec6b8e403
2 changed files with 25 additions and 8 deletions

View file

@ -181,14 +181,14 @@ static const VertexAttributes g_cubemapAttributes { 8 * sizeof(float), 0, 3 * si
// AABB
static const vector<float> g_aabbVertices = {
-0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, -0.5f,
0.5f, 0.5f, 0.5f,
0.5f, 0.5f, -0.5f,
0.5f, -0.5f, -0.5f,
0.5f, -0.5f, 0.5f
-0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 1.0f,
-0.5f, 0.5f, 1.0f,
-0.5f, 0.5f, 0.0f,
0.5f, 0.5f, 1.0f,
0.5f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 1.0f
};
static const vector<uint16_t> g_aabbIndices = {

View file

@ -19,6 +19,8 @@
#include <algorithm>
#include "glm/gtx/transform.hpp"
#include "../graphics/mesh/meshes.h"
#include "node/cameranode.h"
@ -38,6 +40,8 @@ namespace scene {
static constexpr float kMaxGrassDistance = 16.0f;
static const bool g_debugAABB = false;
SceneGraph::SceneGraph(const GraphicsOptions &opts) : _opts(opts) {
}
@ -312,6 +316,19 @@ void SceneGraph::draw(bool shadowPass) {
mesh->drawSingle(false);
}
if (g_debugAABB) {
for (auto &root : _roots) {
glm::mat4 transform(root->absoluteTransform());
transform *= glm::scale(root->aabb().getSize());
ShaderUniforms uniforms(_uniformsPrototype);
uniforms.combined.general.model = move(transform);
Shaders::instance().activate(ShaderProgram::SimpleColor, uniforms);
Meshes::instance().getAABB()->draw();
}
}
// Render transparent meshes
for (auto &mesh : _transparentMeshes) {
mesh->drawSingle(false);