mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Merge branch 'main' into block-wraps-update
This commit is contained in:
commit
251ca617bc
4 changed files with 30 additions and 38 deletions
|
|
@ -1,53 +1,53 @@
|
|||
#include "DebugLinesRenderer.hpp"
|
||||
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "window/Camera.hpp"
|
||||
#include "graphics/core/LineBatch.hpp"
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
#include "graphics/render/LinesRenderer.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "graphics/core/LineBatch.hpp"
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "maths/voxmaths.hpp"
|
||||
#include "voxels/Chunk.hpp"
|
||||
#include "voxels/Pathfinding.hpp"
|
||||
#include "maths/voxmaths.hpp"
|
||||
#include "window/Camera.hpp"
|
||||
#include "world/Level.hpp"
|
||||
|
||||
bool DebugLinesRenderer::showPaths = false;
|
||||
|
||||
static void draw_route(
|
||||
LinesRenderer& lines, const voxels::Agent& agent
|
||||
) {
|
||||
static void draw_route(LineBatch& batch, const voxels::Agent& agent) {
|
||||
const auto& route = agent.route;
|
||||
if (!route.found)
|
||||
return;
|
||||
if (!route.found) return;
|
||||
|
||||
batch.lineWidth(1.0f);
|
||||
|
||||
for (int i = 1; i < route.nodes.size(); i++) {
|
||||
const auto& a = route.nodes.at(i - 1);
|
||||
const auto& b = route.nodes.at(i);
|
||||
const auto& a = glm::vec3(route.nodes.at(i - 1).pos);
|
||||
const auto& b = glm::vec3(route.nodes.at(i).pos);
|
||||
|
||||
glm::vec3 a_base = a + glm::vec3(0.5);
|
||||
glm::vec3 b_base = b + glm::vec3(0.5);
|
||||
glm::vec3 b_up = b + glm::vec3(0.5f, 1.0f, 0.5f);
|
||||
|
||||
if (i == 1) {
|
||||
lines.pushLine(
|
||||
glm::vec3(a.pos) + glm::vec3(0.5f),
|
||||
glm::vec3(a.pos) + glm::vec3(0.5f, 1.0f, 0.5f),
|
||||
glm::vec4(1, 1, 1, 1)
|
||||
glm::vec3 a_up = a + glm::vec3(0.5f, 1.0f, 0.5f);
|
||||
|
||||
batch.line(
|
||||
a_base.x, a_base.y, a_base.z, a_up.x, a_up.y, a_up.z, 1, 1, 1, 1
|
||||
);
|
||||
}
|
||||
|
||||
lines.pushLine(
|
||||
glm::vec3(a.pos) + glm::vec3(0.5f),
|
||||
glm::vec3(b.pos) + glm::vec3(0.5f),
|
||||
glm::vec4(1, 0, 1, 1)
|
||||
batch.line(
|
||||
a_base.x, a_base.y, a_base.z, b_base.x, b_base.y, b_base.z,
|
||||
1, 0, 1, 1
|
||||
);
|
||||
|
||||
lines.pushLine(
|
||||
glm::vec3(b.pos) + glm::vec3(0.5f),
|
||||
glm::vec3(b.pos) + glm::vec3(0.5f, 1.0f, 0.5f),
|
||||
glm::vec4(1, 1, 1, 1)
|
||||
batch.line(
|
||||
b_base.x, b_base.y, b_base.z, b_up.x, b_up.y, b_up.z, 1, 1, 1, 1
|
||||
);
|
||||
}
|
||||
|
||||
batch.flush();
|
||||
}
|
||||
|
||||
void DebugLinesRenderer::drawBorders(
|
||||
LineBatch& batch, int sx, int sy, int sz, int ex, int ey, int ez
|
||||
) {
|
||||
batch.lineWidth(1.0f);
|
||||
int ww = ex - sx;
|
||||
int dd = ez - sz;
|
||||
/*corner*/ {
|
||||
|
|
@ -89,13 +89,12 @@ void DebugLinesRenderer::drawCoordSystem(
|
|||
batch.line(0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f);
|
||||
batch.line(0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 0.f, 1.f);
|
||||
batch.line(0.f, 0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 1.f);
|
||||
batch.flush();
|
||||
}
|
||||
|
||||
|
||||
void DebugLinesRenderer::render(
|
||||
DrawContext& pctx,
|
||||
const Camera& camera,
|
||||
LinesRenderer& renderer,
|
||||
LineBatch& linesBatch,
|
||||
Shader& linesShader,
|
||||
bool showChunkBorders
|
||||
|
|
@ -103,7 +102,7 @@ void DebugLinesRenderer::render(
|
|||
// In-world lines
|
||||
if (showPaths) {
|
||||
for (const auto& [_, agent] : level.pathfinding->getAgents()) {
|
||||
draw_route(renderer, agent);
|
||||
draw_route(linesBatch, agent);
|
||||
}
|
||||
}
|
||||
DrawContext ctx = pctx.sub(&linesBatch);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
class DrawContext;
|
||||
class Camera;
|
||||
class LineBatch;
|
||||
class LinesRenderer;
|
||||
class Shader;
|
||||
class Level;
|
||||
|
||||
|
|
@ -23,7 +22,6 @@ public:
|
|||
void render(
|
||||
DrawContext& ctx,
|
||||
const Camera& camera,
|
||||
LinesRenderer& renderer,
|
||||
LineBatch& linesBatch,
|
||||
Shader& linesShader,
|
||||
bool showChunkBorders
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@
|
|||
#include "NamedSkeletons.hpp"
|
||||
#include "TextsRenderer.hpp"
|
||||
#include "ChunksRenderer.hpp"
|
||||
#include "LinesRenderer.hpp"
|
||||
#include "DebugLinesRenderer.hpp"
|
||||
#include "ModelBatch.hpp"
|
||||
#include "Skybox.hpp"
|
||||
|
|
@ -117,7 +116,6 @@ WorldRenderer::WorldRenderer(
|
|||
hands = std::make_unique<HandsRenderer>(
|
||||
*assets, *modelBatch, skeletons->createSkeleton("hand", &skeletonConfig)
|
||||
);
|
||||
lines = std::make_unique<LinesRenderer>();
|
||||
shadowMapping = std::make_unique<Shadows>(level);
|
||||
debugLines = std::make_unique<DebugLinesRenderer>(level);
|
||||
}
|
||||
|
|
@ -386,11 +384,10 @@ void WorldRenderer::renderFrame(
|
|||
linesShader.use();
|
||||
if (debug && hudVisible) {
|
||||
debugLines->render(
|
||||
ctx, camera, *lines, *lineBatch, linesShader, showChunkBorders
|
||||
ctx, camera, *lineBatch, linesShader, showChunkBorders
|
||||
);
|
||||
}
|
||||
linesShader.uniformMatrix("u_projview", projView);
|
||||
lines->draw(*lineBatch);
|
||||
lineBatch->flush();
|
||||
|
||||
// Translucent blocks
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ class BlockWrapsRenderer;
|
|||
class PrecipitationRenderer;
|
||||
class HandsRenderer;
|
||||
class NamedSkeletons;
|
||||
class LinesRenderer;
|
||||
class TextsRenderer;
|
||||
class Shader;
|
||||
class Frustum;
|
||||
|
|
@ -104,7 +103,6 @@ public:
|
|||
std::unique_ptr<BlockWrapsRenderer> blockWraps;
|
||||
std::unique_ptr<PrecipitationRenderer> precipitation;
|
||||
std::unique_ptr<NamedSkeletons> skeletons;
|
||||
std::unique_ptr<LinesRenderer> lines;
|
||||
|
||||
static bool showChunkBorders;
|
||||
static bool showEntitiesDebug;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue