1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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.

This commit is contained in:
Perttu Ahola 2011-04-03 19:50:54 +03:00
parent 01c2b003e1
commit e0f7bd4d57
9 changed files with 240 additions and 83 deletions

View file

@ -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<FastFace> &dest);
core::array<FastFace> &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<FastFace> &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
/*