From 0066bd77d25793b76fdaa9a62755cca934f0121d Mon Sep 17 00:00:00 2001 From: RealBadAngel Date: Wed, 15 Oct 2014 04:13:53 +0200 Subject: [PATCH 1/5] Add meshnode drawtype. --- doc/lua_api.txt | 14 ++- src/client.cpp | 2 +- src/content_mapblock.cpp | 12 ++ src/mapblock_mesh.cpp | 51 ++++++++ src/mapblock_mesh.h | 4 + src/mesh.cpp | 216 ++++++++++++++++++++++++++++++++ src/mesh.h | 21 ++++ src/nodedef.cpp | 48 ++++++- src/nodedef.h | 8 +- src/script/common/c_content.cpp | 3 + src/script/cpp_api/s_node.cpp | 1 + 11 files changed, 374 insertions(+), 6 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 131a63fa5..8f77366f7 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -103,6 +103,7 @@ mods | |-- screenshot.png | |-- description.txt | |-- init.lua +| |-- models | |-- textures | | |-- modname_stuff.png | | `-- modname_something_else.png @@ -137,6 +138,9 @@ init.lua: minetest.setting_get(name) and minetest.setting_getbool(name) can be used to read custom or existing settings at load time, if necessary. +models: + Models for entities or meshnodes. + textures, sounds, media: Media files (textures, sounds, whatever) that will be transferred to the client and will be available for use by the mod. @@ -430,6 +434,7 @@ Look for examples in games/minimal or games/minetest_game. - fencelike - raillike - nodebox -- See below. EXPERIMENTAL +- mesh -- use models for nodes *_optional drawtypes need less rendering time if deactivated (always client side) @@ -469,6 +474,12 @@ A box of a regular node would look like: type = "leveled" is same as "fixed", but y2 will be automatically set to level from param2 +Meshes +----------- +If drawtype "mesh" is used tiles should hold model materials textures. +Only static meshes are implemented. +For supported model formats see Irrlicht engine documentation. + Ore types --------------- These tell in what manner the ore is generated. @@ -2405,7 +2416,7 @@ Node definition (register_node) drawtype = "normal", -- See "Node drawtypes" visual_scale = 1.0, - ^ Supported for drawtypes "plantlike", "signlike", "torchlike". + ^ Supported for drawtypes "plantlike", "signlike", "torchlike", "mesh". ^ For plantlike, the image will start at the bottom of the node; for the ^ other drawtypes, the image will be centered on the node. ^ Note that positioning for "torchlike" may still change. @@ -2439,6 +2450,7 @@ Node definition (register_node) light_source = 0, -- Amount of light emitted by node damage_per_second = 0, -- If player is inside node, this damage is caused node_box = {type="regular"}, -- See "Node boxes" + mesh = "model", selection_box = {type="regular"}, -- See "Node boxes" ^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used legacy_facedir_simple = false, -- Support maps made in and before January 2012 diff --git a/src/client.cpp b/src/client.cpp index 4a00283ee..0bc2e66a5 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2678,7 +2678,7 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font) // Update node textures and assign shaders to each tile infostream<<"- Updating node textures"<updateTextures(m_tsrc, m_shsrc); + m_nodedef->updateTextures(this); // Preload item textures and meshes if configured to if(g_settings->getBool("preload_item_visuals")) diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index c84e75ac0..53b9874d4 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -1715,6 +1715,18 @@ void mapblock_mesh_generate_special(MeshMakeData *data, makeCuboid(&collector, box, tiles, 6, c, txc); } break;} + case NDT_MESH: + { + v3f pos = intToFloat(p, BS); + video::SColor c = MapBlock_LightColor(255, getInteriorLight(n, 1, nodedef), f.light_source); + u8 facedir = n.getFaceDir(nodedef); + for(u16 j = 0; j < f.mesh_ptr[facedir]->getMeshBufferCount(); j++) { + scene::IMeshBuffer *buf = f.mesh_ptr[facedir]->getMeshBuffer(j); + collector.append(getNodeTileN(n, p, j, data), + (video::S3DVertex *)buf->getVertices(), buf->getVertexCount(), + buf->getIndices(), buf->getIndexCount(), pos, c); + } + break;} } } } diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index d75d3e148..a7fafa683 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -1428,3 +1428,54 @@ void MeshCollector::append(const TileSpec &tile, p->vertices.push_back(vertices[i]); } } + +/* + MeshCollector - for meshnodes and converted drawtypes. +*/ + +void MeshCollector::append(const TileSpec &tile, + const video::S3DVertex *vertices, u32 numVertices, + const u16 *indices, u32 numIndices, + v3f pos, video::SColor c) +{ + if(numIndices > 65535) + { + dstream<<"FIXME: MeshCollector::append() called with numIndices="< 65535) + continue; + + p = &pp; + break; + } + + if(p == NULL) + { + PreMeshBuffer pp; + pp.tile = tile; + prebuffers.push_back(pp); + p = &prebuffers[prebuffers.size()-1]; + } + + u32 vertex_count = p->vertices.size(); + for(u32 i=0; iindices.push_back(j); + } + for(u32 i=0; ivertices.push_back(vert); + } +} diff --git a/src/mapblock_mesh.h b/src/mapblock_mesh.h index c52954998..e1cccc64e 100644 --- a/src/mapblock_mesh.h +++ b/src/mapblock_mesh.h @@ -174,6 +174,10 @@ struct MeshCollector void append(const TileSpec &material, const video::S3DVertex *vertices, u32 numVertices, const u16 *indices, u32 numIndices); + void append(const TileSpec &material, + const video::S3DVertex *vertices, u32 numVertices, + const u16 *indices, u32 numIndices, + v3f pos, video::SColor c); }; // This encodes diff --git a/src/mesh.cpp b/src/mesh.cpp index 3200d5fa6..19d75f9f5 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -408,3 +408,219 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh, } } } + +void rotateMeshBy6dFacedir(scene::IMesh *mesh, int facedir) +{ + int axisdir = facedir>>2; + facedir &= 0x03; + + u16 mc = mesh->getMeshBufferCount(); + for(u16 j = 0; j < mc; j++) + { + scene::IMeshBuffer *buf = mesh->getMeshBuffer(j); + video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); + u16 vc = buf->getVertexCount(); + for(u16 i=0; i bbox; + bbox.reset(0,0,0); + for(u16 j = 0; j < src_mesh->getMeshBufferCount(); j++) + { + scene::IMeshBuffer *buf = src_mesh->getMeshBuffer(j); + buf->recalculateBoundingBox(); + if(j == 0) + bbox = buf->getBoundingBox(); + else + bbox.addInternalBox(buf->getBoundingBox()); + } + src_mesh->setBoundingBox(bbox); +} + +scene::IMesh* cloneMesh(scene::IMesh *src_mesh) +{ + scene::SMesh* dst_mesh = new scene::SMesh(); + for(u16 j = 0; j < src_mesh->getMeshBufferCount(); j++) + { + scene::IMeshBuffer *buf = src_mesh->getMeshBuffer(j); + video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); + u16 *indices = (u16*)buf->getIndices(); + scene::SMeshBuffer *temp_buf = new scene::SMeshBuffer(); + temp_buf->append(vertices, buf->getVertexCount(), + indices, buf->getIndexCount()); + dst_mesh->addMeshBuffer(temp_buf); + temp_buf->drop(); + } + return dst_mesh; +} + +scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f) +{ + scene::SMesh* dst_mesh = new scene::SMesh(); + for (u16 j = 0; j < 6; j++) + { + scene::IMeshBuffer *buf = new scene::SMeshBuffer(); + dst_mesh->addMeshBuffer(buf); + buf->drop(); + } + + video::SColor c(255,255,255,255); + + std::vector boxes = f->node_box.fixed; + + for(std::vector::iterator + i = boxes.begin(); + i != boxes.end(); i++) + { + aabb3f box = *i; + + f32 temp; + if (box.MinEdge.X > box.MaxEdge.X) + { + temp=box.MinEdge.X; + box.MinEdge.X=box.MaxEdge.X; + box.MaxEdge.X=temp; + } + if (box.MinEdge.Y > box.MaxEdge.Y) + { + temp=box.MinEdge.Y; + box.MinEdge.Y=box.MaxEdge.Y; + box.MaxEdge.Y=temp; + } + if (box.MinEdge.Z > box.MaxEdge.Z) + { + temp=box.MinEdge.Z; + box.MinEdge.Z=box.MaxEdge.Z; + box.MaxEdge.Z=temp; + } + // Compute texture coords + f32 tx1 = (box.MinEdge.X/BS)+0.5; + f32 ty1 = (box.MinEdge.Y/BS)+0.5; + f32 tz1 = (box.MinEdge.Z/BS)+0.5; + f32 tx2 = (box.MaxEdge.X/BS)+0.5; + f32 ty2 = (box.MaxEdge.Y/BS)+0.5; + f32 tz2 = (box.MaxEdge.Z/BS)+0.5; + f32 txc[24] = { + // up + tx1, 1-tz2, tx2, 1-tz1, + // down + tx1, tz1, tx2, tz2, + // right + tz1, 1-ty2, tz2, 1-ty1, + // left + 1-tz2, 1-ty2, 1-tz1, 1-ty1, + // back + 1-tx2, 1-ty2, 1-tx1, 1-ty1, + // front + tx1, 1-ty2, tx2, 1-ty1, + }; + v3f min = box.MinEdge; + v3f max = box.MaxEdge; + + video::S3DVertex vertices[24] = + { + // up + video::S3DVertex(min.X,max.Y,max.Z, 0,1,0, c, txc[0],txc[1]), + video::S3DVertex(max.X,max.Y,max.Z, 0,1,0, c, txc[2],txc[1]), + video::S3DVertex(max.X,max.Y,min.Z, 0,1,0, c, txc[2],txc[3]), + video::S3DVertex(min.X,max.Y,min.Z, 0,1,0, c, txc[0],txc[3]), + // down + video::S3DVertex(min.X,min.Y,min.Z, 0,-1,0, c, txc[4],txc[5]), + video::S3DVertex(max.X,min.Y,min.Z, 0,-1,0, c, txc[6],txc[5]), + video::S3DVertex(max.X,min.Y,max.Z, 0,-1,0, c, txc[6],txc[7]), + video::S3DVertex(min.X,min.Y,max.Z, 0,-1,0, c, txc[4],txc[7]), + // right + video::S3DVertex(max.X,max.Y,min.Z, 1,0,0, c, txc[ 8],txc[9]), + video::S3DVertex(max.X,max.Y,max.Z, 1,0,0, c, txc[10],txc[9]), + video::S3DVertex(max.X,min.Y,max.Z, 1,0,0, c, txc[10],txc[11]), + video::S3DVertex(max.X,min.Y,min.Z, 1,0,0, c, txc[ 8],txc[11]), + // left + video::S3DVertex(min.X,max.Y,max.Z, -1,0,0, c, txc[12],txc[13]), + video::S3DVertex(min.X,max.Y,min.Z, -1,0,0, c, txc[14],txc[13]), + video::S3DVertex(min.X,min.Y,min.Z, -1,0,0, c, txc[14],txc[15]), + video::S3DVertex(min.X,min.Y,max.Z, -1,0,0, c, txc[12],txc[15]), + // back + video::S3DVertex(max.X,max.Y,max.Z, 0,0,1, c, txc[16],txc[17]), + video::S3DVertex(min.X,max.Y,max.Z, 0,0,1, c, txc[18],txc[17]), + video::S3DVertex(min.X,min.Y,max.Z, 0,0,1, c, txc[18],txc[19]), + video::S3DVertex(max.X,min.Y,max.Z, 0,0,1, c, txc[16],txc[19]), + // front + video::S3DVertex(min.X,max.Y,min.Z, 0,0,-1, c, txc[20],txc[21]), + video::S3DVertex(max.X,max.Y,min.Z, 0,0,-1, c, txc[22],txc[21]), + video::S3DVertex(max.X,min.Y,min.Z, 0,0,-1, c, txc[22],txc[23]), + video::S3DVertex(min.X,min.Y,min.Z, 0,0,-1, c, txc[20],txc[23]), + }; + + u16 indices[] = {0,1,2,2,3,0}; + + for(u16 j = 0; j < 24; j += 4) + { + scene::IMeshBuffer *buf = dst_mesh->getMeshBuffer(j / 4); + buf->append(vertices + j, 4, indices, 6); + } + } + return dst_mesh; +} diff --git a/src/mesh.h b/src/mesh.h index a89bea385..7539298cb 100644 --- a/src/mesh.h +++ b/src/mesh.h @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MESH_HEADER #include "irrlichttypes_extrabloated.h" +#include "nodedef.h" #include /* @@ -68,5 +69,25 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh, const video::SColor &colorX, const video::SColor &colorY, const video::SColor &colorZ); +/* + Rotate the mesh by 6d facedir value. + Method only for meshnodes, not suitable for entities. +*/ +void rotateMeshBy6dFacedir(scene::IMesh *mesh, int facedir); + +/* + Clone the mesh. +*/ +scene::IMesh* cloneMesh(scene::IMesh *src_mesh); + +/* + Convert nodebox drawtype node to mesh. +*/ +scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f); + +/* + Update bounding box for a mesh. +*/ +void recalculateBoundingBox(scene::IMesh *src_mesh); #endif diff --git a/src/nodedef.cpp b/src/nodedef.cpp index f1a7ad694..ef61d0722 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "itemdef.h" #ifndef SERVER #include "tile.h" +#include "mesh.h" #endif #include "log.h" #include "settings.h" @@ -31,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/serialize.h" #include "exceptions.h" #include "debug.h" +#include "gamedef.h" /* NodeBox @@ -195,6 +197,11 @@ void ContentFeatures::reset() // Unknown nodes can be dug groups["dig_immediate"] = 2; drawtype = NDT_NORMAL; + mesh = ""; +#ifndef SERVER + for(u32 i = 0; i < 24; i++) + mesh_ptr[i] = NULL; +#endif visual_scale = 1.0; for(u32 i = 0; i < 6; i++) tiledef[i] = TileDef(); @@ -295,6 +302,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) writeU8(os, waving); // Stuff below should be moved to correct place in a version that otherwise changes // the protocol version + os<tsrc(); + IShaderSource *shdsrc = gamedef->getShaderSource(); bool new_style_water = g_settings->getBool("new_style_water"); bool new_style_leaves = g_settings->getBool("new_style_leaves"); @@ -771,6 +783,10 @@ void CNodeDefManager::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc f->backface_culling = false; f->solidness = 0; break; + case NDT_MESH: + f->solidness = 0; + f->backface_culling = false; + break; case NDT_TORCHLIKE: case NDT_SIGNLIKE: case NDT_FENCELIKE: @@ -810,6 +826,34 @@ void CNodeDefManager::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc tile_shader[j], use_normal_texture, f->tiledef_special[j].backface_culling, f->alpha, material_type); } + + // Meshnode drawtype + // Read the mesh and apply scale + if ((f->drawtype == NDT_MESH) && (f->mesh != "")) { + f->mesh_ptr[0] = gamedef->getMesh(f->mesh); + scaleMesh(f->mesh_ptr[0], v3f(f->visual_scale,f->visual_scale,f->visual_scale)); + recalculateBoundingBox(f->mesh_ptr[0]); + } + + //Convert regular nodebox nodes to meshnodes + //Change the drawtype and apply scale + if ((f->drawtype == NDT_NODEBOX) && + ((f->node_box.type == NODEBOX_REGULAR) || (f->node_box.type == NODEBOX_FIXED)) && + (!f->node_box.fixed.empty())) { + f->drawtype = NDT_MESH; + f->mesh_ptr[0] = convertNodeboxNodeToMesh(f); + scaleMesh(f->mesh_ptr[0], v3f(f->visual_scale,f->visual_scale,f->visual_scale)); + recalculateBoundingBox(f->mesh_ptr[0]); + } + + //Cache 6dfacedir rotated clones of meshes + if (f->mesh_ptr[0] && (f->param_type_2 == CPT2_FACEDIR)) { + for (u16 j = 1; j < 24; j++) { + f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]); + rotateMeshBy6dFacedir(f->mesh_ptr[j], j); + recalculateBoundingBox(f->mesh_ptr[j]); + } + } } #endif } diff --git a/src/nodedef.h b/src/nodedef.h index b737e0237..2400f5f73 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -152,6 +152,7 @@ enum NodeDrawType NDT_FIRELIKE, // Draw faces slightly rotated and only on connecting nodes, NDT_GLASSLIKE_FRAMED_OPTIONAL, // enabled -> connected, disabled -> Glass-like // uses 2 textures, one for frames, second for faces + NDT_MESH, // Uses static meshes }; #define CF_SPECIAL_COUNT 6 @@ -187,6 +188,10 @@ struct ContentFeatures // Visual definition enum NodeDrawType drawtype; + std::string mesh; +#ifndef SERVER + scene::IMesh *mesh_ptr[24]; +#endif float visual_scale; // Misc. scale parameter TileDef tiledef[6]; TileDef tiledef_special[CF_SPECIAL_COUNT]; // eg. flowing liquid @@ -328,8 +333,7 @@ public: /* Update tile textures to latest return values of TextueSource. */ - virtual void updateTextures(ITextureSource *tsrc, - IShaderSource *shdsrc)=0; + virtual void updateTextures(IGameDef *gamedef)=0; virtual void serialize(std::ostream &os, u16 protocol_version)=0; virtual void deSerialize(std::istream &is)=0; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 2f749043e..4737f1993 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -281,6 +281,9 @@ ContentFeatures read_content_features(lua_State *L, int index) ScriptApiNode::es_DrawType,NDT_NORMAL); getfloatfield(L, index, "visual_scale", f.visual_scale); + /* Meshnode model filename */ + getstringfield(L, index, "mesh", f.mesh); + // tiles = {} lua_getfield(L, index, "tiles"); // If nil, try the deprecated name "tile_images" instead diff --git a/src/script/cpp_api/s_node.cpp b/src/script/cpp_api/s_node.cpp index 05f908004..e3d3fb58b 100644 --- a/src/script/cpp_api/s_node.cpp +++ b/src/script/cpp_api/s_node.cpp @@ -45,6 +45,7 @@ struct EnumString ScriptApiNode::es_DrawType[] = {NDT_FENCELIKE, "fencelike"}, {NDT_RAILLIKE, "raillike"}, {NDT_NODEBOX, "nodebox"}, + {NDT_MESH, "mesh"}, {0, NULL}, }; From fe8ef1be59399a327d9df50a0ab823bb2731de79 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Thu, 16 Oct 2014 17:47:54 +1000 Subject: [PATCH 2/5] Move buttons upwards to accommodate for new configure keys button in the pause menu --- src/game.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game.cpp b/src/game.cpp index 774d8f03e..2f228b0ed 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1036,7 +1036,8 @@ static void show_pause_menu(GUIFormSpecMenu** cur_formspec, "- T: chat\n" )); #endif - float ypos = singleplayermode ? 1.0 : 0.5; + + float ypos = singleplayermode ? 0.5 : 0.1; std::ostringstream os; os << FORMSPEC_VERSION_STRING << SIZE_TAG From 076c5ee2234c7f217f8941bbbd710d317485ccbc Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Tue, 7 Oct 2014 17:01:07 +1000 Subject: [PATCH 3/5] Various uninitialised variable fixes sky.cpp: m_bgcolor.getAlpha() was being used before initialised mesh related: m_highlight_mesh_color was being used uninitialised --- src/client.cpp | 1 + src/content_mapblock.cpp | 10 +++++----- src/mapblock_mesh.cpp | 8 +++++--- src/sky.cpp | 32 ++++++++++++++------------------ src/sky.h | 3 ++- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 0bc2e66a5..7e74cf36b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -250,6 +250,7 @@ Client::Client( m_inventory_updated(false), m_inventory_from_server(NULL), m_inventory_from_server_age(0.0), + m_show_hud(true), m_animation_time(0), m_crack_level(-1), m_crack_pos(0,0,0), diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 53b9874d4..996db421b 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -188,10 +188,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data, // Create selection mesh v3s16 p = data->m_highlighted_pos_relative; - if (data->m_show_hud & - (p.X >= 0) & (p.X < MAP_BLOCKSIZE) & - (p.Y >= 0) & (p.Y < MAP_BLOCKSIZE) & - (p.Z >= 0) & (p.Z < MAP_BLOCKSIZE)) { + if (data->m_show_hud && + (p.X >= 0) && (p.X < MAP_BLOCKSIZE) && + (p.Y >= 0) && (p.Y < MAP_BLOCKSIZE) && + (p.Z >= 0) && (p.Z < MAP_BLOCKSIZE)) { MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + p); if(n.getContent() != CONTENT_AIR) { @@ -215,7 +215,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data, l = l1; } video::SColor c = MapBlock_LightColor(255, l, 0); - data->m_highlight_mesh_color = c; + data->m_highlight_mesh_color = c; std::vector boxes = n.getSelectionBoxes(nodedef); TileSpec h_tile; h_tile.material_flags |= MATERIAL_FLAG_HIGHLIGHTED; diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index a7fafa683..2459cf0d7 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -48,6 +48,8 @@ MeshMakeData::MeshMakeData(IGameDef *gamedef): m_crack_pos_relative(-1337, -1337, -1337), m_highlighted_pos_relative(-1337, -1337, -1337), m_smooth_lighting(false), + m_show_hud(false), + m_highlight_mesh_color(255, 255, 255, 255), m_gamedef(gamedef) {} @@ -330,7 +332,7 @@ static void finalColorBlend(video::SColor& result, // Emphase blue a bit in darker places // Each entry of this array represents a range of 8 blue levels - static u8 emphase_blue_when_dark[32] = { + static const u8 emphase_blue_when_dark[32] = { 1, 4, 6, 6, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; @@ -338,7 +340,7 @@ static void finalColorBlend(video::SColor& result, b = irr::core::clamp (b, 0, 255); // Artificial light is yellow-ish - static u8 emphase_yellow_when_artificial[16] = { + static const u8 emphase_yellow_when_artificial[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 15, 15 }; rg += emphase_yellow_when_artificial[night/16]; @@ -1086,7 +1088,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): mapblock_mesh_generate_special(data, collector); - m_highlight_mesh_color = data->m_highlight_mesh_color; + m_highlight_mesh_color = data->m_highlight_mesh_color; /* Convert MeshCollector to SMesh diff --git a/src/sky.cpp b/src/sky.cpp index 17d8d46ce..b5706f4e3 100644 --- a/src/sky.cpp +++ b/src/sky.cpp @@ -573,6 +573,20 @@ void Sky::update(float time_of_day, float time_brightness, m_clouds_visible = false; } + video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor(); + m_bgcolor = video::SColor( + 255, + bgcolor_bright.getRed() * m_brightness, + bgcolor_bright.getGreen() * m_brightness, + bgcolor_bright.getBlue() * m_brightness); + + video::SColor skycolor_bright = m_skycolor_bright_f.toSColor(); + m_skycolor = video::SColor( + 255, + skycolor_bright.getRed() * m_brightness, + skycolor_bright.getGreen() * m_brightness, + skycolor_bright.getBlue() * m_brightness); + // Horizon coloring based on sun and moon direction during sunset and sunrise video::SColor pointcolor = video::SColor(255, 255, 255, m_bgcolor.getAlpha()); if (m_directional_colored_fog) { @@ -606,25 +620,7 @@ void Sky::update(float time_of_day, float time_brightness, // calculate the blend color pointcolor = m_mix_scolor(pointcolor_moon, pointcolor_sun, pointcolor_blend); } - } - - video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor(); - m_bgcolor = video::SColor( - 255, - bgcolor_bright.getRed() * m_brightness, - bgcolor_bright.getGreen() * m_brightness, - bgcolor_bright.getBlue() * m_brightness); - if (m_directional_colored_fog) { m_bgcolor = m_mix_scolor(m_bgcolor, pointcolor, m_horizon_blend() * 0.5); - } - - video::SColor skycolor_bright = m_skycolor_bright_f.toSColor(); - m_skycolor = video::SColor( - 255, - skycolor_bright.getRed() * m_brightness, - skycolor_bright.getGreen() * m_brightness, - skycolor_bright.getBlue() * m_brightness); - if (m_directional_colored_fog) { m_skycolor = m_mix_scolor(m_skycolor, pointcolor, m_horizon_blend() * 0.25); } diff --git a/src/sky.h b/src/sky.h index d7dabedb8..4af6be024 100644 --- a/src/sky.h +++ b/src/sky.h @@ -79,7 +79,8 @@ private: { if (!m_sunlight_seen) return 0; - float x; m_time_of_day >= 0.5 ? x = (1 - m_time_of_day) * 2 : x = m_time_of_day * 2; + float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2 : m_time_of_day * 2; + if (x <= 0.3) return 0; if (x <= 0.4) // when the sun and moon are aligned From b11e1db809aebc22f26887fffd50bd37f1fb6c3a Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 6 Oct 2014 13:39:03 +0200 Subject: [PATCH 4/5] Update the cURL the buildbot uses to 7.38.0 --- util/buildbot/buildwin32.sh | 12 ++++++------ util/buildbot/buildwin64.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/util/buildbot/buildwin32.sh b/util/buildbot/buildwin32.sh index 25964a9bb..99416bdbd 100755 --- a/util/buildbot/buildwin32.sh +++ b/util/buildbot/buildwin32.sh @@ -16,7 +16,7 @@ toolchain_file=$dir/toolchain_mingw.cmake irrlicht_version=1.8.1 ogg_version=1.2.1 vorbis_version=1.3.3 -curl_version=7.18.0 +curl_version=7.38.0 gettext_version=0.14.4 freetype_version=2.3.5 luajit_version=2.0.1 @@ -41,8 +41,8 @@ cd $builddir -c -O $packagedir/libvorbis-$vorbis_version-dev.7z [ -e $packagedir/libvorbis-$vorbis_version-dll.7z ] || wget http://sfan5.pf-control.de/libvorbis-$vorbis_version-dll.7z \ -c -O $packagedir/libvorbis-$vorbis_version-dll.7z -[ -e $packagedir/libcurl-$curl_version-win32-msvc.zip ] || wget http://curl.haxx.se/download/libcurl-$curl_version-win32-msvc.zip \ - -c -O $packagedir/libcurl-$curl_version-win32-msvc.zip +[ -e $packagedir/libcurl-$curl_version.zip ] || wget http://sfan5.pf-control.de/libcurl-$curl_version-win32.zip \ + -c -O $packagedir/libcurl-$curl_version.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/libfreetype-$freetype_version.zip ] || wget http://sfan5.pf-control.de/libfreetype-$freetype_version-win32.zip \ @@ -62,7 +62,7 @@ cd $libdir [ -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 libcurl ] || unzip -o $packagedir/libcurl-$curl_version.zip -d libcurl [ -d gettext ] || unzip -o $packagedir/gettext-$gettext_version.zip -d gettext [ -d freetype ] || unzip -o $packagedir/libfreetype-$freetype_version.zip -d freetype [ -d openal_stripped ] || unzip -o $packagedir/openal_stripped.zip @@ -123,9 +123,9 @@ cmake .. \ -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \ -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \ \ - -DCURL_DLL=$libdir/libcurl/libcurl.dll \ + -DCURL_DLL=$libdir/libcurl/bin/libcurl-4.dll \ -DCURL_INCLUDE_DIR=$libdir/libcurl/include \ - -DCURL_LIBRARY=$libdir/libcurl/libcurl.lib \ + -DCURL_LIBRARY=$libdir/libcurl/lib/libcurl.dll.a \ \ -DCUSTOM_GETTEXT_PATH=$libdir/gettext \ -DGETTEXT_MSGFMT=`which msgfmt` \ diff --git a/util/buildbot/buildwin64.sh b/util/buildbot/buildwin64.sh index 321985e1b..2380c6351 100755 --- a/util/buildbot/buildwin64.sh +++ b/util/buildbot/buildwin64.sh @@ -16,7 +16,7 @@ toolchain_file=$dir/toolchain_mingw64.cmake irrlicht_version=1.8.1 ogg_version=1.3.1 vorbis_version=1.3.4 -curl_version=7.36.0 +curl_version=7.38.0 gettext_version=0.18.2 freetype_version=2.5.3 luajit_version=2.0.3 From e5652cb75cd891895fab50ce46eb34ab9734d160 Mon Sep 17 00:00:00 2001 From: RealBadAngel Date: Sat, 18 Oct 2014 18:46:16 +0200 Subject: [PATCH 5/5] Custom collision boxes node property. --- doc/lua_api.txt | 12 ++++++++++-- src/collision.cpp | 2 +- src/mapnode.cpp | 9 +++++++++ src/mapnode.h | 8 ++++++-- src/nodedef.cpp | 3 +++ src/nodedef.h | 1 + src/script/common/c_content.cpp | 5 +++++ 7 files changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 8f77366f7..ff2143cc8 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -408,8 +408,16 @@ param2 is reserved for the engine when any of these are used: 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y- facedir's two less significant bits are rotation around the axis paramtype2 == "leveled" - ^ The drawn node level is read from param2, like flowingliquid - + collision_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + }, + }, + ^ defines list of collision boxes for the node. If empty, collision boxes + will be the same as nodeboxes, in case of any other nodes will be full cube + as in the example above. + Nodes can also contain extra data. See "Node Metadata". Node drawtypes diff --git a/src/collision.cpp b/src/collision.cpp index 76696e90d..edbee40b9 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -259,7 +259,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, continue; int n_bouncy_value = itemgroup_get(f.groups, "bouncy"); - std::vector nodeboxes = n.getNodeBoxes(gamedef->ndef()); + std::vector nodeboxes = n.getCollisionBoxes(gamedef->ndef()); for(std::vector::iterator i = nodeboxes.begin(); i != nodeboxes.end(); i++) diff --git a/src/mapnode.cpp b/src/mapnode.cpp index d52677be0..786224240 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -354,6 +354,15 @@ std::vector MapNode::getNodeBoxes(INodeDefManager *nodemgr) const return transformNodeBox(*this, f.node_box, nodemgr); } +std::vector MapNode::getCollisionBoxes(INodeDefManager *nodemgr) const +{ + const ContentFeatures &f = nodemgr->get(*this); + if (f.collision_box.fixed.empty()) + return transformNodeBox(*this, f.node_box, nodemgr); + else + return transformNodeBox(*this, f.collision_box, nodemgr); +} + std::vector MapNode::getSelectionBoxes(INodeDefManager *nodemgr) const { const ContentFeatures &f = nodemgr->get(*this); diff --git a/src/mapnode.h b/src/mapnode.h index f19885d87..d0b949e6f 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -217,8 +217,7 @@ struct MapNode void rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot); /* - Gets list of node boxes (used for rendering (NDT_NODEBOX) - and collision) + Gets list of node boxes (used for rendering (NDT_NODEBOX)) */ std::vector getNodeBoxes(INodeDefManager *nodemgr) const; @@ -227,6 +226,11 @@ struct MapNode */ std::vector getSelectionBoxes(INodeDefManager *nodemgr) const; + /* + Gets list of collision boxes + */ + std::vector getCollisionBoxes(INodeDefManager *nodemgr) const; + /* Liquid helpers */ u8 getMaxLevel(INodeDefManager *nodemgr) const; u8 getLevel(INodeDefManager *nodemgr) const; diff --git a/src/nodedef.cpp b/src/nodedef.cpp index ef61d0722..5735ef914 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -233,6 +233,7 @@ void ContentFeatures::reset() damage_per_second = 0; node_box = NodeBox(); selection_box = NodeBox(); + collision_box = NodeBox(); waving = 0; legacy_facedir_simple = false; legacy_wallmounted = false; @@ -303,6 +304,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) // Stuff below should be moved to correct place in a version that otherwise changes // the protocol version os<