Removed unused camera_position and camera_direction fields from Client. Moved ClientEnvironment::drawPostFx to ClientMap::renderPostFx -- this will make the camera management classes easier to write, as ClientMap already knows the camera position but ClientEnvironment doesn't and has to be told about it. This also eliminates the need for Client::getEnv(). Made the post effect color a content feature defined in content_mapnode.h.
parent
d28ea57083
commit
c0b35fa429
|
@ -189,8 +189,6 @@ Client::Client(
|
||||||
),
|
),
|
||||||
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
||||||
m_device(device),
|
m_device(device),
|
||||||
camera_position(0,0,0),
|
|
||||||
camera_direction(0,0,1),
|
|
||||||
m_server_ser_ver(SER_FMT_VER_INVALID),
|
m_server_ser_ver(SER_FMT_VER_INVALID),
|
||||||
m_inventory_updated(false),
|
m_inventory_updated(false),
|
||||||
m_time_of_day(0),
|
m_time_of_day(0),
|
||||||
|
@ -1983,8 +1981,11 @@ void Client::addNode(v3s16 p, MapNode n)
|
||||||
void Client::updateCamera(v3f pos, v3f dir)
|
void Client::updateCamera(v3f pos, v3f dir)
|
||||||
{
|
{
|
||||||
m_env.getClientMap().updateCamera(pos, dir);
|
m_env.getClientMap().updateCamera(pos, dir);
|
||||||
camera_position = pos;
|
}
|
||||||
camera_direction = dir;
|
|
||||||
|
void Client::renderPostFx()
|
||||||
|
{
|
||||||
|
m_env.getClientMap().renderPostFx();
|
||||||
}
|
}
|
||||||
|
|
||||||
MapNode Client::getNode(v3s16 p)
|
MapNode Client::getNode(v3s16 p)
|
||||||
|
@ -1998,6 +1999,11 @@ NodeMetadata* Client::getNodeMetadata(v3s16 p)
|
||||||
return m_env.getMap().getNodeMetadata(p);
|
return m_env.getMap().getNodeMetadata(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LocalPlayer* Client::getLocalPlayer()
|
||||||
|
{
|
||||||
|
return m_env.getLocalPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
v3f Client::getPlayerPosition(v3f *eye_position)
|
v3f Client::getPlayerPosition(v3f *eye_position)
|
||||||
{
|
{
|
||||||
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
|
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
|
||||||
|
|
20
src/client.h
20
src/client.h
|
@ -201,14 +201,16 @@ public:
|
||||||
|
|
||||||
void updateCamera(v3f pos, v3f dir);
|
void updateCamera(v3f pos, v3f dir);
|
||||||
|
|
||||||
|
void renderPostFx();
|
||||||
|
|
||||||
// Returns InvalidPositionException if not found
|
// Returns InvalidPositionException if not found
|
||||||
MapNode getNode(v3s16 p);
|
MapNode getNode(v3s16 p);
|
||||||
// Wrapper to Map
|
// Wrapper to Map
|
||||||
NodeMetadata* getNodeMetadata(v3s16 p);
|
NodeMetadata* getNodeMetadata(v3s16 p);
|
||||||
|
|
||||||
// Get the player position, and optionally put the
|
LocalPlayer* getLocalPlayer();
|
||||||
// eye position in *eye_position
|
|
||||||
v3f getPlayerPosition(v3f *eye_position=NULL);
|
v3f getPlayerPosition(v3f *eye_position);
|
||||||
|
|
||||||
void setPlayerControl(PlayerControl &control);
|
void setPlayerControl(PlayerControl &control);
|
||||||
|
|
||||||
|
@ -302,15 +304,6 @@ public:
|
||||||
{
|
{
|
||||||
return m_access_denied_reason;
|
return m_access_denied_reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
This should only be used for calling the special drawing stuff in
|
|
||||||
ClientEnvironment
|
|
||||||
*/
|
|
||||||
ClientEnvironment * getEnv()
|
|
||||||
{
|
|
||||||
return &m_env;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -342,9 +335,6 @@ private:
|
||||||
|
|
||||||
IrrlichtDevice *m_device;
|
IrrlichtDevice *m_device;
|
||||||
|
|
||||||
v3f camera_position;
|
|
||||||
v3f camera_direction;
|
|
||||||
|
|
||||||
// Server serialization version
|
// Server serialization version
|
||||||
u8 m_server_ser_ver;
|
u8 m_server_ser_ver;
|
||||||
|
|
||||||
|
|
|
@ -385,6 +385,7 @@ void content_mapnode_init()
|
||||||
f->liquid_alternative_source = CONTENT_WATERSOURCE;
|
f->liquid_alternative_source = CONTENT_WATERSOURCE;
|
||||||
f->liquid_viscosity = WATER_VISC;
|
f->liquid_viscosity = WATER_VISC;
|
||||||
f->vertex_alpha = WATER_ALPHA;
|
f->vertex_alpha = WATER_ALPHA;
|
||||||
|
f->post_effect_color = video::SColor(64, 100, 100, 200);
|
||||||
if(f->special_material == NULL && g_texturesource)
|
if(f->special_material == NULL && g_texturesource)
|
||||||
{
|
{
|
||||||
// Flowing water material
|
// Flowing water material
|
||||||
|
@ -433,6 +434,7 @@ void content_mapnode_init()
|
||||||
f->liquid_alternative_source = CONTENT_WATERSOURCE;
|
f->liquid_alternative_source = CONTENT_WATERSOURCE;
|
||||||
f->liquid_viscosity = WATER_VISC;
|
f->liquid_viscosity = WATER_VISC;
|
||||||
f->vertex_alpha = WATER_ALPHA;
|
f->vertex_alpha = WATER_ALPHA;
|
||||||
|
f->post_effect_color = video::SColor(64, 100, 100, 200);
|
||||||
if(f->special_material == NULL && g_texturesource)
|
if(f->special_material == NULL && g_texturesource)
|
||||||
{
|
{
|
||||||
// Flowing water material
|
// Flowing water material
|
||||||
|
@ -465,6 +467,7 @@ void content_mapnode_init()
|
||||||
f->liquid_alternative_source = CONTENT_LAVASOURCE;
|
f->liquid_alternative_source = CONTENT_LAVASOURCE;
|
||||||
f->liquid_viscosity = LAVA_VISC;
|
f->liquid_viscosity = LAVA_VISC;
|
||||||
f->damage_per_second = 4*2;
|
f->damage_per_second = 4*2;
|
||||||
|
f->post_effect_color = video::SColor(192, 255, 64, 0);
|
||||||
if(f->special_material == NULL && g_texturesource)
|
if(f->special_material == NULL && g_texturesource)
|
||||||
{
|
{
|
||||||
// Flowing lava material
|
// Flowing lava material
|
||||||
|
@ -514,6 +517,7 @@ void content_mapnode_init()
|
||||||
f->liquid_alternative_source = CONTENT_LAVASOURCE;
|
f->liquid_alternative_source = CONTENT_LAVASOURCE;
|
||||||
f->liquid_viscosity = LAVA_VISC;
|
f->liquid_viscosity = LAVA_VISC;
|
||||||
f->damage_per_second = 4*2;
|
f->damage_per_second = 4*2;
|
||||||
|
f->post_effect_color = video::SColor(192, 255, 64, 0);
|
||||||
if(f->special_material == NULL && g_texturesource)
|
if(f->special_material == NULL && g_texturesource)
|
||||||
{
|
{
|
||||||
// Flowing lava material
|
// Flowing lava material
|
||||||
|
|
|
@ -1940,29 +1940,6 @@ ClientEnvEvent ClientEnvironment::getClientEvent()
|
||||||
return m_client_event_queue.pop_front();
|
return m_client_event_queue.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientEnvironment::drawPostFx(video::IVideoDriver* driver, v3f camera_pos)
|
|
||||||
{
|
|
||||||
/*LocalPlayer *player = getLocalPlayer();
|
|
||||||
assert(player);
|
|
||||||
v3f pos_f = player->getPosition() + v3f(0,BS*1.625,0);*/
|
|
||||||
v3f pos_f = camera_pos;
|
|
||||||
v3s16 p_nodes = floatToInt(pos_f, BS);
|
|
||||||
MapNode n = m_map->getNodeNoEx(p_nodes);
|
|
||||||
if(n.getContent() == CONTENT_WATER || n.getContent() == CONTENT_WATERSOURCE)
|
|
||||||
{
|
|
||||||
v2u32 ss = driver->getScreenSize();
|
|
||||||
core::rect<s32> rect(0,0, ss.X, ss.Y);
|
|
||||||
driver->draw2DRectangle(video::SColor(64, 100, 100, 200), rect);
|
|
||||||
}
|
|
||||||
else if(content_features(n).solidness == 2 &&
|
|
||||||
g_settings.getBool("free_move") == false)
|
|
||||||
{
|
|
||||||
v2u32 ss = driver->getScreenSize();
|
|
||||||
core::rect<s32> rect(0,0, ss.X, ss.Y);
|
|
||||||
driver->draw2DRectangle(video::SColor(255, 0, 0, 0), rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #ifndef SERVER
|
#endif // #ifndef SERVER
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -406,9 +406,6 @@ public:
|
||||||
|
|
||||||
// Get event from queue. CEE_NONE is returned if queue is empty.
|
// Get event from queue. CEE_NONE is returned if queue is empty.
|
||||||
ClientEnvEvent getClientEvent();
|
ClientEnvEvent getClientEvent();
|
||||||
|
|
||||||
// Post effects
|
|
||||||
void drawPostFx(video::IVideoDriver* driver, v3f camera_pos);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ClientMap *m_map;
|
ClientMap *m_map;
|
||||||
|
|
16
src/game.cpp
16
src/game.cpp
|
@ -2032,7 +2032,7 @@ void the_game(
|
||||||
update_skybox(driver, smgr, skybox, brightness);
|
update_skybox(driver, smgr, skybox, brightness);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Update coulds
|
Update clouds
|
||||||
*/
|
*/
|
||||||
if(clouds)
|
if(clouds)
|
||||||
{
|
{
|
||||||
|
@ -2313,6 +2313,13 @@ void the_game(
|
||||||
driver->draw3DBox(*i, video::SColor(255,0,0,0));
|
driver->draw3DBox(*i, video::SColor(255,0,0,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Post effects
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
client.renderPostFx();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Frametime log
|
Frametime log
|
||||||
*/
|
*/
|
||||||
|
@ -2352,13 +2359,6 @@ void the_game(
|
||||||
// 0-1ms
|
// 0-1ms
|
||||||
guienv->drawAll();
|
guienv->drawAll();
|
||||||
|
|
||||||
/*
|
|
||||||
Environment post fx
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
client.getEnv()->drawPostFx(driver, camera_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Draw hotbar
|
Draw hotbar
|
||||||
*/
|
*/
|
||||||
|
|
29
src/map.cpp
29
src/map.cpp
|
@ -3925,6 +3925,35 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||||
<<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
|
<<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientMap::renderPostFx()
|
||||||
|
{
|
||||||
|
// Sadly ISceneManager has no "post effects" render pass, in that case we
|
||||||
|
// could just register for that and handle it in renderMap().
|
||||||
|
|
||||||
|
m_camera_mutex.Lock();
|
||||||
|
v3f camera_position = m_camera_position;
|
||||||
|
m_camera_mutex.Unlock();
|
||||||
|
|
||||||
|
MapNode n = getNodeNoEx(floatToInt(camera_position, BS));
|
||||||
|
|
||||||
|
// - If the player is in a solid node, make everything black.
|
||||||
|
// - If the player is in liquid, draw a semi-transparent overlay.
|
||||||
|
ContentFeatures& features = content_features(n);
|
||||||
|
video::SColor post_effect_color = features.post_effect_color;
|
||||||
|
if(features.solidness == 2 && g_settings.getBool("free_move") == false)
|
||||||
|
{
|
||||||
|
post_effect_color = video::SColor(255, 0, 0, 0);
|
||||||
|
}
|
||||||
|
if (post_effect_color.getAlpha() != 0)
|
||||||
|
{
|
||||||
|
// Draw a full-screen rectangle
|
||||||
|
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||||
|
v2u32 ss = driver->getScreenSize();
|
||||||
|
core::rect<s32> rect(0,0, ss.X, ss.Y);
|
||||||
|
driver->draw2DRectangle(post_effect_color, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ClientMap::setTempMod(v3s16 p, NodeMod mod,
|
bool ClientMap::setTempMod(v3s16 p, NodeMod mod,
|
||||||
core::map<v3s16, MapBlock*> *affected_blocks)
|
core::map<v3s16, MapBlock*> *affected_blocks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -552,6 +552,8 @@ public:
|
||||||
|
|
||||||
void renderMap(video::IVideoDriver* driver, s32 pass);
|
void renderMap(video::IVideoDriver* driver, s32 pass);
|
||||||
|
|
||||||
|
void renderPostFx();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Methods for setting temporary modifications to nodes for
|
Methods for setting temporary modifications to nodes for
|
||||||
drawing.
|
drawing.
|
||||||
|
|
|
@ -160,6 +160,8 @@ struct ContentFeatures
|
||||||
u8 liquid_viscosity;
|
u8 liquid_viscosity;
|
||||||
// Used currently for flowing liquids
|
// Used currently for flowing liquids
|
||||||
u8 vertex_alpha;
|
u8 vertex_alpha;
|
||||||
|
// Post effect color, drawn when the camera is inside the node.
|
||||||
|
video::SColor post_effect_color;
|
||||||
// Special irrlicht material, used sometimes
|
// Special irrlicht material, used sometimes
|
||||||
video::SMaterial *special_material;
|
video::SMaterial *special_material;
|
||||||
AtlasPointer *special_atlas;
|
AtlasPointer *special_atlas;
|
||||||
|
@ -197,6 +199,7 @@ struct ContentFeatures
|
||||||
liquid_alternative_source = CONTENT_IGNORE;
|
liquid_alternative_source = CONTENT_IGNORE;
|
||||||
liquid_viscosity = 0;
|
liquid_viscosity = 0;
|
||||||
vertex_alpha = 255;
|
vertex_alpha = 255;
|
||||||
|
post_effect_color = video::SColor(0, 0, 0, 0);
|
||||||
special_material = NULL;
|
special_material = NULL;
|
||||||
special_atlas = NULL;
|
special_atlas = NULL;
|
||||||
light_source = 0;
|
light_source = 0;
|
||||||
|
|
Loading…
Reference in New Issue