From 626ed6338aa90eb07038adee29643e692fec6545 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 14 Dec 2010 00:21:18 +0200 Subject: in before messing with face drawing orientation --- src/map.cpp | 196 ++---------------------------------------------------------- 1 file changed, 4 insertions(+), 192 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index f9adbd00a..213404a07 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1504,7 +1504,8 @@ MapSector * ServerMap::emergeSector(v2s16 p2d) sector->setHeightmap(p_in_sector, hm); //TODO: Make these values configurable - hm->generateContinued(0.0, 0.0, corners); + //hm->generateContinued(0.0, 0.0, corners); + hm->generateContinued(0.5, 0.2, corners); //hm->generateContinued(1.0, 0.2, corners); //hm->generateContinued(2.0, 0.2, corners); @@ -2755,7 +2756,6 @@ void ServerMap::PrintInfo(std::ostream &out) ClientMap::ClientMap( Client *client, - video::SMaterial *materials, scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id @@ -2763,7 +2763,6 @@ ClientMap::ClientMap( Map(dout_client), scene::ISceneNode(parent, mgr, id), m_client(client), - m_materials(materials), mesh(NULL) { /*m_box = core::aabbox3d(0,0,0, @@ -2837,8 +2836,7 @@ void ClientMap::deSerializeSector(v2s16 p2d, std::istream &is) sector->deSerialize(is); } -void ClientMap::renderMap(video::IVideoDriver* driver, - video::SMaterial *materials, s32 pass) +void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) { //m_dout<::Iterator - si = m_sectors.getIterator(); - si.atEnd() == false; si++) - { - MapSector *sector = si.getNode()->getValue(); - - if(sector->getId() != MAPSECTOR_CLIENT) - { - dstream<<"WARNING: Client has a non-client sector" - <getPos(); - - if(sp.X < p_blocks_min.X - || sp.X > p_blocks_max.X - || sp.Y < p_blocks_min.Z - || sp.Y > p_blocks_max.Z) - continue; - - /* - Get some ground level info - */ - - s16 a = -5; - - s16 cn[4] = - { - cs->getCorner(0)+a, - cs->getCorner(1)+a, - cs->getCorner(2)+a, - cs->getCorner(3)+a, - }; - s16 cn_avg = (cn[0]+cn[1]+cn[2]+cn[3])/4; - s16 cn_min = 32767; - s16 cn_max = -32768; - for(s16 i=0; i<4; i++) - { - if(cn[i] < cn_min) - cn_min = cn[i]; - if(cn[i] > cn_max) - cn_max = cn[i]; - } - s16 cn_slope = cn_max - cn_min; - - /* - Generate this part of the heightmap mesh - */ - - u8 material; - if(cn_avg + MAP_BLOCKSIZE/4 <= WATER_LEVEL) - material = 0; - else if(cn_slope <= MAP_BLOCKSIZE) - material = 1; - else - material = 2; - - if(material != material_in_use || buf == NULL) - { - // Try to get a meshbuffer associated with the material - buf = (scene::SMeshBuffer*)mesh_new->getMeshBuffer - (g_mesh_materials[material]); - // If not found, create one - if(buf == NULL) - { - // This is a "Standard MeshBuffer", - // it's a typedeffed CMeshBuffer - buf = new scene::SMeshBuffer(); - - // Set material - buf->Material = g_mesh_materials[material]; - // Use VBO - //buf->setHardwareMappingHint(scene::EHM_STATIC); - // Add to mesh - mesh_new->addMeshBuffer(buf); - // Mesh grabbed it - buf->drop(); - } - material_in_use = material; - } - - // Sector side width in floating-point units - f32 sd = BS * MAP_BLOCKSIZE; - // Sector position in global floating-point units - v3f spf = v3f((f32)sp.X, 0, (f32)sp.Y) * sd; - - //video::SColor c(255,255,255,255); - u8 cc = 180; - video::SColor c(255,cc,cc,cc); - - video::S3DVertex vertices[4] = - { - video::S3DVertex(spf.X, (f32)BS*cn[0],spf.Z, 0,0,0, c, 0,1), - video::S3DVertex(spf.X+sd,(f32)BS*cn[1],spf.Z, 0,0,0, c, 1,1), - video::S3DVertex(spf.X+sd,(f32)BS*cn[2],spf.Z+sd,0,0,0, c, 1,0), - video::S3DVertex(spf.X, (f32)BS*cn[3],spf.Z+sd,0,0,0, c, 0,0), - }; - u16 indices[] = {0,1,2,2,3,0}; - - buf->append(vertices, 4, indices, 6); - } - - // Set VBO on - //mesh_new->setHardwareMappingHint(scene::EHM_STATIC); - - /* - Replace the mesh - */ - - mesh_mutex.Lock(); - - scene::SMesh *mesh_old = mesh; - - //DEBUG - /*mesh = NULL; - mesh_new->drop();*/ - mesh = mesh_new; - - mesh_mutex.Unlock(); - - if(mesh_old != NULL) - { - /*dstream<<"mesh_old refcount="<getReferenceCount() - <getMeshBuffer - (g_materials[CONTENT_GRASS]); - if(buf != NULL) - dstream<<"grass buf refcount="<getReferenceCount() - <drop(); - } - else - { - dstream<<"WARNING: There was no old master heightmap mesh"<