fix: on_render called while paused
This commit is contained in:
parent
19c6a82ab2
commit
690b8f4807
@ -98,7 +98,7 @@ void LevelScreen::saveWorldPreview() {
|
|||||||
Viewport viewport(previewSize * 1.5, previewSize);
|
Viewport viewport(previewSize * 1.5, previewSize);
|
||||||
DrawContext ctx(&pctx, viewport, batch.get());
|
DrawContext ctx(&pctx, viewport, batch.get());
|
||||||
|
|
||||||
worldRenderer->draw(ctx, &camera, false, postProcessing.get());
|
worldRenderer->draw(ctx, &camera, false, true, postProcessing.get());
|
||||||
auto image = postProcessing->toImage();
|
auto image = postProcessing->toImage();
|
||||||
image->flipY();
|
image->flipY();
|
||||||
imageio::write(paths->resolve("world:preview.png").u8string(), image.get());
|
imageio::write(paths->resolve("world:preview.png").u8string(), image.get());
|
||||||
@ -161,7 +161,7 @@ void LevelScreen::draw(float) {
|
|||||||
Viewport viewport(Window::width, Window::height);
|
Viewport viewport(Window::width, Window::height);
|
||||||
DrawContext ctx(nullptr, viewport, batch.get());
|
DrawContext ctx(nullptr, viewport, batch.get());
|
||||||
|
|
||||||
worldRenderer->draw(ctx, camera.get(), hudVisible, postProcessing.get());
|
worldRenderer->draw(ctx, camera.get(), hudVisible, hud->isPause(), postProcessing.get());
|
||||||
|
|
||||||
if (hudVisible) {
|
if (hudVisible) {
|
||||||
hud->draw(ctx);
|
hud->draw(ctx);
|
||||||
|
|||||||
@ -154,7 +154,8 @@ void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
|
|||||||
void WorldRenderer::renderLevel(
|
void WorldRenderer::renderLevel(
|
||||||
const DrawContext&,
|
const DrawContext&,
|
||||||
Camera* camera,
|
Camera* camera,
|
||||||
const EngineSettings& settings
|
const EngineSettings& settings,
|
||||||
|
bool pause
|
||||||
) {
|
) {
|
||||||
auto assets = engine->getAssets();
|
auto assets = engine->getAssets();
|
||||||
auto atlas = assets->get<Atlas>("blocks");
|
auto atlas = assets->get<Atlas>("blocks");
|
||||||
@ -197,7 +198,7 @@ void WorldRenderer::renderLevel(
|
|||||||
drawChunks(level->chunks.get(), camera, shader);
|
drawChunks(level->chunks.get(), camera, shader);
|
||||||
|
|
||||||
shader->uniformMatrix("u_model", glm::mat4(1.0f));
|
shader->uniformMatrix("u_model", glm::mat4(1.0f));
|
||||||
level->entities->render(assets, *modelBatch, *frustumCulling);
|
level->entities->render(assets, *modelBatch, *frustumCulling, pause);
|
||||||
modelBatch->render();
|
modelBatch->render();
|
||||||
|
|
||||||
skybox->unbind();
|
skybox->unbind();
|
||||||
@ -295,6 +296,7 @@ void WorldRenderer::draw(
|
|||||||
const DrawContext& pctx,
|
const DrawContext& pctx,
|
||||||
Camera* camera,
|
Camera* camera,
|
||||||
bool hudVisible,
|
bool hudVisible,
|
||||||
|
bool pause,
|
||||||
PostProcessing* postProcessing
|
PostProcessing* postProcessing
|
||||||
){
|
){
|
||||||
auto world = level->getWorld();
|
auto world = level->getWorld();
|
||||||
@ -322,7 +324,7 @@ void WorldRenderer::draw(
|
|||||||
DrawContext ctx = wctx.sub();
|
DrawContext ctx = wctx.sub();
|
||||||
ctx.setDepthTest(true);
|
ctx.setDepthTest(true);
|
||||||
ctx.setCullFace(true);
|
ctx.setCullFace(true);
|
||||||
renderLevel(ctx, camera, settings);
|
renderLevel(ctx, camera, settings, pause);
|
||||||
// Debug lines
|
// Debug lines
|
||||||
if (hudVisible){
|
if (hudVisible){
|
||||||
renderLines(camera, linesShader);
|
renderLines(camera, linesShader);
|
||||||
|
|||||||
@ -72,6 +72,7 @@ public:
|
|||||||
const DrawContext& context,
|
const DrawContext& context,
|
||||||
Camera* camera,
|
Camera* camera,
|
||||||
bool hudVisible,
|
bool hudVisible,
|
||||||
|
bool pause,
|
||||||
PostProcessing* postProcessing
|
PostProcessing* postProcessing
|
||||||
);
|
);
|
||||||
void drawBorders(int sx, int sy, int sz, int ex, int ey, int ez);
|
void drawBorders(int sx, int sy, int sz, int ex, int ey, int ez);
|
||||||
@ -83,7 +84,8 @@ public:
|
|||||||
void renderLevel(
|
void renderLevel(
|
||||||
const DrawContext& context,
|
const DrawContext& context,
|
||||||
Camera* camera,
|
Camera* camera,
|
||||||
const EngineSettings& settings
|
const EngineSettings& settings,
|
||||||
|
bool pause
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -350,8 +350,10 @@ void Entities::renderDebug(LineBatch& batch, const Frustum& frustum) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entities::render(Assets* assets, ModelBatch& batch, const Frustum& frustum) {
|
void Entities::render(Assets* assets, ModelBatch& batch, const Frustum& frustum, bool pause) {
|
||||||
|
if (!pause) {
|
||||||
scripting::on_entities_render();
|
scripting::on_entities_render();
|
||||||
|
}
|
||||||
|
|
||||||
auto view = registry.view<Transform, rigging::Rig>();
|
auto view = registry.view<Transform, rigging::Rig>();
|
||||||
for (auto [entity, transform, rig] : view.each()) {
|
for (auto [entity, transform, rig] : view.each()) {
|
||||||
|
|||||||
@ -168,7 +168,7 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
void renderDebug(LineBatch& batch, const Frustum& frustum);
|
void renderDebug(LineBatch& batch, const Frustum& frustum);
|
||||||
void render(Assets* assets, ModelBatch& batch, const Frustum& frustum);
|
void render(Assets* assets, ModelBatch& batch, const Frustum& frustum, bool pause);
|
||||||
|
|
||||||
entityid_t spawn(
|
entityid_t spawn(
|
||||||
EntityDef& def,
|
EntityDef& def,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user