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

make minimap respect airlike drawtype rather than air

This commit is contained in:
Xeno333 2025-06-11 00:30:33 -05:00
parent aba2b6638e
commit 8564434954
7 changed files with 62 additions and 6 deletions

23
mapgens/superflat/LICENSE Normal file
View file

@ -0,0 +1,23 @@
Imported from 1042 with modifications
MIT Licesnse:
Copyright (c) 2024 Xeno333
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1 @@
core.register_mapgen_script(core.get_modpath("superflat") .. "/mapgen.lua")

View file

@ -0,0 +1,4 @@
name = superflat
title = Superflat
description = Example mapgen with superflat world.
author = TX_Miner/Xeno333

View file

@ -0,0 +1,26 @@
local stone = core.get_content_id("mapgen_stone")
core.register_on_generated(function(vm, minp, maxp, seed)
local emin, emax = vm:get_emerged_area()
local area = VoxelArea(emin, emax)
local data = vm:get_data()
local ly = 0
for y = minp.y, maxp.y do
ly = ly + 1
local lz = 0
for z = minp.z, maxp.z do
lz = lz + 1
local vi = area:index(minp.x, y, z)
local lx = 0
for x = minp.x, maxp.x do
if y == -1 then
data[vi] = stone
end
vi = vi + 1
end
end
end
vm:set_data(data)
end)

View file

@ -626,7 +626,7 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data):
if (data->m_vmanip.getNodeNoEx(p).getContent() != CONTENT_IGNORE) { if (data->m_vmanip.getNodeNoEx(p).getContent() != CONTENT_IGNORE) {
MinimapMapblock *block = new MinimapMapblock; MinimapMapblock *block = new MinimapMapblock;
m_minimap_mapblocks[mesh_grid.getOffsetIndex(ofs)] = block; m_minimap_mapblocks[mesh_grid.getOffsetIndex(ofs)] = block;
block->getMinimapNodes(&data->m_vmanip, p); block->getMinimapNodes(data, p);
} }
} }
} }

View file

@ -713,9 +713,9 @@ void Minimap::updateActiveMarkers()
//// MinimapMapblock //// MinimapMapblock
//// ////
void MinimapMapblock::getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos) void MinimapMapblock::getMinimapNodes(MeshMakeData *meshdata, const v3s16 &pos)
{ {
VoxelManipulator *vmanip = &meshdata->m_vmanip;
for (s16 x = 0; x < MAP_BLOCKSIZE; x++) for (s16 x = 0; x < MAP_BLOCKSIZE; x++)
for (s16 z = 0; z < MAP_BLOCKSIZE; z++) { for (s16 z = 0; z < MAP_BLOCKSIZE; z++) {
s16 air_count = 0; s16 air_count = 0;
@ -725,11 +725,12 @@ void MinimapMapblock::getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos
for (s16 y = MAP_BLOCKSIZE -1; y >= 0; y--) { for (s16 y = MAP_BLOCKSIZE -1; y >= 0; y--) {
v3s16 p(x, y, z); v3s16 p(x, y, z);
MapNode n = vmanip->getNodeNoEx(pos + p); MapNode n = vmanip->getNodeNoEx(pos + p);
if (!surface_found && n.getContent() != CONTENT_AIR) { const ContentFeatures &f = meshdata->m_nodedef->get(n);
if (!surface_found && f.drawtype != NDT_AIRLIKE) {
mmpixel->height = y; mmpixel->height = y;
mmpixel->n = n; mmpixel->n = n;
surface_found = true; surface_found = true;
} else if (n.getContent() == CONTENT_AIR) { } else if (f.drawtype == NDT_AIRLIKE) {
air_count++; air_count++;
} }
} }

View file

@ -9,6 +9,7 @@
#include "rect.h" #include "rect.h"
#include "SMeshBuffer.h" #include "SMeshBuffer.h"
#include "mapblock_mesh.h"
#include "../hud.h" #include "../hud.h"
#include "mapnode.h" #include "mapnode.h"
#include "util/thread.h" #include "util/thread.h"
@ -66,7 +67,7 @@ struct MinimapPixel {
}; };
struct MinimapMapblock { struct MinimapMapblock {
void getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos); void getMinimapNodes(MeshMakeData *data, const v3s16 &pos);
MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE]; MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE];
}; };