#include "profiler.h"
#include "settings.h"
#include "camera.h" // CameraModes
-#include "util/mathconstants.h"
#include "util/basic_macros.h"
#include <algorithm>
ClientMap::ClientMap(
Client *client,
- IGameDef *gamedef,
MapDrawControl &control,
scene::ISceneNode* parent,
scene::ISceneManager* mgr,
s32 id
):
- Map(dout_client, gamedef),
+ Map(dout_client, client),
scene::ISceneNode(parent, mgr, id),
m_client(client),
m_control(control),
return false;
}
-void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes,
+void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes,
v3s16 *p_blocks_min, v3s16 *p_blocks_max)
{
v3s16 box_nodes_d = m_control.wanted_range * v3s16(1, 1, 1);
ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);
g_profiler->add("CM::updateDrawList() count", 1);
- INodeDefManager *nodemgr = m_gamedef->ndef();
-
for (std::map<v3s16, MapBlock*>::iterator i = m_drawlist.begin();
i != m_drawlist.end(); ++i) {
MapBlock *block = i->second;
if (g_settings->getBool("free_move")) {
MapNode n = getNodeNoEx(cam_pos_nodes);
if (n.getContent() == CONTENT_IGNORE ||
- nodemgr->get(n).solidness == 2)
+ m_nodedef->get(n).solidness == 2)
occlusion_culling_enabled = false;
}
if (occlusion_culling_enabled &&
// For the central point of the mapblock 'endoff' can be halved
isOccluded(this, spn, cpn,
- step, stepfac, startoff, endoff / 2.0f, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff / 2.0f, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr) &&
+ step, stepfac, startoff, endoff, needed_count, m_nodedef) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2),
- step, stepfac, startoff, endoff, needed_count, nodemgr)) {
+ step, stepfac, startoff, endoff, needed_count, m_nodedef)) {
blocks_occlusion_culled++;
continue;
}
void add(scene::IMeshBuffer *buf)
{
+ const video::SMaterial &m = buf->getMaterial();
for(std::vector<MeshBufList>::iterator i = lists.begin();
i != lists.end(); ++i){
MeshBufList &l = *i;
- video::SMaterial &m = buf->getMaterial();
// comparing a full material is quite expensive so we don't do it if
// not even first texture is equal
}
}
MeshBufList l;
- l.m = buf->getMaterial();
+ l.m = m;
l.bufs.push_back(buf);
lists.push_back(l);
}
{
scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
- buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
- buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
- buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
- buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
-
- const video::SMaterial& material = buf->getMaterial();
+ video::SMaterial& material = buf->getMaterial();
video::IMaterialRenderer* rnd =
driver->getMaterialRenderer(material.MaterialType);
bool transparent = (rnd && rnd->isTransparent());
if (buf->getVertexCount() == 0)
errorstream << "Block [" << analyze_block(block)
<< "] contains an empty meshbuf" << std::endl;
+
+ material.setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
+ material.setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
+ material.setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
+ material.setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
+
drawbufs.add(buf);
}
}
int oldvalue, bool *sunlight_seen_result)
{
const bool debugprint = false;
- INodeDefManager *ndef = m_gamedef->ndef();
static v3f z_directions[50] = {
v3f(-100, 0, 0)
};
float off = step * z_offsets[i];
bool sunlight_seen_now = false;
bool ok = getVisibleBrightness(this, m_camera_position, dir,
- step, 1.0, max_d*0.6+off, max_d, ndef, daylight_factor,
+ step, 1.0, max_d*0.6+off, max_d, m_nodedef, daylight_factor,
sunlight_min_d,
&br, &sunlight_seen_now);
if(sunlight_seen_now)
int ret = 0;
if(brightness_count == 0){
MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS));
- if(ndef->get(n).param_type == CPT_LIGHT){
- ret = decode_light(n.getLightBlend(daylight_factor, ndef));
+ if(m_nodedef->get(n).param_type == CPT_LIGHT){
+ ret = decode_light(n.getLightBlend(daylight_factor, m_nodedef));
} else {
ret = oldvalue;
}
void ClientMap::renderPostFx(CameraMode cam_mode)
{
- INodeDefManager *nodemgr = m_gamedef->ndef();
-
// Sadly ISceneManager has no "post effects" render pass, in that case we
// could just register for that and handle it in renderMap().
// - If the player is in a solid node, make everything black.
// - If the player is in liquid, draw a semi-transparent overlay.
// - Do not if player is in third person mode
- const ContentFeatures& features = nodemgr->get(n);
+ const ContentFeatures& features = m_nodedef->get(n);
video::SColor post_effect_color = features.post_effect_color;
if(features.solidness == 2 && !(g_settings->getBool("noclip") &&
- m_gamedef->checkLocalPrivilege("noclip")) &&
+ m_client->checkLocalPrivilege("noclip")) &&
cam_mode == CAMERA_MODE_FIRST)
{
post_effect_color = video::SColor(255, 0, 0, 0);