summaryrefslogtreecommitdiff
path: root/src/drawscene.cpp
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2016-02-07 04:08:43 +0100
committerkwolekr <kwolekr@minetest.net>2016-02-08 03:57:42 -0500
commitb44da4916aa09b27155ce6675cccbcc128b5a66c (patch)
treebe51c3a097e1371cb126bf1516e81aaad20bb768 /src/drawscene.cpp
parent430195381d8d7254a7b8cdcf6b50769c2c598329 (diff)
downloadminetest-b44da4916aa09b27155ce6675cccbcc128b5a66c.tar.gz
minetest-b44da4916aa09b27155ce6675cccbcc128b5a66c.tar.bz2
minetest-b44da4916aa09b27155ce6675cccbcc128b5a66c.zip
Cleanup selection mesh code, add shaders for halo and selection boxes
Diffstat (limited to 'src/drawscene.cpp')
-rw-r--r--src/drawscene.cpp120
1 files changed, 45 insertions, 75 deletions
diff --git a/src/drawscene.cpp b/src/drawscene.cpp
index c716ca0d4..32eafeb29 100644
--- a/src/drawscene.cpp
+++ b/src/drawscene.cpp
@@ -31,27 +31,9 @@ typedef enum {
EYECOUNT = 2
} paralax_sign;
-
-void draw_selectionbox(video::IVideoDriver* driver, Hud& hud,
- std::vector<aabb3f>& hilightboxes, bool show_hud)
-{
- static const s16 selectionbox_width = rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
-
- if (!show_hud)
- return;
-
- video::SMaterial oldmaterial = driver->getMaterial2D();
- video::SMaterial m;
- m.Thickness = selectionbox_width;
- m.Lighting = false;
- driver->setMaterial(m);
- hud.drawSelectionBoxes(hilightboxes);
- driver->setMaterial(oldmaterial);
-}
-
void draw_anaglyph_3d_mode(Camera& camera, bool show_hud, Hud& hud,
- std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
- scene::ISceneManager* smgr, bool draw_wield_tool, Client& client,
+ video::IVideoDriver* driver, scene::ISceneManager* smgr,
+ bool draw_wield_tool, Client& client,
gui::IGUIEnvironment* guienv )
{
@@ -85,10 +67,8 @@ void draw_anaglyph_3d_mode(Camera& camera, bool show_hud, Hud& hud,
camera.getCameraNode()->setTarget(focusPoint);
smgr->drawAll();
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
- if (show_hud)
- {
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
+ if (show_hud) {
+ hud.drawSelectionMesh();
if (draw_wield_tool)
camera.drawWieldedTool(&leftMove);
}
@@ -115,10 +95,8 @@ void draw_anaglyph_3d_mode(Camera& camera, bool show_hud, Hud& hud,
camera.getCameraNode()->setTarget(focusPoint);
smgr->drawAll();
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
- if (show_hud)
- {
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
+ if (show_hud) {
+ hud.drawSelectionMesh();
if (draw_wield_tool)
camera.drawWieldedTool(&rightMove);
}
@@ -144,16 +122,15 @@ void init_texture(video::IVideoDriver* driver, const v2u32& screensize,
irr::video::ECF_A8R8G8B8);
}
-video::ITexture* draw_image(const v2u32& screensize,
- paralax_sign psign, const irr::core::matrix4& startMatrix,
- const irr::core::vector3df& focusPoint, bool show_hud,
- video::IVideoDriver* driver, Camera& camera, scene::ISceneManager* smgr,
- Hud& hud, std::vector<aabb3f>& hilightboxes,
- bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
- video::SColor skycolor )
+video::ITexture* draw_image(const v2u32 &screensize,
+ paralax_sign psign, const irr::core::matrix4 &startMatrix,
+ const irr::core::vector3df &focusPoint, bool show_hud,
+ video::IVideoDriver *driver, Camera &camera, scene::ISceneManager *smgr,
+ Hud &hud, bool draw_wield_tool, Client &client,
+ gui::IGUIEnvironment *guienv, const video::SColor &skycolor)
{
static video::ITexture* images[2] = { NULL, NULL };
- static v2u32 last_screensize = v2u32(0,0);
+ static v2u32 last_screensize = v2u32(0, 0);
video::ITexture* image = NULL;
@@ -187,10 +164,8 @@ video::ITexture* draw_image(const v2u32& screensize,
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
- if (show_hud)
- {
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
+ if (show_hud) {
+ hud.drawSelectionMesh();
if (draw_wield_tool)
camera.drawWieldedTool(&movement);
}
@@ -232,7 +207,7 @@ video::ITexture* draw_hud(video::IVideoDriver* driver, const v2u32& screensize,
}
void draw_interlaced_3d_mode(Camera& camera, bool show_hud,
- Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
+ Hud& hud, video::IVideoDriver* driver,
scene::ISceneManager* smgr, const v2u32& screensize,
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
video::SColor skycolor )
@@ -248,7 +223,7 @@ void draw_interlaced_3d_mode(Camera& camera, bool show_hud,
/* create left view */
video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix,
- focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
+ focusPoint, show_hud, driver, camera, smgr, hud,
draw_wield_tool, client, guienv, skycolor);
//Right eye...
@@ -267,10 +242,8 @@ void draw_interlaced_3d_mode(Camera& camera, bool show_hud,
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
- if (show_hud)
- {
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
+ if (show_hud) {
+ hud.drawSelectionMesh();
if(draw_wield_tool)
camera.drawWieldedTool(&rightMove);
}
@@ -293,7 +266,7 @@ void draw_interlaced_3d_mode(Camera& camera, bool show_hud,
}
void draw_sidebyside_3d_mode(Camera& camera, bool show_hud,
- Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
+ Hud& hud, video::IVideoDriver* driver,
scene::ISceneManager* smgr, const v2u32& screensize,
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
video::SColor skycolor )
@@ -309,12 +282,12 @@ void draw_sidebyside_3d_mode(Camera& camera, bool show_hud,
/* create left view */
video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix,
- focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
+ focusPoint, show_hud, driver, camera, smgr, hud,
draw_wield_tool, client, guienv, skycolor);
/* create right view */
video::ITexture* right_image = draw_image(screensize, RIGHT, startMatrix,
- focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
+ focusPoint, show_hud, driver, camera, smgr, hud,
draw_wield_tool, client, guienv, skycolor);
/* create hud overlay */
@@ -349,7 +322,7 @@ void draw_sidebyside_3d_mode(Camera& camera, bool show_hud,
}
void draw_top_bottom_3d_mode(Camera& camera, bool show_hud,
- Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
+ Hud& hud, video::IVideoDriver* driver,
scene::ISceneManager* smgr, const v2u32& screensize,
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
video::SColor skycolor )
@@ -365,12 +338,12 @@ void draw_top_bottom_3d_mode(Camera& camera, bool show_hud,
/* create left view */
video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix,
- focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
+ focusPoint, show_hud, driver, camera, smgr, hud,
draw_wield_tool, client, guienv, skycolor);
/* create right view */
video::ITexture* right_image = draw_image(screensize, RIGHT, startMatrix,
- focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
+ focusPoint, show_hud, driver, camera, smgr, hud,
draw_wield_tool, client, guienv, skycolor);
/* create hud overlay */
@@ -405,7 +378,7 @@ void draw_top_bottom_3d_mode(Camera& camera, bool show_hud,
}
void draw_pageflip_3d_mode(Camera& camera, bool show_hud,
- Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
+ Hud& hud, video::IVideoDriver* driver,
scene::ISceneManager* smgr, const v2u32& screensize,
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
video::SColor skycolor)
@@ -438,11 +411,9 @@ void draw_pageflip_3d_mode(Camera& camera, bool show_hud,
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (show_hud) {
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
+ hud.drawSelectionMesh();
if (draw_wield_tool)
camera.drawWieldedTool(&leftMove);
-
hud.drawHotbar(client.getPlayerItem());
hud.drawLuaElements(camera.getOffset());
}
@@ -467,11 +438,9 @@ void draw_pageflip_3d_mode(Camera& camera, bool show_hud,
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (show_hud) {
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
+ hud.drawSelectionMesh();
if (draw_wield_tool)
camera.drawWieldedTool(&rightMove);
-
hud.drawHotbar(client.getPlayerItem());
hud.drawLuaElements(camera.getOffset());
}
@@ -482,23 +451,24 @@ void draw_pageflip_3d_mode(Camera& camera, bool show_hud,
camera.getCameraNode()->setTarget(oldTarget);
}
-void draw_plain(Camera& camera, bool show_hud, Hud& hud,
- std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
- bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv)
+void draw_plain(Camera &camera, bool show_hud, Hud &hud,
+ video::IVideoDriver *driver, bool draw_wield_tool,
+ Client &client, gui::IGUIEnvironment *guienv)
{
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
-
- draw_selectionbox(driver, hud, hilightboxes, show_hud);
-
- if(draw_wield_tool)
- camera.drawWieldedTool();
+ if (show_hud) {
+ hud.drawSelectionMesh();
+ if (draw_wield_tool) {
+ camera.drawWieldedTool();
+ }
+ }
}
void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr,
Camera &camera, Client& client, LocalPlayer *player, Hud &hud,
Mapper &mapper, gui::IGUIEnvironment *guienv,
- std::vector<aabb3f> hilightboxes, const v2u32 &screensize,
- video::SColor skycolor, bool show_hud, bool show_minimap)
+ const v2u32 &screensize, const video::SColor &skycolor,
+ bool show_hud, bool show_minimap)
{
TimeTaker timer("smgr");
@@ -522,37 +492,37 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr,
if (draw_mode == "anaglyph")
{
- draw_anaglyph_3d_mode(camera, show_hud, hud, hilightboxes, driver,
+ draw_anaglyph_3d_mode(camera, show_hud, hud, driver,
smgr, draw_wield_tool, client, guienv);
draw_crosshair = false;
}
else if (draw_mode == "interlaced")
{
- draw_interlaced_3d_mode(camera, show_hud, hud, hilightboxes, driver,
+ draw_interlaced_3d_mode(camera, show_hud, hud, driver,
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
draw_crosshair = false;
}
else if (draw_mode == "sidebyside")
{
- draw_sidebyside_3d_mode(camera, show_hud, hud, hilightboxes, driver,
+ draw_sidebyside_3d_mode(camera, show_hud, hud, driver,
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
show_hud = false;
}
else if (draw_mode == "topbottom")
{
- draw_top_bottom_3d_mode(camera, show_hud, hud, hilightboxes, driver,
+ draw_top_bottom_3d_mode(camera, show_hud, hud, driver,
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
show_hud = false;
}
else if (draw_mode == "pageflip")
{
- draw_pageflip_3d_mode(camera, show_hud, hud, hilightboxes, driver,
+ draw_pageflip_3d_mode(camera, show_hud, hud, driver,
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
draw_crosshair = false;
show_hud = false;
}
else {
- draw_plain(camera, show_hud, hud, hilightboxes, driver,
+ draw_plain(camera, show_hud, hud, driver,
draw_wield_tool, client, guienv);
}