From e0f7bd4d57bf0c9b497c4d0bb73f7bd4d5cc0643 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 3 Apr 2011 19:50:54 +0300 Subject: Modified block mesh generation to have clearer input and output. Instead of being a messy object oriented cludge, it now is a messy cludge with separate parameters. --- src/mapblock.h | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'src/mapblock.h') diff --git a/src/mapblock.h b/src/mapblock.h index 6af4070bc..1894269bd 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "voxel.h" #include "nodemetadata.h" + // Named by looking towards z+ enum{ FACE_BACK=0, @@ -157,6 +158,23 @@ public: virtual u16 nodeContainerId() const = 0; }; +/* + Plain functions in mapblock.cpp +*/ + +u8 getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2, + v3s16 face_dir); + +scene::SMesh* makeMapBlockMesh( + u32 daynight_ratio, + NodeModMap &temp_mods, + VoxelManipulator &vmanip, + v3s16 blockpos_nodes); + +/* + MapBlock itself +*/ + class MapBlock : public NodeContainer { public: @@ -380,11 +398,18 @@ public: Graphics-related methods */ - // A quick version with nodes passed as parameters + /*// A quick version with nodes passed as parameters u8 getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2, - v3s16 face_dir); - // A more convenient version + v3s16 face_dir);*/ + /*// A more convenient version u8 getFaceLight(u32 daynight_ratio, v3s16 p, v3s16 face_dir) + { + return getFaceLight(daynight_ratio, + getNodeParentNoEx(p), + getNodeParentNoEx(p + face_dir), + face_dir); + }*/ + u8 getFaceLight2(u32 daynight_ratio, v3s16 p, v3s16 face_dir) { return getFaceLight(daynight_ratio, getNodeParentNoEx(p), @@ -394,14 +419,14 @@ public: #ifndef SERVER // light = 0...255 - static void makeFastFace(TileSpec tile, u8 light, v3f p, + /*static void makeFastFace(TileSpec tile, u8 light, v3f p, v3s16 dir, v3f scale, v3f posRelative_f, - core::array &dest); + core::array &dest);*/ - TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, - NodeModMap &temp_mods); - u8 getNodeContent(v3s16 p, MapNode mn, - NodeModMap &temp_mods); + /*TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, + NodeModMap &temp_mods);*/ + /*u8 getNodeContent(v3s16 p, MapNode mn, + NodeModMap &temp_mods);*/ /* Generates the FastFaces of a node row. This has a @@ -411,7 +436,7 @@ public: translate_dir: unit vector with only one of x, y or z face_dir: unit vector with only one of x, y or z */ - void updateFastFaceRow( + /*void updateFastFaceRow( u32 daynight_ratio, v3f posRelative_f, v3s16 startpos, @@ -421,12 +446,16 @@ public: v3s16 face_dir, v3f face_dir_f, core::array &dest, - NodeModMap &temp_mods); + NodeModMap &temp_mods);*/ /* Thread-safely updates the whole mesh of the mapblock. */ +#if 1 void updateMesh(u32 daynight_ratio); +#endif + + void replaceMesh(scene::SMesh *mesh_new); #endif // !SERVER @@ -545,6 +574,11 @@ public: return m_temp_mods.clear(); } + void copyTempMods(NodeModMap &dst) + { + JMutexAutoLock lock(m_temp_mods_mutex); + m_temp_mods.copy(dst); + } #endif /* -- cgit v1.2.3