mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
MeshMakeData: Explain members, and add grid size and minimap flag
This commit is contained in:
parent
c0ce918d77
commit
d044c27b5f
6 changed files with 49 additions and 35 deletions
|
@ -26,9 +26,11 @@
|
|||
MeshMakeData
|
||||
*/
|
||||
|
||||
MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length):
|
||||
side_length(side_length),
|
||||
nodedef(ndef)
|
||||
MeshMakeData::MeshMakeData(const NodeDefManager *ndef,
|
||||
u16 side_length, MeshGrid mesh_grid) :
|
||||
m_side_length(side_length),
|
||||
m_mesh_grid(mesh_grid),
|
||||
m_nodedef(ndef)
|
||||
{}
|
||||
|
||||
void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos)
|
||||
|
@ -38,8 +40,9 @@ void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos)
|
|||
v3s16 blockpos_nodes = m_blockpos*MAP_BLOCKSIZE;
|
||||
|
||||
m_vmanip.clear();
|
||||
// extra 1 block thick layer around the mesh
|
||||
VoxelArea voxel_area(blockpos_nodes - v3s16(1,1,1) * MAP_BLOCKSIZE,
|
||||
blockpos_nodes + v3s16(1,1,1) * (side_length + MAP_BLOCKSIZE /* extra layer of blocks around the mesh */) - v3s16(1,1,1));
|
||||
blockpos_nodes + v3s16(1,1,1) * (m_side_length + MAP_BLOCKSIZE) - v3s16(1,1,1));
|
||||
m_vmanip.addArea(voxel_area);
|
||||
}
|
||||
|
||||
|
@ -128,7 +131,7 @@ u16 getFaceLight(MapNode n, MapNode n2, const NodeDefManager *ndef)
|
|||
static u16 getSmoothLightCombined(const v3s16 &p,
|
||||
const std::array<v3s16,8> &dirs, MeshMakeData *data)
|
||||
{
|
||||
const NodeDefManager *ndef = data->nodedef;
|
||||
const NodeDefManager *ndef = data->m_nodedef;
|
||||
|
||||
u16 ambient_occlusion = 0;
|
||||
u16 light_count = 0;
|
||||
|
@ -316,7 +319,7 @@ void final_color_blend(video::SColor *result,
|
|||
*/
|
||||
void getNodeTileN(MapNode mn, const v3s16 &p, u8 tileindex, MeshMakeData *data, TileSpec &tile)
|
||||
{
|
||||
const NodeDefManager *ndef = data->nodedef;
|
||||
const NodeDefManager *ndef = data->m_nodedef;
|
||||
const ContentFeatures &f = ndef->get(mn);
|
||||
tile = f.tiles[tileindex];
|
||||
bool has_crack = p == data->m_crack_pos_relative;
|
||||
|
@ -336,7 +339,7 @@ void getNodeTileN(MapNode mn, const v3s16 &p, u8 tileindex, MeshMakeData *data,
|
|||
*/
|
||||
void getNodeTile(MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *data, TileSpec &tile)
|
||||
{
|
||||
const NodeDefManager *ndef = data->nodedef;
|
||||
const NodeDefManager *ndef = data->m_nodedef;
|
||||
|
||||
// Direction must be (1,0,0), (-1,0,0), (0,1,0), (0,-1,0),
|
||||
// (0,0,1), (0,0,-1) or (0,0,0)
|
||||
|
@ -588,7 +591,7 @@ void PartialMeshBuffer::draw(video::IVideoDriver *driver) const
|
|||
MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offset):
|
||||
m_tsrc(client->getTextureSource()),
|
||||
m_shdrsrc(client->getShaderSource()),
|
||||
m_bounding_sphere_center((data->side_length * 0.5f - 0.5f) * BS),
|
||||
m_bounding_sphere_center((data->m_side_length * 0.5f - 0.5f) * BS),
|
||||
m_animation_force_timer(0), // force initial animation
|
||||
m_last_crack(-1)
|
||||
{
|
||||
|
@ -597,10 +600,12 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
|
|||
for (auto &m : m_mesh)
|
||||
m = make_irr<scene::SMesh>();
|
||||
|
||||
auto mesh_grid = client->getMeshGrid();
|
||||
auto mesh_grid = data->m_mesh_grid;
|
||||
v3s16 bp = data->m_blockpos;
|
||||
// Only generate minimap mapblocks at even coordinates.
|
||||
if (mesh_grid.isMeshPos(bp) && client->getMinimap()) {
|
||||
// Only generate minimap mapblocks at grid aligned coordinates.
|
||||
// FIXME: ^ doesn't really make sense. and in practice, bp is always aligned
|
||||
if (mesh_grid.isMeshPos(bp) && data->m_generate_minimap) {
|
||||
// meshgen area always fits into a grid cell
|
||||
m_minimap_mapblocks.resize(mesh_grid.getCellVolume(), nullptr);
|
||||
v3s16 ofs;
|
||||
|
||||
|
@ -617,15 +622,10 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
|
|||
}
|
||||
}
|
||||
|
||||
// algin vertices to mesh grid, not meshgen area
|
||||
v3f offset = intToFloat((data->m_blockpos - mesh_grid.getMeshPos(data->m_blockpos)) * MAP_BLOCKSIZE, BS);
|
||||
|
||||
MeshCollector collector(m_bounding_sphere_center, offset);
|
||||
/*
|
||||
Add special graphics:
|
||||
- torches
|
||||
- flowing water
|
||||
- fences
|
||||
- whatever
|
||||
*/
|
||||
|
||||
{
|
||||
MapblockMeshGenerator(data, &collector).generate();
|
||||
|
@ -731,7 +731,7 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
|
|||
}
|
||||
}
|
||||
|
||||
m_bsp_tree.buildTree(&m_transparent_triangles, data->side_length);
|
||||
m_bsp_tree.buildTree(&m_transparent_triangles, data->m_side_length);
|
||||
|
||||
// Check if animation is required for this mesh
|
||||
m_has_animation =
|
||||
|
@ -942,19 +942,19 @@ u8 get_solid_sides(MeshMakeData *data)
|
|||
{
|
||||
std::unordered_map<v3s16, u8> results;
|
||||
v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
|
||||
const NodeDefManager *ndef = data->nodedef;
|
||||
const NodeDefManager *ndef = data->m_nodedef;
|
||||
|
||||
u8 result = 0x3F; // all sides solid;
|
||||
|
||||
for (s16 i = 0; i < data->side_length && result != 0; i++)
|
||||
for (s16 j = 0; j < data->side_length && result != 0; j++) {
|
||||
for (s16 i = 0; i < data->m_side_length && result != 0; i++)
|
||||
for (s16 j = 0; j < data->m_side_length && result != 0; j++) {
|
||||
v3s16 positions[6] = {
|
||||
v3s16(0, i, j),
|
||||
v3s16(data->side_length - 1, i, j),
|
||||
v3s16(data->m_side_length - 1, i, j),
|
||||
v3s16(i, 0, j),
|
||||
v3s16(i, data->side_length - 1, j),
|
||||
v3s16(i, data->m_side_length - 1, j),
|
||||
v3s16(i, j, 0),
|
||||
v3s16(i, j, data->side_length - 1)
|
||||
v3s16(i, j, data->m_side_length - 1)
|
||||
};
|
||||
|
||||
for (u8 k = 0; k < 6; k++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue