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