X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ffarmesh.cpp;h=bd08acadc3fd28133262d4ff80672d2976a9ff37;hb=43ebec2be1949aa5eac127df7cb902d37e4e461b;hp=2cd92243425c7d3c8a11212ac4288d882d291127;hpb=805ccd449fdd62e05083b71c1e035e5e7347c73a;p=minetest.git diff --git a/src/farmesh.cpp b/src/farmesh.cpp index 2cd922434..bd08acadc 100644 --- a/src/farmesh.cpp +++ b/src/farmesh.cpp @@ -3,16 +3,16 @@ Part of Minetest-c55 Copyright (C) 2011 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU Lesser General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ @@ -23,13 +23,16 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "farmesh.h" + #include "constants.h" #include "debug.h" #include "noise.h" #include "map.h" #include "client.h" +#include "tile.h" // ITextureSource +#include "clientmap.h" -#include "mapgen.h" +#include "mapgen.h" // Shouldn't really be done this way FarMesh::FarMesh( scene::ISceneNode* parent, @@ -47,7 +50,7 @@ FarMesh::FarMesh( { dstream<<__FUNCTION_NAME<getVideoDriver(); + //video::IVideoDriver* driver = mgr->getVideoDriver(); m_materials[0].setFlag(video::EMF_LIGHTING, false); m_materials[0].setFlag(video::EMF_BACK_FACE_CULLING, true); @@ -62,15 +65,13 @@ FarMesh::FarMesh( m_materials[1].setFlag(video::EMF_BACK_FACE_CULLING, false); m_materials[1].setFlag(video::EMF_BILINEAR_FILTER, false); m_materials[1].setFlag(video::EMF_FOG_ENABLE, false); - m_materials[1].setTexture - (0, driver->getTexture(getTexturePath("treeprop.png").c_str())); + m_materials[1].setTexture(0, client->tsrc()->getTextureRaw("treeprop.png")); m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; m_materials[1].setFlag(video::EMF_FOG_ENABLE, true); m_box = core::aabbox3d(-BS*1000000,-BS*31000,-BS*1000000, BS*1000000,BS*31000,BS*1000000); - trees = g_settings.getBool("farmesh_trees"); } FarMesh::~FarMesh() @@ -124,7 +125,7 @@ HeightPoint ground_height(u64 seed, v2s16 p2d) hp.ma = (4)*BS; /*hp.gh = BS*base_rock_level_2d(seed, p2d); hp.ma = BS*get_mud_add_amount(seed, p2d);*/ - hp.have_sand = mapgen::get_have_sand(seed, p2d); + hp.have_sand = mapgen::get_have_beach(seed, p2d); if(hp.gh > BS*WATER_LEVEL) hp.tree_amount = mapgen::tree_amount_2d(seed, p2d); else @@ -314,11 +315,12 @@ void FarMesh::render() } else { - // Trees if there are over 0.01 trees per MapNode - if(trees && tree_amount_avg > 0.01) + /*// Trees if there are over 0.01 trees per MapNode + if(tree_amount_avg > 0.01) c = video::SColor(255,50,128,50); else - c = video::SColor(255,107,134,51); + c = video::SColor(255,107,134,51);*/ + c = video::SColor(255,107,134,51); ground_is_mud = true; } } @@ -351,7 +353,7 @@ void FarMesh::render() video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT); // Add some trees if appropriate - if(trees && tree_amount_avg >= 0.0065 && steepness < 1.4 + if(tree_amount_avg >= 0.0065 && steepness < 1.4 && ground_is_mud == true) { driver->setMaterial(m_materials[1]); @@ -404,11 +406,11 @@ void FarMesh::step(float dtime) m_time += dtime; } -void FarMesh::update(v2f camera_p, float brightness) +void FarMesh::update(v2f camera_p, float brightness, s16 render_range) { m_camera_pos = camera_p; m_brightness = brightness; - m_render_range = g_settings.getS16("farmesh_distance")*10; + m_render_range = render_range; }