Reimplement AABB debugging
This commit is contained in:
parent
a6c6230e2b
commit
eec6b8e403
2 changed files with 25 additions and 8 deletions
|
@ -181,14 +181,14 @@ static const VertexAttributes g_cubemapAttributes { 8 * sizeof(float), 0, 3 * si
|
||||||
// AABB
|
// AABB
|
||||||
|
|
||||||
static const vector<float> g_aabbVertices = {
|
static const vector<float> g_aabbVertices = {
|
||||||
-0.5f, -0.5f, -0.5f,
|
-0.5f, -0.5f, 0.0f,
|
||||||
-0.5f, -0.5f, 0.5f,
|
-0.5f, -0.5f, 1.0f,
|
||||||
-0.5f, 0.5f, 0.5f,
|
-0.5f, 0.5f, 1.0f,
|
||||||
-0.5f, 0.5f, -0.5f,
|
-0.5f, 0.5f, 0.0f,
|
||||||
0.5f, 0.5f, 0.5f,
|
0.5f, 0.5f, 1.0f,
|
||||||
0.5f, 0.5f, -0.5f,
|
0.5f, 0.5f, 0.0f,
|
||||||
0.5f, -0.5f, -0.5f,
|
0.5f, -0.5f, 0.0f,
|
||||||
0.5f, -0.5f, 0.5f
|
0.5f, -0.5f, 1.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
static const vector<uint16_t> g_aabbIndices = {
|
static const vector<uint16_t> g_aabbIndices = {
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "glm/gtx/transform.hpp"
|
||||||
|
|
||||||
#include "../graphics/mesh/meshes.h"
|
#include "../graphics/mesh/meshes.h"
|
||||||
|
|
||||||
#include "node/cameranode.h"
|
#include "node/cameranode.h"
|
||||||
|
@ -38,6 +40,8 @@ namespace scene {
|
||||||
|
|
||||||
static constexpr float kMaxGrassDistance = 16.0f;
|
static constexpr float kMaxGrassDistance = 16.0f;
|
||||||
|
|
||||||
|
static const bool g_debugAABB = false;
|
||||||
|
|
||||||
SceneGraph::SceneGraph(const GraphicsOptions &opts) : _opts(opts) {
|
SceneGraph::SceneGraph(const GraphicsOptions &opts) : _opts(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,6 +316,19 @@ void SceneGraph::draw(bool shadowPass) {
|
||||||
mesh->drawSingle(false);
|
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
|
// Render transparent meshes
|
||||||
for (auto &mesh : _transparentMeshes) {
|
for (auto &mesh : _transparentMeshes) {
|
||||||
mesh->drawSingle(false);
|
mesh->drawSingle(false);
|
||||||
|
|
Loading…
Reference in a new issue