Merge remote-tracking branch 'minetest/master'
Conflicts: CMakeLists.txt README.txt src/CMakeLists.txt src/tile.cppmaster
commit
bf6b890cb7
|
@ -208,11 +208,17 @@ if(WIN32)
|
|||
ERROR_QUIET)
|
||||
|
||||
if(VERSION_GITHASH)
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_GITHASH}-win32")
|
||||
set(PROJECT_VERSION ${VERSION_GITHASH})
|
||||
else()
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
|
||||
set(PROJECT_VERSION ${VERSION_STRING})
|
||||
endif()
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win64")
|
||||
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win32")
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
|
||||
# This might be needed for some installer
|
||||
|
|
|
@ -18,9 +18,10 @@ ogg_version=1.2.1
|
|||
vorbis_version=1.3.3
|
||||
curl_version=7.18.0
|
||||
gettext_version=0.14.4
|
||||
freetype_version=2.3.5-1
|
||||
freetype_version=2.3.5
|
||||
luajit_version=2.0.1
|
||||
leveldb_version=1.15
|
||||
zlib_version=1.2.8
|
||||
|
||||
mkdir -p $packagedir
|
||||
mkdir -p $libdir
|
||||
|
@ -30,10 +31,8 @@ cd $builddir
|
|||
# Get stuff
|
||||
[ -e $packagedir/irrlicht-$irrlicht_version.zip ] || wget http://sfan5.pf-control.de/irrlicht-$irrlicht_version-win32.zip \
|
||||
-c -O $packagedir/irrlicht-$irrlicht_version.zip
|
||||
[ -e $packagedir/zlib125.zip ] || wget http://www.winimage.com/zLibDll/zlib125.zip \
|
||||
-c -O $packagedir/zlib125.zip
|
||||
[ -e $packagedir/zlib125dll.zip ] || wget http://www.winimage.com/zLibDll/zlib125dll.zip \
|
||||
-c -O $packagedir/zlib125dll.zip
|
||||
[ -e $packagedir/zlib-$zlib_version.zip ] || wget http://sfan5.pf-control.de/zlib-$zlib_version-win32.zip \
|
||||
-c -O $packagedir/zlib-$zlib_version.zip
|
||||
[ -e $packagedir/libogg-$ogg_version-dev.7z ] || wget http://sfan5.pf-control.de/libogg-$ogg_version-dev.7z \
|
||||
-c -O $packagedir/libogg-$ogg_version-dev.7z
|
||||
[ -e $packagedir/libogg-$ogg_version-dll.7z ] || wget http://sfan5.pf-control.de/libogg-$ogg_version-dll.7z \
|
||||
|
@ -46,29 +45,26 @@ cd $builddir
|
|||
-c -O $packagedir/libcurl-$curl_version-win32-msvc.zip
|
||||
[ -e $packagedir/gettext-$gettext_version.zip ] || wget http://sfan5.pf-control.de/gettext-$gettext_version.zip \
|
||||
-c -O $packagedir/gettext-$gettext_version.zip
|
||||
[ -e $packagedir/freetype-$freetype_version.zip ] || wget http://sfan5.pf-control.de/freetype-$freetype_version.zip \
|
||||
-c -O $packagedir/freetype-$freetype_version.zip
|
||||
[ -e $packagedir/libfreetype-$freetype_version.zip ] || wget http://sfan5.pf-control.de/libfreetype-$freetype_version-win32.zip \
|
||||
-c -O $packagedir/libfreetype-$freetype_version.zip
|
||||
[ -e $packagedir/luajit-$luajit_version-static-win32.zip ] || wget http://sfan5.pf-control.de/luajit-$luajit_version-static-win32.zip \
|
||||
-c -O $packagedir/luajit-$luajit_version-static-win32.zip
|
||||
[ -e $packagedir/libleveldb-$leveldb_version-win32.zip ] || wget http://sfan5.pf-control.de/libleveldb-$leveldb_version-win32.zip \
|
||||
-c -O $packagedir/libleveldb-$leveldb_version-win32.zip
|
||||
[ -e $packagedir/openal_stripped.zip ] || wget http://minetest.ru/bin/openal_stripped.zip \
|
||||
[ -e $packagedir/openal_stripped.zip ] || wget http://sfan5.pf-control.de/openal_stripped.zip \
|
||||
-c -O $packagedir/openal_stripped.zip
|
||||
[ -e $packagedir/mingwm10.dll ] || wget http://minetest.ru/bin/mingwm10.dll \
|
||||
-c -O $packagedir/mingwm10.dll
|
||||
|
||||
# Extract stuff
|
||||
cd $libdir
|
||||
[ -d irrlicht-$irrlicht_version ] || unzip -o $packagedir/irrlicht-$irrlicht_version.zip
|
||||
[ -d zlib-1.2.5 ] || unzip -o $packagedir/zlib125.zip
|
||||
[ -d zlib125dll ] || unzip -o $packagedir/zlib125dll.zip -d zlib125dll
|
||||
[ -d zlib ] || unzip -o $packagedir/zlib-$zlib_version.zip -d zlib
|
||||
[ -d libogg/include ] || 7z x -y -olibogg $packagedir/libogg-$ogg_version-dev.7z
|
||||
[ -d libogg/bin ] || 7z x -y -olibogg $packagedir/libogg-$ogg_version-dll.7z
|
||||
[ -d libvorbis/include ] || 7z x -y -olibvorbis $packagedir/libvorbis-$vorbis_version-dev.7z
|
||||
[ -d libvorbis/bin ] || 7z x -y -olibvorbis $packagedir/libvorbis-$vorbis_version-dll.7z
|
||||
[ -d libcurl ] || unzip -o $packagedir/libcurl-$curl_version-win32-msvc.zip -d libcurl
|
||||
[ -d gettext ] || unzip -o $packagedir/gettext-$gettext_version.zip -d gettext
|
||||
[ -d freetype ] || unzip -o $packagedir/freetype-$freetype_version.zip -d freetype
|
||||
[ -d freetype ] || unzip -o $packagedir/libfreetype-$freetype_version.zip -d freetype
|
||||
[ -d openal_stripped ] || unzip -o $packagedir/openal_stripped.zip
|
||||
[ -d luajit ] || unzip -o $packagedir/luajit-$luajit_version-static-win32.zip -d luajit
|
||||
[ -d leveldb ] || unzip -o $packagedir/libleveldb-$leveldb_version-win32.zip -d leveldb
|
||||
|
@ -86,53 +82,66 @@ cd ../..
|
|||
|
||||
# Build the thing
|
||||
cd minetest
|
||||
[ -d build ] && rm -Rf build/
|
||||
mkdir build
|
||||
cd build
|
||||
[ -d _build ] && rm -Rf _build/
|
||||
mkdir _build
|
||||
cd _build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX=/tmp \
|
||||
-DVERSION_EXTRA=$git_hash \
|
||||
-DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
|
||||
\
|
||||
-DENABLE_SOUND=1 \
|
||||
-DENABLE_CURL=1 \
|
||||
-DENABLE_GETTEXT=1 \
|
||||
-DENABLE_FREETYPE=1 \
|
||||
-DENABLE_LEVELDB=1 \
|
||||
\
|
||||
-DIRRLICHT_INCLUDE_DIR=$libdir/irrlicht-$irrlicht_version/include \
|
||||
-DIRRLICHT_LIBRARY=$libdir/irrlicht-$irrlicht_version/lib/Win32-gcc/libIrrlicht.dll.a \
|
||||
-DIRRLICHT_DLL=$libdir/irrlicht-$irrlicht_version/bin/Win32-gcc/Irrlicht.dll \
|
||||
-DZLIB_INCLUDE_DIR=$libdir/zlib-1.2.5 \
|
||||
-DZLIB_LIBRARIES=$libdir/zlib125dll/dll32/zlibwapi.lib \
|
||||
-DZLIB_DLL=$libdir/zlib125dll/dll32/zlibwapi.dll \
|
||||
\
|
||||
-DZLIB_INCLUDE_DIR=$libdir/zlib/include \
|
||||
-DZLIB_LIBRARIES=$libdir/zlib/lib/zlibwapi.dll.a \
|
||||
-DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
|
||||
-DZLIBWAPI_DLL=$libdir/zlib/bin/zlibwapi.dll \
|
||||
\
|
||||
-DLUA_INCLUDE_DIR=$libdir/luajit/include \
|
||||
-DLUA_LIBRARY=$libdir/luajit/libluajit.a \
|
||||
\
|
||||
-DOGG_INCLUDE_DIR=$libdir/libogg/include \
|
||||
-DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
|
||||
-DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
|
||||
\
|
||||
-DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
|
||||
-DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
|
||||
-DVORBIS_DLL=$libdir/libvorbis/bin/libvorbis-0.dll \
|
||||
-DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
|
||||
-DVORBISFILE_DLL=$libdir/libvorbis/bin/libvorbisfile-3.dll \
|
||||
-DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include \
|
||||
-DOPENAL_LIBRARY=$libdir/openal_stripped/lib/OpenAL32.lib \
|
||||
\
|
||||
-DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
|
||||
-DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
|
||||
-DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
|
||||
-DMINGWM10_DLL=$packagedir/mingwm10.dll \
|
||||
\
|
||||
-DCURL_DLL=$libdir/libcurl/libcurl.dll \
|
||||
-DCURL_INCLUDE_DIR=$libdir/libcurl/include \
|
||||
-DCURL_LIBRARY=$libdir/libcurl/libcurl.lib \
|
||||
\
|
||||
-DCUSTOM_GETTEXT_PATH=$libdir/gettext \
|
||||
-DGETTEXT_MSGFMT=`which msgfmt` \
|
||||
-DGETTEXT_DLL=$libdir/gettext/bin/libintl3.dll \
|
||||
-DGETTEXT_ICONV_DLL=$libdir/gettext/bin/libiconv2.dll \
|
||||
-DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
|
||||
-DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
|
||||
-DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype \
|
||||
\
|
||||
-DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
|
||||
-DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include \
|
||||
-DFREETYPE_LIBRARY=$libdir/freetype/lib/freetype.lib \
|
||||
-DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
|
||||
-DFREETYPE_DLL=$libdir/freetype/bin/freetype6.dll \
|
||||
\
|
||||
-DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
|
||||
-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a
|
||||
-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
|
||||
-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
|
||||
|
||||
make package -j2
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ core.features = {
|
|||
get_all_craft_recipes_works = true,
|
||||
use_texture_alpha = true,
|
||||
no_legacy_abms = true,
|
||||
texture_names_parens = true,
|
||||
}
|
||||
|
||||
function core.has_feature(arg)
|
||||
|
|
|
@ -186,6 +186,78 @@ stripping out the file extension:
|
|||
e.g. foomod_foothing.png
|
||||
e.g. foomod_foothing
|
||||
|
||||
Texture modifiers
|
||||
-----------------
|
||||
There are various texture modifiers that can be used
|
||||
to generate textures on-the-fly.
|
||||
|
||||
Texture overlaying:
|
||||
Textures can be overlaid by putting a ^ between them.
|
||||
Example: default_dirt.png^default_grass_side.png
|
||||
default_grass_side.png is overlayed over default_dirt.png
|
||||
|
||||
Texture grouping:
|
||||
Textures can be grouped together by enclosing them in ( and ).
|
||||
Example: cobble.png^(thing1.png^thing2.png)
|
||||
A texture for 'thing1.png^thing2.png' is created and the resulting
|
||||
texture is overlaid over cobble.png.
|
||||
|
||||
Advanced texture modifiers:
|
||||
[crack:<n>:<p>
|
||||
n = animation frame count, p = current animation frame
|
||||
Draw a step of the crack animation on the texture.
|
||||
Example: default_cobble.png^[crack:10:1
|
||||
|
||||
[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>
|
||||
w = width, h = height, x1/x2 = x position, y1/y1 = y position,
|
||||
file1/file2 = texture to combine
|
||||
Create a textue of size <w> x <h> and blit <file1> to (<x1>,<y1>)
|
||||
and blit <file2> to (<x2>,<y2>).
|
||||
Example: [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
|
||||
|
||||
[brighten
|
||||
Brightens the texture.
|
||||
Example: tnt_tnt_side.png^[brighten
|
||||
|
||||
[noalpha
|
||||
Makes the texture completly opaque.
|
||||
Example: default_leaves.png^[noalpha
|
||||
|
||||
[makealpha:<r>,<g>,<b>
|
||||
Convert one color to transparency.
|
||||
Example: default_cobble.png^[makealpha:128,128,128
|
||||
|
||||
[transform<t>
|
||||
t = transformation(s) to apply
|
||||
Rotates and/or flips the image.
|
||||
<t> can be a number (between 0 and 7) or a transform name.
|
||||
Rotations are counter-clockwise.
|
||||
0 I identity
|
||||
1 R90 rotate by 90 degrees
|
||||
2 R180 rotate by 180 degrees
|
||||
3 R270 rotate by 270 degrees
|
||||
4 FX flip X
|
||||
5 FXR90 flip X then rotate by 90 degrees
|
||||
6 FY flip Y
|
||||
7 FYR90 flip Y then rotate by 90 degrees
|
||||
Example: default_stone.png^[transformFXR90
|
||||
|
||||
[inventorycube{<top>{<left>{<right>
|
||||
'^' is replaced by '&' in texture names
|
||||
Create an inventory cube texture using the side textures.
|
||||
Example: [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
|
||||
Creates an inventorycube with 'grass.png', 'dirt.png^grass_side.png' and
|
||||
'dirt.png^grass_side.png' textures
|
||||
|
||||
[lowpart:<percent>:<file>
|
||||
Blit the lower <percent>% part of <file> on the texture:
|
||||
Example: base.png^[lowpart:25:overlay.png
|
||||
|
||||
[verticalframe:<t>:<n>
|
||||
t = animation frame count, n = current animation frame
|
||||
Crops the texture to a frame of a vertical animation.
|
||||
Example: default_torch_animated.png^[verticalframe:16:8
|
||||
|
||||
Sounds
|
||||
-------
|
||||
Only OGG Vorbis files are supported.
|
||||
|
|
|
@ -148,8 +148,6 @@ if(WIN32)
|
|||
set(FREETYPE_LIBRARY "${PROJECT_SOURCE_DIR}/../../freetype2/objs/win32/vc2005/freetype247.lib"
|
||||
CACHE FILEPATH "Path to freetype247.lib")
|
||||
endif(USE_FREETYPE)
|
||||
set(MINGWM10_DLL ""
|
||||
CACHE FILEPATH "Path to mingwm10.dll (for installation)")
|
||||
if(ENABLE_SOUND)
|
||||
set(OPENAL_DLL "" CACHE FILEPATH "Path to OpenAL32.dll for installation (optional)")
|
||||
set(OGG_DLL "" CACHE FILEPATH "Path to libogg.dll for installation (optional)")
|
||||
|
@ -773,12 +771,6 @@ endif()
|
|||
if(WIN32)
|
||||
if(NOT STATIC_BUILD)
|
||||
|
||||
if(MINGWM10_DLL)
|
||||
install(FILES ${MINGWM10_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
if(DEFINED ZLIB_DLL)
|
||||
install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
if(USE_SOUND)
|
||||
if(OPENAL_DLL)
|
||||
install(FILES ${OPENAL_DLL} DESTINATION ${BINDIR})
|
||||
|
@ -796,6 +788,19 @@ if(WIN32)
|
|||
if(CURL_DLL)
|
||||
install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
|
||||
if(ZLIB_DLL)
|
||||
install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
if(ZLIBWAPI_DLL)
|
||||
install(FILES ${ZLIBWAPI_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
if(FREETYPE_DLL)
|
||||
install(FILES ${FREETYPE_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
if(LEVELDB_DLL)
|
||||
install(FILES ${LEVELDB_DLL} DESTINATION ${BINDIR})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -34,9 +34,8 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
|||
int LuaVoxelManip::gc_object(lua_State *L)
|
||||
{
|
||||
LuaVoxelManip *o = *(LuaVoxelManip **)(lua_touserdata(L, 1));
|
||||
if (!o->is_mapgen_vm)
|
||||
delete o;
|
||||
|
||||
delete o;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -44,16 +43,16 @@ int LuaVoxelManip::l_read_from_map(lua_State *L)
|
|||
{
|
||||
LuaVoxelManip *o = checkobject(L, 1);
|
||||
ManualMapVoxelManipulator *vm = o->vm;
|
||||
|
||||
|
||||
v3s16 bp1 = getNodeBlockPos(read_v3s16(L, 2));
|
||||
v3s16 bp2 = getNodeBlockPos(read_v3s16(L, 3));
|
||||
sortBoxVerticies(bp1, bp2);
|
||||
|
||||
|
||||
vm->initialEmerge(bp1, bp2);
|
||||
|
||||
|
||||
push_v3s16(L, vm->m_area.MinEdge);
|
||||
push_v3s16(L, vm->m_area.MaxEdge);
|
||||
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -63,39 +62,39 @@ int LuaVoxelManip::l_get_data(lua_State *L)
|
|||
|
||||
LuaVoxelManip *o = checkobject(L, 1);
|
||||
ManualMapVoxelManipulator *vm = o->vm;
|
||||
|
||||
|
||||
int volume = vm->m_area.getVolume();
|
||||
|
||||
|
||||
lua_newtable(L);
|
||||
for (int i = 0; i != volume; i++) {
|
||||
lua_Integer cid = vm->m_data[i].getContent();
|
||||
lua_pushinteger(L, cid);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaVoxelManip::l_set_data(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
|
||||
LuaVoxelManip *o = checkobject(L, 1);
|
||||
ManualMapVoxelManipulator *vm = o->vm;
|
||||
|
||||
|
||||
if (!lua_istable(L, 2))
|
||||
return 0;
|
||||
|
||||
|
||||
int volume = vm->m_area.getVolume();
|
||||
for (int i = 0; i != volume; i++) {
|
||||
lua_rawgeti(L, 2, i + 1);
|
||||
content_t c = lua_tointeger(L, -1);
|
||||
|
||||
|
||||
vm->m_data[i].setContent(c);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +105,7 @@ int LuaVoxelManip::l_write_to_map(lua_State *L)
|
|||
|
||||
vm->blitBackAll(&o->modified_blocks);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaVoxelManip::l_update_liquids(lua_State *L)
|
||||
|
@ -134,7 +133,7 @@ int LuaVoxelManip::l_update_liquids(lua_State *L)
|
|||
int LuaVoxelManip::l_calc_lighting(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
|
||||
LuaVoxelManip *o = checkobject(L, 1);
|
||||
if (!o->is_mapgen_vm)
|
||||
return 0;
|
||||
|
@ -153,7 +152,7 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
|
|||
mg.vm = vm;
|
||||
mg.ndef = ndef;
|
||||
mg.water_level = emerge->params.water_level;
|
||||
|
||||
|
||||
mg.calcLighting(p1, p2);
|
||||
|
||||
return 0;
|
||||
|
@ -162,20 +161,20 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
|
|||
int LuaVoxelManip::l_set_lighting(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
|
||||
LuaVoxelManip *o = checkobject(L, 1);
|
||||
if (!o->is_mapgen_vm)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!lua_istable(L, 2))
|
||||
return 0;
|
||||
|
||||
u8 light;
|
||||
light = (getintfield_default(L, 2, "day", 0) & 0x0F);
|
||||
light |= (getintfield_default(L, 2, "night", 0) & 0x0F) << 4;
|
||||
|
||||
|
||||
ManualMapVoxelManipulator *vm = o->vm;
|
||||
|
||||
|
||||
v3s16 p1 = lua_istable(L, 3) ? read_v3s16(L, 3) :
|
||||
vm->m_area.MinEdge + v3s16(0, 1, 0) * MAP_BLOCKSIZE;
|
||||
v3s16 p2 = lua_istable(L, 4) ? read_v3s16(L, 4) :
|
||||
|
@ -184,7 +183,7 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
|
|||
|
||||
Mapgen mg;
|
||||
mg.vm = vm;
|
||||
|
||||
|
||||
mg.setLighting(p1, p2, light);
|
||||
|
||||
return 0;
|
||||
|
@ -279,7 +278,7 @@ int LuaVoxelManip::l_update_map(lua_State *L)
|
|||
LuaVoxelManip *o = checkobject(L, 1);
|
||||
if (o->is_mapgen_vm)
|
||||
return 0;
|
||||
|
||||
|
||||
Environment *env = getEnv(L);
|
||||
if (!env)
|
||||
return 0;
|
||||
|
@ -289,9 +288,9 @@ int LuaVoxelManip::l_update_map(lua_State *L)
|
|||
// TODO: Optimize this by using Mapgen::calcLighting() instead
|
||||
shared_map<v3s16, MapBlock *> lighting_mblocks;
|
||||
std::map<v3s16, MapBlock *> *mblocks = &o->modified_blocks;
|
||||
|
||||
|
||||
lighting_mblocks.insert(mblocks->begin(), mblocks->end());
|
||||
|
||||
|
||||
map->updateLighting(lighting_mblocks, *mblocks);
|
||||
|
||||
MapEditEvent event;
|
||||
|
@ -300,12 +299,12 @@ int LuaVoxelManip::l_update_map(lua_State *L)
|
|||
it = mblocks->begin();
|
||||
it != mblocks->end(); ++it)
|
||||
event.modified_blocks.insert(it->first);
|
||||
|
||||
|
||||
map->dispatchEvent(&event);
|
||||
|
||||
mblocks->clear();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LuaVoxelManip::LuaVoxelManip(ManualMapVoxelManipulator *mmvm, bool is_mg_vm)
|
||||
|
@ -322,7 +321,8 @@ LuaVoxelManip::LuaVoxelManip(Map *map)
|
|||
|
||||
LuaVoxelManip::~LuaVoxelManip()
|
||||
{
|
||||
delete vm;
|
||||
if (!is_mapgen_vm)
|
||||
delete vm;
|
||||
}
|
||||
|
||||
// LuaVoxelManip()
|
||||
|
@ -330,14 +330,14 @@ LuaVoxelManip::~LuaVoxelManip()
|
|||
int LuaVoxelManip::create_object(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
|
||||
Environment *env = getEnv(L);
|
||||
if (!env)
|
||||
return 0;
|
||||
|
||||
|
||||
Map *map = &(env->getMap());
|
||||
LuaVoxelManip *o = new LuaVoxelManip(map);
|
||||
|
||||
|
||||
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||
luaL_getmetatable(L, className);
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -347,13 +347,13 @@ int LuaVoxelManip::create_object(lua_State *L)
|
|||
LuaVoxelManip *LuaVoxelManip::checkobject(lua_State *L, int narg)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
|
||||
luaL_checktype(L, narg, LUA_TUSERDATA);
|
||||
|
||||
void *ud = luaL_checkudata(L, narg, className);
|
||||
if (!ud)
|
||||
luaL_typerror(L, narg, className);
|
||||
|
||||
|
||||
return *(LuaVoxelManip **)ud; // unbox pointer
|
||||
}
|
||||
|
||||
|
|
402
src/tile.cpp
402
src/tile.cpp
|
@ -290,27 +290,12 @@ public:
|
|||
|
||||
/*
|
||||
Gets a texture id from cache or
|
||||
- if main thread, from getTextureIdDirect
|
||||
- if other thread, adds to request queue and waits for main thread
|
||||
*/
|
||||
u32 getTextureId(const std::string &name);
|
||||
|
||||
/*
|
||||
Example names:
|
||||
"stone.png"
|
||||
"stone.png^crack2"
|
||||
"stone.png^mineral_coal.png"
|
||||
"stone.png^mineral_coal.png^crack1"
|
||||
|
||||
- If texture specified by name is found from cache, return the
|
||||
cached id.
|
||||
- Otherwise generate the texture, add to cache and return id.
|
||||
Recursion is used to find out the largest found part of the
|
||||
texture and continue based on it.
|
||||
- if main thread, generates the texture, adds to cache and returns id.
|
||||
- if other thread, adds to request queue and waits for main thread.
|
||||
|
||||
The id 0 points to a NULL texture. It is returned in case of error.
|
||||
*/
|
||||
u32 getTextureIdDirect(const std::string &name);
|
||||
u32 getTextureId(const std::string &name);
|
||||
|
||||
// Finds out the name of a cached texture.
|
||||
std::string getTextureName(u32 id);
|
||||
|
@ -368,12 +353,7 @@ public:
|
|||
// Generates an image from a full string like
|
||||
// "stone.png^mineral_coal.png^[crack:1:0".
|
||||
// Shall be called from the main thread.
|
||||
video::IImage* generateImageFromScratch(std::string name);
|
||||
|
||||
// Generate image based on a string like "stone.png" or "[crack:1:0".
|
||||
// if baseimg is NULL, it is created. Otherwise stuff is made on it.
|
||||
// Shall be called from the main thread.
|
||||
bool generateImage(std::string part_of_name, video::IImage *& baseimg);
|
||||
video::IImage* generateImage(const std::string &name);
|
||||
|
||||
video::ITexture* getNormalTexture(const std::string &name);
|
||||
private:
|
||||
|
@ -387,6 +367,13 @@ private:
|
|||
// This should be only accessed from the main thread
|
||||
SourceImageCache m_sourcecache;
|
||||
|
||||
// Generate a texture
|
||||
u32 generateTexture(const std::string &name);
|
||||
|
||||
// Generate image based on a string like "stone.png" or "[crack:1:0".
|
||||
// if baseimg is NULL, it is created. Otherwise stuff is made on it.
|
||||
bool generateImagePart(std::string part_of_name, video::IImage *& baseimg);
|
||||
|
||||
// Thread-safe cache of what source images are known (true = known)
|
||||
MutexedMap<std::string, bool> m_source_image_existence;
|
||||
|
||||
|
@ -487,7 +474,7 @@ u32 TextureSource::getTextureId(const std::string &name)
|
|||
*/
|
||||
if(get_current_thread_id() == m_main_thread)
|
||||
{
|
||||
return getTextureIdDirect(name);
|
||||
return generateTexture(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -553,151 +540,50 @@ void imageTransform(u32 transform, video::IImage *src, video::IImage *dst);
|
|||
/*
|
||||
This method generates all the textures
|
||||
*/
|
||||
u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
u32 TextureSource::generateTexture(const std::string &name)
|
||||
{
|
||||
//infostream<<"getTextureIdDirect(): name=\""<<name<<"\""<<std::endl;
|
||||
//infostream << "generateTexture(): name=\"" << name << "\"" << std::endl;
|
||||
|
||||
// Empty name means texture 0
|
||||
if(name == "")
|
||||
{
|
||||
infostream<<"getTextureIdDirect(): name is empty"<<std::endl;
|
||||
if (name == "") {
|
||||
infostream<<"generateTexture(): name is empty"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
See if texture already exists
|
||||
*/
|
||||
JMutexAutoLock lock(m_textureinfo_cache_mutex);
|
||||
std::map<std::string, u32>::iterator n;
|
||||
n = m_name_to_id.find(name);
|
||||
if (n != m_name_to_id.end()) {
|
||||
return n->second;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Calling only allowed from main thread
|
||||
*/
|
||||
if(get_current_thread_id() != m_main_thread)
|
||||
{
|
||||
errorstream<<"TextureSource::getTextureIdDirect() "
|
||||
if (get_current_thread_id() != m_main_thread) {
|
||||
errorstream<<"TextureSource::generateTexture() "
|
||||
"called not from main thread"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
See if texture already exists
|
||||
*/
|
||||
{
|
||||
JMutexAutoLock lock(m_textureinfo_cache_mutex);
|
||||
|
||||
std::map<std::string, u32>::iterator n;
|
||||
n = m_name_to_id.find(name);
|
||||
if(n != m_name_to_id.end())
|
||||
{
|
||||
/*infostream<<"getTextureIdDirect(): \""<<name
|
||||
<<"\" found in cache"<<std::endl;*/
|
||||
return n->second;
|
||||
}
|
||||
}
|
||||
|
||||
/*infostream<<"getTextureIdDirect(): \""<<name
|
||||
<<"\" NOT found in cache. Creating it."<<std::endl;*/
|
||||
|
||||
/*
|
||||
Get the base image
|
||||
*/
|
||||
|
||||
char separator = '^';
|
||||
|
||||
/*
|
||||
This is set to the id of the base image.
|
||||
If left 0, there is no base image and a completely new image
|
||||
is made.
|
||||
*/
|
||||
u32 base_image_id = 0;
|
||||
|
||||
// Find last meta separator in name
|
||||
s32 last_separator_position = -1;
|
||||
for(s32 i=name.size()-1; i>=0; i--)
|
||||
{
|
||||
if(name[i] == separator)
|
||||
{
|
||||
last_separator_position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
If separator was found, construct the base name and make the
|
||||
base image using a recursive call
|
||||
*/
|
||||
std::string base_image_name;
|
||||
if(last_separator_position != -1)
|
||||
{
|
||||
// Construct base name
|
||||
base_image_name = name.substr(0, last_separator_position);
|
||||
/*infostream<<"getTextureIdDirect(): Calling itself recursively"
|
||||
" to get base image of \""<<name<<"\" = \""
|
||||
<<base_image_name<<"\""<<std::endl;*/
|
||||
base_image_id = getTextureIdDirect(base_image_name);
|
||||
}
|
||||
|
||||
//infostream<<"base_image_id="<<base_image_id<<std::endl;
|
||||
|
||||
video::IVideoDriver* driver = m_device->getVideoDriver();
|
||||
video::IVideoDriver *driver = m_device->getVideoDriver();
|
||||
assert(driver);
|
||||
|
||||
video::ITexture *t = NULL;
|
||||
video::IImage *img = generateImage(name);
|
||||
|
||||
/*
|
||||
An image will be built from files and then converted into a texture.
|
||||
*/
|
||||
video::IImage *baseimg = NULL;
|
||||
video::ITexture *tex = NULL;
|
||||
|
||||
// If a base image was found, copy it to baseimg
|
||||
if(base_image_id != 0)
|
||||
{
|
||||
JMutexAutoLock lock(m_textureinfo_cache_mutex);
|
||||
|
||||
TextureInfo *ti = &m_textureinfo_cache[base_image_id];
|
||||
|
||||
if(ti->texture == NULL)
|
||||
{
|
||||
infostream<<"getTextureIdDirect(): WARNING: NULL Texture in "
|
||||
<<"cache: \""<<base_image_name<<"\""
|
||||
<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
core::dimension2d<u32> dim = ti->texture->getSize();
|
||||
|
||||
baseimg = driver->createImage(ti->texture,v2s32(0,0), dim);
|
||||
|
||||
/*infostream<<"getTextureIdDirect(): Loaded \""
|
||||
<<base_image_name<<"\" from image cache"
|
||||
<<std::endl;*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Parse out the last part of the name of the image and act
|
||||
according to it
|
||||
*/
|
||||
|
||||
std::string last_part_of_name = name.substr(last_separator_position+1);
|
||||
//infostream<<"last_part_of_name=\""<<last_part_of_name<<"\""<<std::endl;
|
||||
|
||||
// Generate image according to part of name
|
||||
if(!generateImage(last_part_of_name, baseimg))
|
||||
{
|
||||
errorstream<<"getTextureIdDirect(): "
|
||||
"failed to generate \""<<last_part_of_name<<"\""
|
||||
<<std::endl;
|
||||
}
|
||||
|
||||
// If no resulting image, print a warning
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
errorstream<<"getTextureIdDirect(): baseimg is NULL (attempted to"
|
||||
" create texture \""<<name<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
if(baseimg != NULL)
|
||||
{
|
||||
if (img != NULL) {
|
||||
#ifdef __ANDROID__
|
||||
baseimg = Align2Npot2(baseimg, driver);
|
||||
img = Align2Npot2(img, driver);
|
||||
#endif
|
||||
// Create texture from resulting image
|
||||
t = driver->addTexture(name.c_str(), baseimg);
|
||||
tex = driver->addTexture(name.c_str(), img);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -707,10 +593,9 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
|||
JMutexAutoLock lock(m_textureinfo_cache_mutex);
|
||||
|
||||
u32 id = m_textureinfo_cache.size();
|
||||
TextureInfo ti(name, t, baseimg);
|
||||
if (baseimg)
|
||||
baseimg->drop();
|
||||
|
||||
TextureInfo ti(name, tex, img);
|
||||
if (img)
|
||||
img->drop();
|
||||
m_textureinfo_cache.push_back(ti);
|
||||
m_name_to_id[name] = id;
|
||||
|
||||
|
@ -777,7 +662,7 @@ void TextureSource::processQueue()
|
|||
<<"name=\""<<request.key<<"\""
|
||||
<<std::endl;*/
|
||||
|
||||
m_get_texture_queue.pushResult(request,getTextureIdDirect(request.key));
|
||||
m_get_texture_queue.pushResult(request, generateTexture(request.key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -801,15 +686,15 @@ void TextureSource::rebuildImagesAndTextures()
|
|||
// Recreate textures
|
||||
for(u32 i=0; i<m_textureinfo_cache.size(); i++){
|
||||
TextureInfo *ti = &m_textureinfo_cache[i];
|
||||
video::IImage *img = generateImageFromScratch(ti->name);
|
||||
video::IImage *img = generateImage(ti->name);
|
||||
#ifdef __ANDROID__
|
||||
img = Align2Npot2(img,driver);
|
||||
img = Align2Npot2(img, driver);
|
||||
assert(img->getDimension().Height == npot2(img->getDimension().Height));
|
||||
assert(img->getDimension().Width == npot2(img->getDimension().Width));
|
||||
#endif
|
||||
// Create texture from resulting image
|
||||
video::ITexture *t = NULL;
|
||||
if(img) {
|
||||
if (img) {
|
||||
t = driver->addTexture(ti->name.c_str(), img);
|
||||
img->drop();
|
||||
}
|
||||
|
@ -817,7 +702,7 @@ void TextureSource::rebuildImagesAndTextures()
|
|||
// Replace texture
|
||||
ti->texture = t;
|
||||
|
||||
if (t_old != 0)
|
||||
if (t_old)
|
||||
m_texture_trash.push_back(t_old);
|
||||
}
|
||||
}
|
||||
|
@ -1028,51 +913,103 @@ video::ITexture* TextureSource::generateTextureFromMesh(
|
|||
return rtt;
|
||||
}
|
||||
|
||||
video::IImage* TextureSource::generateImageFromScratch(std::string name)
|
||||
video::IImage* TextureSource::generateImage(const std::string &name)
|
||||
{
|
||||
/*infostream<<"generateImageFromScratch(): "
|
||||
"\""<<name<<"\""<<std::endl;*/
|
||||
|
||||
video::IVideoDriver *driver = m_device->getVideoDriver();
|
||||
assert(driver);
|
||||
|
||||
/*
|
||||
Get the base image
|
||||
*/
|
||||
|
||||
const char separator = '^';
|
||||
const char paren_open = '(';
|
||||
const char paren_close = ')';
|
||||
|
||||
// Find last separator in the name
|
||||
s32 last_separator_pos = -1;
|
||||
u8 paren_bal = 0;
|
||||
for(s32 i = name.size() - 1; i >= 0; i--) {
|
||||
switch(name[i]) {
|
||||
case separator:
|
||||
if (paren_bal == 0) {
|
||||
last_separator_pos = i;
|
||||
i = -1; // break out of loop
|
||||
}
|
||||
break;
|
||||
case paren_open:
|
||||
if (paren_bal == 0) {
|
||||
errorstream << "generateImage(): unbalanced parentheses"
|
||||
<< "(extranous '(') while generating texture \""
|
||||
<< name << "\"" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
paren_bal--;
|
||||
break;
|
||||
case paren_close:
|
||||
paren_bal++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (paren_bal > 0) {
|
||||
errorstream << "generateImage(): unbalanced parentheses"
|
||||
<< "(missing matching '(') while generating texture \""
|
||||
<< name << "\"" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
video::IImage *baseimg = NULL;
|
||||
|
||||
char separator = '^';
|
||||
|
||||
// Find last meta separator in name
|
||||
s32 last_separator_position = name.find_last_of(separator);
|
||||
|
||||
/*
|
||||
If separator was found, construct the base name and make the
|
||||
base image using a recursive call
|
||||
If separator was found, make the base image
|
||||
using a recursive call.
|
||||
*/
|
||||
std::string base_image_name;
|
||||
if(last_separator_position != -1)
|
||||
{
|
||||
// Construct base name
|
||||
base_image_name = name.substr(0, last_separator_position);
|
||||
baseimg = generateImageFromScratch(base_image_name);
|
||||
if (last_separator_pos != -1) {
|
||||
baseimg = generateImage(name.substr(0, last_separator_pos));
|
||||
}
|
||||
|
||||
|
||||
video::IVideoDriver* driver = m_device->getVideoDriver();
|
||||
assert(driver);
|
||||
|
||||
/*
|
||||
Parse out the last part of the name of the image and act
|
||||
according to it
|
||||
*/
|
||||
|
||||
std::string last_part_of_name = name.substr(last_separator_position+1);
|
||||
std::string last_part_of_name = name.substr(last_separator_pos + 1);
|
||||
|
||||
// Generate image according to part of name
|
||||
if(!generateImage(last_part_of_name, baseimg))
|
||||
{
|
||||
errorstream<<"generateImageFromScratch(): "
|
||||
"failed to generate \""<<last_part_of_name<<"\""
|
||||
<<std::endl;
|
||||
return NULL;
|
||||
/*
|
||||
If this name is enclosed in parentheses, generate it
|
||||
and blit it onto the base image
|
||||
*/
|
||||
if (last_part_of_name[0] == paren_open
|
||||
&& last_part_of_name[last_part_of_name.size() - 1] == paren_close) {
|
||||
std::string name2 = last_part_of_name.substr(1,
|
||||
last_part_of_name.size() - 2);
|
||||
video::IImage *tmp = generateImage(name2);
|
||||
if (!tmp) {
|
||||
errorstream << "generateImage(): "
|
||||
"Failed to generate \"" << name2 << "\""
|
||||
<< std::endl;
|
||||
return NULL;
|
||||
}
|
||||
core::dimension2d<u32> dim = tmp->getDimension();
|
||||
if (!baseimg)
|
||||
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
|
||||
blit_with_alpha(tmp, baseimg, v2s32(0, 0), v2s32(0, 0), dim);
|
||||
tmp->drop();
|
||||
} else if (!generateImagePart(last_part_of_name, baseimg)) {
|
||||
// Generate image according to part of name
|
||||
errorstream << "generateImage(): "
|
||||
"Failed to generate \"" << last_part_of_name << "\""
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// If no resulting image, print a warning
|
||||
if (baseimg == NULL) {
|
||||
errorstream << "generateImage(): baseimg is NULL (attempted to"
|
||||
" create texture \"" << name << "\")" << std::endl;
|
||||
}
|
||||
|
||||
return baseimg;
|
||||
|
@ -1129,7 +1066,8 @@ video::IImage * Align2Npot2(video::IImage * image,
|
|||
|
||||
#endif
|
||||
|
||||
bool TextureSource::generateImage(std::string part_of_name, video::IImage *& baseimg)
|
||||
bool TextureSource::generateImagePart(std::string part_of_name,
|
||||
video::IImage *& baseimg)
|
||||
{
|
||||
video::IVideoDriver* driver = m_device->getVideoDriver();
|
||||
assert(driver);
|
||||
|
@ -1139,7 +1077,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
{
|
||||
video::IImage *image = m_sourcecache.getOrLoad(part_of_name, m_device);
|
||||
#ifdef __ANDROID__
|
||||
image = Align2Npot2(image,driver);
|
||||
image = Align2Npot2(image, driver);
|
||||
#endif
|
||||
if (image == NULL) {
|
||||
if (part_of_name != "") {
|
||||
|
@ -1225,9 +1163,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
*/
|
||||
if(part_of_name.substr(0,6) == "[crack")
|
||||
{
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
errorstream<<"generateImage(): baseimg==NULL "
|
||||
if (baseimg == NULL) {
|
||||
errorstream<<"generateImagePart(): baseimg == NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1267,15 +1204,13 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
sf.next(":");
|
||||
u32 w0 = stoi(sf.next("x"));
|
||||
u32 h0 = stoi(sf.next(":"));
|
||||
infostream<<"combined w="<<w0<<" h="<<h0<<std::endl;
|
||||
//infostream<<"combined w="<<w0<<" h="<<h0<<std::endl;
|
||||
core::dimension2d<u32> dim(w0,h0);
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
if (baseimg == NULL) {
|
||||
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
|
||||
baseimg->fill(video::SColor(0,0,0,0));
|
||||
}
|
||||
while(sf.atend() == false)
|
||||
{
|
||||
while (sf.atend() == false) {
|
||||
u32 x = stoi(sf.next(","));
|
||||
u32 y = stoi(sf.next("="));
|
||||
std::string filename = sf.next(":");
|
||||
|
@ -1283,8 +1218,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
<<"\" to combined ("<<x<<","<<y<<")"
|
||||
<<std::endl;
|
||||
video::IImage *img = m_sourcecache.getOrLoad(filename, m_device);
|
||||
if(img)
|
||||
{
|
||||
if (img) {
|
||||
core::dimension2d<u32> dim = img->getDimension();
|
||||
infostream<<"Size "<<dim.Width
|
||||
<<"x"<<dim.Height<<std::endl;
|
||||
|
@ -1299,10 +1233,9 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
NULL);*/
|
||||
blit_with_alpha(img2, baseimg, v2s32(0,0), pos_base, dim);
|
||||
img2->drop();
|
||||
}
|
||||
else
|
||||
{
|
||||
infostream<<"img==NULL"<<std::endl;
|
||||
} else {
|
||||
errorstream << "generateImagePart(): Failed to load image \""
|
||||
<< filename << "\" for [combine" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1311,9 +1244,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
*/
|
||||
else if(part_of_name.substr(0,9) == "[brighten")
|
||||
{
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
errorstream<<"generateImage(): baseimg==NULL "
|
||||
if (baseimg == NULL) {
|
||||
errorstream<<"generateImagePart(): baseimg==NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1330,9 +1262,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
*/
|
||||
else if(part_of_name.substr(0,8) == "[noalpha")
|
||||
{
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
errorstream<<"generateImage(): baseimg==NULL "
|
||||
if (baseimg == NULL){
|
||||
errorstream<<"generateImagePart(): baseimg==NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1355,9 +1286,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
*/
|
||||
else if(part_of_name.substr(0,11) == "[makealpha:")
|
||||
{
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
errorstream<<"generateImage(): baseimg==NULL "
|
||||
if (baseimg == NULL) {
|
||||
errorstream<<"generateImagePart(): baseimg == NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1412,9 +1342,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
*/
|
||||
else if(part_of_name.substr(0,10) == "[transform")
|
||||
{
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
errorstream<<"generateImage(): baseimg==NULL "
|
||||
if (baseimg == NULL) {
|
||||
errorstream<<"generateImagePart(): baseimg == NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1440,9 +1369,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
*/
|
||||
else if(part_of_name.substr(0,14) == "[inventorycube")
|
||||
{
|
||||
if(baseimg != NULL)
|
||||
{
|
||||
errorstream<<"generateImage(): baseimg!=NULL "
|
||||
if (baseimg != NULL){
|
||||
errorstream<<"generateImagePart(): baseimg != NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1456,13 +1384,18 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
std::string imagename_right = sf.next("{");
|
||||
|
||||
// Generate images for the faces of the cube
|
||||
video::IImage *img_top =
|
||||
generateImageFromScratch(imagename_top);
|
||||
video::IImage *img_left =
|
||||
generateImageFromScratch(imagename_left);
|
||||
video::IImage *img_right =
|
||||
generateImageFromScratch(imagename_right);
|
||||
assert(img_top && img_left && img_right);
|
||||
video::IImage *img_top = generateImage(imagename_top);
|
||||
video::IImage *img_left = generateImage(imagename_left);
|
||||
video::IImage *img_right = generateImage(imagename_right);
|
||||
|
||||
if (img_top == NULL || img_left == NULL || img_right == NULL) {
|
||||
errorstream << "generateImagePart(): Failed to create textures"
|
||||
<< " for inventorycube \"" << part_of_name << "\""
|
||||
<< std::endl;
|
||||
baseimg = generateImage(imagename_top);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
assert(img_top->getDimension().Height == npot2(img_top->getDimension().Height));
|
||||
assert(img_top->getDimension().Width == npot2(img_top->getDimension().Width));
|
||||
|
@ -1473,6 +1406,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
assert(img_right->getDimension().Height == npot2(img_right->getDimension().Height));
|
||||
assert(img_right->getDimension().Width == npot2(img_right->getDimension().Width));
|
||||
#endif
|
||||
|
||||
// Create textures from images
|
||||
video::ITexture *texture_top = driver->addTexture(
|
||||
(imagename_top + "__temp__").c_str(), img_top);
|
||||
|
@ -1522,19 +1456,18 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
// Drop mesh
|
||||
cube->drop();
|
||||
|
||||
// Free textures of images
|
||||
// Free textures
|
||||
driver->removeTexture(texture_top);
|
||||
driver->removeTexture(texture_left);
|
||||
driver->removeTexture(texture_right);
|
||||
|
||||
if(rtt == NULL)
|
||||
{
|
||||
baseimg = generateImageFromScratch(imagename_top);
|
||||
if (rtt == NULL) {
|
||||
baseimg = generateImage(imagename_top);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create image of render target
|
||||
video::IImage *image = driver->createImage(rtt, v2s32(0,0), params.dim);
|
||||
video::IImage *image = driver->createImage(rtt, v2s32(0, 0), params.dim);
|
||||
assert(image);
|
||||
|
||||
// Cleanup texture
|
||||
|
@ -1542,8 +1475,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
|
||||
baseimg = driver->createImage(video::ECF_A8R8G8B8, params.dim);
|
||||
|
||||
if(image)
|
||||
{
|
||||
if (image) {
|
||||
image->copyTo(baseimg);
|
||||
image->drop();
|
||||
}
|
||||
|
@ -1596,7 +1528,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
u32 frame_index = stoi(sf.next(":"));
|
||||
|
||||
if(baseimg == NULL){
|
||||
errorstream<<"generateImage(): baseimg!=NULL "
|
||||
errorstream<<"generateImagePart(): baseimg != NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1609,7 +1541,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
video::IImage *img = driver->createImage(video::ECF_A8R8G8B8,
|
||||
frame_size);
|
||||
if(!img){
|
||||
errorstream<<"generateImage(): Could not create image "
|
||||
errorstream<<"generateImagePart(): Could not create image "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
|
@ -1631,7 +1563,7 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
|
|||
}
|
||||
else
|
||||
{
|
||||
errorstream<<"generateImage(): Invalid "
|
||||
errorstream<<"generateImagePart(): Invalid "
|
||||
" modification: \""<<part_of_name<<"\""<<std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,6 @@ public:
|
|||
ITextureSource(){}
|
||||
virtual ~ITextureSource(){}
|
||||
virtual u32 getTextureId(const std::string &name)=0;
|
||||
virtual u32 getTextureIdDirect(const std::string &name)=0;
|
||||
virtual std::string getTextureName(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(u32 id)=0;
|
||||
virtual TextureInfo* getTextureInfo(u32 id)=0;
|
||||
|
@ -145,7 +144,6 @@ public:
|
|||
IWritableTextureSource(){}
|
||||
virtual ~IWritableTextureSource(){}
|
||||
virtual u32 getTextureId(const std::string &name)=0;
|
||||
virtual u32 getTextureIdDirect(const std::string &name)=0;
|
||||
virtual std::string getTextureName(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(
|
||||
|
|
|
@ -77,46 +77,59 @@ cd ../..
|
|||
|
||||
# Build the thing
|
||||
cd minetest
|
||||
[ -d build ] && rm -Rf build/
|
||||
mkdir build
|
||||
cd build
|
||||
[ -d _build ] && rm -Rf _build/
|
||||
mkdir _build
|
||||
cd _build
|
||||
cmake .. \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
|
||||
-DCMAKE_INSTALL_PREFIX=/tmp \
|
||||
-DVERSION_EXTRA=$git_hash \
|
||||
-DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
|
||||
\
|
||||
-DENABLE_SOUND=1 \
|
||||
-DENABLE_CURL=1 \
|
||||
-DENABLE_GETTEXT=1 \
|
||||
-DENABLE_FREETYPE=1 \
|
||||
-DENABLE_LEVELDB=1 \
|
||||
\
|
||||
-DIRRLICHT_INCLUDE_DIR=$libdir/irrlicht-$irrlicht_version/include \
|
||||
-DIRRLICHT_LIBRARY=$libdir/irrlicht-$irrlicht_version/lib/Win64-gcc/libIrrlicht.dll.a \
|
||||
-DIRRLICHT_DLL=$libdir/irrlicht-$irrlicht_version/bin/Win64-gcc/Irrlicht.dll \
|
||||
\
|
||||
-DZLIB_INCLUDE_DIR=$libdir/zlib/include \
|
||||
-DZLIB_LIBRARIES=$libdir/zlib/lib/libz.dll.a \
|
||||
-DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
|
||||
\
|
||||
-DLUA_INCLUDE_DIR=$libdir/luajit/include \
|
||||
-DLUA_LIBRARY=$libdir/luajit/libluajit.a \
|
||||
\
|
||||
-DOGG_INCLUDE_DIR=$libdir/libogg/include \
|
||||
-DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
|
||||
-DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
|
||||
\
|
||||
-DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
|
||||
-DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
|
||||
-DVORBIS_DLL=$libdir/libvorbis/bin/libvorbis-0.dll \
|
||||
-DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
|
||||
-DVORBISFILE_DLL=$libdir/libvorbis/bin/libvorbisfile-3.dll \
|
||||
\
|
||||
-DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
|
||||
-DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
|
||||
-DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
|
||||
\
|
||||
-DCURL_DLL=$libdir/libcurl/bin/libcurl-4.dll \
|
||||
-DCURL_INCLUDE_DIR=$libdir/libcurl/include \
|
||||
-DCURL_LIBRARY=$libdir/libcurl/lib/libcurl.dll.a \
|
||||
\
|
||||
-DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
|
||||
-DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
|
||||
-DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
|
||||
-DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
|
||||
\
|
||||
-DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
|
||||
-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
|
||||
-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll \
|
||||
\
|
||||
-DCUSTOM_GETTEXT_PATH=$libdir/gettext \
|
||||
-DGETTEXT_MSGFMT=`which msgfmt` \
|
||||
-DGETTEXT_DLL=$libdir/gettext/bin/libintl-8.dll \
|
||||
|
|
Loading…
Reference in New Issue