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);
|
||||
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();
|
||||
image->flipY();
|
||||
imageio::write(paths->resolve("world:preview.png").u8string(), image.get());
|
||||
@ -161,7 +161,7 @@ void LevelScreen::draw(float) {
|
||||
Viewport viewport(Window::width, Window::height);
|
||||
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) {
|
||||
hud->draw(ctx);
|
||||
|
||||
@ -154,7 +154,8 @@ void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
|
||||
void WorldRenderer::renderLevel(
|
||||
const DrawContext&,
|
||||
Camera* camera,
|
||||
const EngineSettings& settings
|
||||
const EngineSettings& settings,
|
||||
bool pause
|
||||
) {
|
||||
auto assets = engine->getAssets();
|
||||
auto atlas = assets->get<Atlas>("blocks");
|
||||
@ -197,7 +198,7 @@ void WorldRenderer::renderLevel(
|
||||
drawChunks(level->chunks.get(), camera, shader);
|
||||
|
||||
shader->uniformMatrix("u_model", glm::mat4(1.0f));
|
||||
level->entities->render(assets, *modelBatch, *frustumCulling);
|
||||
level->entities->render(assets, *modelBatch, *frustumCulling, pause);
|
||||
modelBatch->render();
|
||||
|
||||
skybox->unbind();
|
||||
@ -294,7 +295,8 @@ void WorldRenderer::renderDebugLines(
|
||||
void WorldRenderer::draw(
|
||||
const DrawContext& pctx,
|
||||
Camera* camera,
|
||||
bool hudVisible,
|
||||
bool hudVisible,
|
||||
bool pause,
|
||||
PostProcessing* postProcessing
|
||||
){
|
||||
auto world = level->getWorld();
|
||||
@ -322,7 +324,7 @@ void WorldRenderer::draw(
|
||||
DrawContext ctx = wctx.sub();
|
||||
ctx.setDepthTest(true);
|
||||
ctx.setCullFace(true);
|
||||
renderLevel(ctx, camera, settings);
|
||||
renderLevel(ctx, camera, settings, pause);
|
||||
// Debug lines
|
||||
if (hudVisible){
|
||||
renderLines(camera, linesShader);
|
||||
|
||||
@ -71,7 +71,8 @@ public:
|
||||
void draw(
|
||||
const DrawContext& context,
|
||||
Camera* camera,
|
||||
bool hudVisible,
|
||||
bool hudVisible,
|
||||
bool pause,
|
||||
PostProcessing* postProcessing
|
||||
);
|
||||
void drawBorders(int sx, int sy, int sz, int ex, int ey, int ez);
|
||||
@ -83,7 +84,8 @@ public:
|
||||
void renderLevel(
|
||||
const DrawContext& context,
|
||||
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) {
|
||||
scripting::on_entities_render();
|
||||
void Entities::render(Assets* assets, ModelBatch& batch, const Frustum& frustum, bool pause) {
|
||||
if (!pause) {
|
||||
scripting::on_entities_render();
|
||||
}
|
||||
|
||||
auto view = registry.view<Transform, rigging::Rig>();
|
||||
for (auto [entity, transform, rig] : view.each()) {
|
||||
|
||||
@ -168,7 +168,7 @@ public:
|
||||
void update();
|
||||
|
||||
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(
|
||||
EntityDef& def,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user