++Performance;
This commit is contained in:
		| @@ -7,24 +7,33 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) { | ||||
|     std::ifstream input(pos.str(), std::fstream::binary); | ||||
|  | ||||
|     if (input.fail()) { | ||||
|         OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(PERLIN_SEED); | ||||
|         OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(SEED); | ||||
|         m_blocks.Reset(BTYPE_AIR); | ||||
|  | ||||
|         for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes | ||||
|             for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) { | ||||
|                 float xnoiz, ynoiz; | ||||
|                 xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 256.; | ||||
|                 ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 256.; | ||||
|                 float height = (simplex.eval(xnoiz, ynoiz)) * 60.f + 5.f; | ||||
|                 xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 1024.; | ||||
|                 ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 1024.; | ||||
|                 double height = 0; | ||||
|                 for (int x = 0; x < 39; ++x) { | ||||
|                     height += simplex.eval(xnoiz, ynoiz); | ||||
|                     height *= .79; | ||||
|                     xnoiz *= 1.139; | ||||
|                     ynoiz *= 1.139; | ||||
|                 } | ||||
|                 height = height * 2000. * simplex.eval((double)(ix + x * CHUNK_SIZE_X) / 512., (double)(iz + y * CHUNK_SIZE_Z) / 512.); | ||||
|                 height /= (CHUNK_SIZE_Y / 1.9); | ||||
|                 height += 15.; | ||||
|                 for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) | ||||
|                     SetBlock(ix, iy, iz, BTYPE_METAL, nullptr); | ||||
|             } | ||||
|         for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines | ||||
|             for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) { | ||||
|                 float xnoiz, ynoiz; | ||||
|                 xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 64.; | ||||
|                 ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 64.; | ||||
|                 float height = simplex.eval(xnoiz, ynoiz) * 5.f + 24.f; | ||||
|                 xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 512.; | ||||
|                 ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 512.; | ||||
|                 float height = simplex.eval(xnoiz, ynoiz) * 50.f;// +1.f; | ||||
|                 for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) { | ||||
|                     if (GetBlock(ix, iy, iz) == BTYPE_AIR) | ||||
|                         SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr); | ||||
| @@ -32,26 +41,26 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) { | ||||
|             } | ||||
|         for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Lacs" | ||||
|             for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) { | ||||
|                 for (int iy = 0; iy < 16; ++iy) { | ||||
|                 for (int iy = 0; iy < 13; ++iy) { | ||||
|                     if (GetBlock(ix, iy, iz) == BTYPE_AIR) | ||||
|                         SetBlock(ix, iy, iz, BTYPE_ICE, nullptr); | ||||
|                 } | ||||
|             } | ||||
|         for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Arbres" | ||||
|             for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) { | ||||
|                 float xnoiz, ynoiz; | ||||
|                 xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / 256.; | ||||
|                 ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / 256.; | ||||
|                 bool tree = (int)(abs(simplex.eval(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false; | ||||
|                 for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy) | ||||
|                     if (GetBlock(ix, iy, iz) == BTYPE_AIR) | ||||
|                         if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS) | ||||
|                             if (tree) { | ||||
|                                 for (int i = 0; i < (int)(abs(simplex.eval(xnoiz, ynoiz) * 65)) % 42 + 1; ++i) | ||||
|                                     SetBlock(ix, iy + i, iz, BTYPE_DIRT, nullptr); | ||||
|                                 break; | ||||
|                             } | ||||
|             } | ||||
|         //for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Arbres" | ||||
|         //    for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) { | ||||
|         //        float xnoiz, ynoiz; | ||||
|         //        xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / 256.; | ||||
|         //        ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / 256.; | ||||
|         //        bool tree = (int)(abs(simplex.eval(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false; | ||||
|         //        for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy) | ||||
|         //            if (GetBlock(ix, iy, iz) == BTYPE_AIR) | ||||
|         //                if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS) | ||||
|         //                    if (tree) { | ||||
|         //                        for (int i = 0; i < (int)(abs(simplex.eval(xnoiz, ynoiz) * 4)) % 42 + 1; ++i) | ||||
|         //                            SetBlock(ix, iy + i, iz, BTYPE_DIRT, nullptr); | ||||
|         //                        break; | ||||
|         //                    } | ||||
|         //    } | ||||
|     } | ||||
|     else { | ||||
|         input.seekg(0, std::ios_base::end); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user