aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2023-03-19 21:31:15 +0100
committerGitHub <noreply@github.com>2023-03-19 21:31:15 +0100
commit6cd2eea48781dd7318b6ea78c5cdea4a3ee5db02 (patch)
treea5d0da127c7b4637adefde7a80e72580dff68484
parent09342c0811bb8d035e012a79dce714a6b63722e4 (diff)
downloadminetest-6cd2eea48781dd7318b6ea78c5cdea4a3ee5db02.tar.xz
Move drawing of wield tool into a dedicated step of the pipeline (#13338)
-rw-r--r--src/client/camera.cpp5
-rw-r--r--src/client/render/anaglyph.cpp17
-rw-r--r--src/client/render/interlaced.cpp1
-rw-r--r--src/client/render/plain.cpp8
-rw-r--r--src/client/render/plain.h13
-rw-r--r--src/client/render/sidebyside.cpp1
6 files changed, 36 insertions, 9 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp
index ba621d15b..13ca7aa5c 100644
--- a/src/client/camera.cpp
+++ b/src/client/camera.cpp
@@ -635,11 +635,14 @@ void Camera::wield(const ItemStack &item)
void Camera::drawWieldedTool(irr::core::matrix4* translation)
{
+ // Clear Z buffer so that the wielded tool stays in front of world geometry
+ m_wieldmgr->getVideoDriver()->clearBuffers(video::ECBF_DEPTH);
+
// Draw the wielded node (in a separate scene manager)
scene::ICameraSceneNode* cam = m_wieldmgr->getActiveCamera();
cam->setAspectRatio(m_cameranode->getAspectRatio());
cam->setFOV(72.0*M_PI/180.0);
- cam->setNearValue(40); // give wield tool smaller z-depth than the world in most cases.
+ cam->setNearValue(10);
cam->setFarValue(1000);
if (translation != NULL)
{
diff --git a/src/client/render/anaglyph.cpp b/src/client/render/anaglyph.cpp
index 46f417900..b26db9186 100644
--- a/src/client/render/anaglyph.cpp
+++ b/src/client/render/anaglyph.cpp
@@ -73,19 +73,20 @@ void populateAnaglyphPipeline(RenderPipeline *pipeline, Client *client)
step3D->setRenderTarget(enable_override_material);
// left eye
- pipeline->addStep(pipeline->createOwned<OffsetCameraStep>(false));
- pipeline->addStep(pipeline->createOwned<SetColorMaskStep>(video::ECP_RED));
+ pipeline->addStep<OffsetCameraStep>(false);
+ pipeline->addStep<SetColorMaskStep>(video::ECP_RED);
pipeline->addStep(step3D);
// right eye
- pipeline->addStep(pipeline->createOwned<OffsetCameraStep>(true));
- pipeline->addStep(pipeline->createOwned<SetColorMaskStep>(video::ECP_GREEN | video::ECP_BLUE));
+ pipeline->addStep<OffsetCameraStep>(true);
+ pipeline->addStep<SetColorMaskStep>(video::ECP_GREEN | video::ECP_BLUE);
pipeline->addStep(step3D);
// reset
- pipeline->addStep(pipeline->createOwned<OffsetCameraStep>(0.0f));
- pipeline->addStep(pipeline->createOwned<SetColorMaskStep>(video::ECP_ALL));
+ pipeline->addStep<OffsetCameraStep>(0.0f);
+ pipeline->addStep<SetColorMaskStep>(video::ECP_ALL);
- pipeline->addStep(pipeline->createOwned<MapPostFxStep>());
- pipeline->addStep(pipeline->createOwned<DrawHUD>());
+ pipeline->addStep<DrawWield>();
+ pipeline->addStep<MapPostFxStep>();
+ pipeline->addStep<DrawHUD>();
}
diff --git a/src/client/render/interlaced.cpp b/src/client/render/interlaced.cpp
index f4accd39b..20e918487 100644
--- a/src/client/render/interlaced.cpp
+++ b/src/client/render/interlaced.cpp
@@ -69,6 +69,7 @@ void populateInterlacedPipeline(RenderPipeline *pipeline, Client *client)
auto output = pipeline->createOwned<TextureBufferOutput>(buffer, right ? TEXTURE_RIGHT : TEXTURE_LEFT);
pipeline->addStep<SetRenderTargetStep>(step3D, output);
pipeline->addStep(step3D);
+ pipeline->addStep<DrawWield>();
pipeline->addStep<MapPostFxStep>();
}
diff --git a/src/client/render/plain.cpp b/src/client/render/plain.cpp
index 11378b165..60abbb97a 100644
--- a/src/client/render/plain.cpp
+++ b/src/client/render/plain.cpp
@@ -39,6 +39,13 @@ void Draw3D::run(PipelineContext &context)
return;
context.hud->drawBlockBounds();
context.hud->drawSelectionMesh();
+}
+
+void DrawWield::run(PipelineContext &context)
+{
+ if (m_target)
+ m_target->activate(context);
+
if (context.draw_wield_tool)
context.client->getCamera()->drawWieldedTool();
}
@@ -144,6 +151,7 @@ void populatePlainPipeline(RenderPipeline *pipeline, Client *client)
auto downscale_factor = getDownscaleFactor();
auto step3D = pipeline->own(create3DStage(client, downscale_factor));
pipeline->addStep(step3D);
+ pipeline->addStep<DrawWield>();
pipeline->addStep<MapPostFxStep>();
step3D = addUpscaling(pipeline, step3D, downscale_factor);
diff --git a/src/client/render/plain.h b/src/client/render/plain.h
index 5180304a4..6bea36bf3 100644
--- a/src/client/render/plain.h
+++ b/src/client/render/plain.h
@@ -38,6 +38,19 @@ private:
RenderTarget *m_target {nullptr};
};
+class DrawWield : public RenderStep
+{
+public:
+ virtual void setRenderSource(RenderSource *) override {}
+ virtual void setRenderTarget(RenderTarget *target) override { m_target = target; }
+
+ virtual void reset(PipelineContext &context) override {}
+ virtual void run(PipelineContext &context) override;
+
+private:
+ RenderTarget *m_target {nullptr};
+};
+
/**
* Implements a pipeline step that renders the game HUD
*/
diff --git a/src/client/render/sidebyside.cpp b/src/client/render/sidebyside.cpp
index 7f199e17b..b02ac3b07 100644
--- a/src/client/render/sidebyside.cpp
+++ b/src/client/render/sidebyside.cpp
@@ -73,6 +73,7 @@ void populateSideBySidePipeline(RenderPipeline *pipeline, Client *client, bool h
auto output = pipeline->createOwned<TextureBufferOutput>(buffer, right ? TEXTURE_RIGHT : TEXTURE_LEFT);
pipeline->addStep<SetRenderTargetStep>(step3D, output);
pipeline->addStep(step3D);
+ pipeline->addStep<DrawWield>();
pipeline->addStep<MapPostFxStep>();
pipeline->addStep<DrawHUD>();
}