From 6b9d281ca1339e00e4f833c2e8a5e5c638cdce40 Mon Sep 17 00:00:00 2001 From: darkrose Date: Thu, 4 Jun 2015 22:26:07 +1000 Subject: [PATCH] remove texture size bias from blit: and plantgrowth --- src/mapblock_mesh.cpp | 5 ++--- src/tile.cpp | 17 +++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index f6b102e..66b6303 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -189,10 +189,9 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, NodeModMap &temp_mods, if (f->param2_type != CPT_PLANTGROWTH || !mn.param2) { texture_name += "^"+orig_name; }else{ - // TODO: this is assuming 16x16 textures std::string bs("^[blit:0,"); - bs += itos(16-mn.param2); - bs += ",16,16,"; + bs += ftos(1.0-(0.0625*(float)mn.param2)); + bs += ",1,1,"; // new name texture_name += bs+orig_name; } diff --git a/src/tile.cpp b/src/tile.cpp index 207352a..e071d3a 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -1801,10 +1801,10 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, // Size of the copied area Strfnd sf(part_of_name); sf.next(":"); - int x = mystoi(sf.next(",")); - int y = mystoi(sf.next(",")); - int X = mystoi(sf.next(",")); - int Y = mystoi(sf.next(",")); + float x = mystof(sf.next(",")); + float y = mystof(sf.next(",")); + float X = mystof(sf.next(",")); + float Y = mystof(sf.next(",")); std::string path = sf.end(); path = getTexturePath(path.c_str()); video::IImage *image = driver->createImageFromFile(path.c_str()); @@ -1821,12 +1821,13 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, << "\", cancelling." << std::endl; return false; } - //core::dimension2d dim = image->getDimension(); - core::dimension2d dim(X-x,Y-y); + core::dimension2d bdim = baseimg->getDimension(); + core::dimension2d idim = image->getDimension(); + core::dimension2d dim((X-x)*(float)bdim.Width,(Y-y)*(float)bdim.Height); // Position to copy the blitted to in the base image - core::position2d pos_to(x,y); + core::position2d pos_to((float)bdim.Width*x,(float)bdim.Height*y); // Position to copy the blitted from in the blitted image - core::position2d pos_from(x,y); + core::position2d pos_from((float)idim.Width*x,(float)idim.Height*y); // Blit image->copyToWithAlpha(baseimg, pos_to, core::rect(pos_from, dim),