forked from oerkki/voxelands
remove texture size bias from blit: and plantgrowth
This commit is contained in:
parent
1983563d6d
commit
6b9d281ca1
|
@ -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;
|
||||
}
|
||||
|
|
17
src/tile.cpp
17
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<u32> dim = image->getDimension();
|
||||
core::dimension2d<u32> dim(X-x,Y-y);
|
||||
core::dimension2d<u32> bdim = baseimg->getDimension();
|
||||
core::dimension2d<u32> idim = image->getDimension();
|
||||
core::dimension2d<u32> dim((X-x)*(float)bdim.Width,(Y-y)*(float)bdim.Height);
|
||||
// Position to copy the blitted to in the base image
|
||||
core::position2d<s32> pos_to(x,y);
|
||||
core::position2d<s32> pos_to((float)bdim.Width*x,(float)bdim.Height*y);
|
||||
// Position to copy the blitted from in the blitted image
|
||||
core::position2d<s32> pos_from(x,y);
|
||||
core::position2d<s32> pos_from((float)idim.Width*x,(float)idim.Height*y);
|
||||
// Blit
|
||||
image->copyToWithAlpha(baseimg, pos_to,
|
||||
core::rect<s32>(pos_from, dim),
|
||||
|
|
Loading…
Reference in New Issue