You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A helper class for voxel areas.
It can be created via VoxelArea:new{MinEdge = pmin, MaxEdge = pmax}.
The coordinates are inclusive, like most other things in Minetest.
Methods
getExtent(): returns a 3D vector containing the size of the area formed by MinEdge and MaxEdge.
getVolume(): returns the volume of the area formed by MinEdge and MaxEdge.
index(x, y, z): returns the index of an absolute position in a flat array
starting at 1.
x, y and z must be integers to avoid an incorrect index result.
The position (x, y, z) is not checked for being inside the area volume,
being outside can cause an incorrect index result.
Useful for things like VoxelManip, raw Schematic specifiers, PerlinNoiseMap:get2d/3dMap, and so on.
indexp(p): same functionality as index(x, y, z) but takes a vector.
As with index(x, y, z), the components of p must be integers, and p
is not checked for being inside the area volume.
position(i): returns the absolute position vector corresponding to index i.
contains(x, y, z): check if (x,y,z) is inside area formed by MinEdge and MaxEdge.
containsp(p): same as above, except takes a vector
containsi(i): same as above, except takes an index i
iter(minx, miny, minz, maxx, maxy, maxz): returns an iterator that returns
indices.
from (minx,miny,minz) to (maxx,maxy,maxz) in the order of [z [y [x]]].
iterp(minp, maxp): same as above, except takes a vector
// returns CONTENT_IGNORE if no free ID foundcontent_tNodeDefManager::allocateId()
{
for (content_t id = m_next_id;
id >= m_next_id; // overflow?
++id) {
while (id >= m_content_features.size()) {
m_content_features.emplace_back();
}
const ContentFeatures &f = m_content_features[id];
if (f.name.empty()) {
m_next_id = id + 1;
return id;
}
}
// If we arrive here, an overflow occurred in id.// That means no ID was foundreturnCONTENT_IGNORE;
}
Variable m_next_id is reset to zero. First id returned by allocateId is 1 effectively making content id 1 based.
This should probably be using VoxelArea from engine core Lua libraries, VoxelArea class itself is just Lua helper and #74 already pulls that in when specified version is not "mineunit".
Having tests from #84 would probably still be useful even while it is engine library, tests would still allow some verification about Mineunit behavior.
Directory structure and loading of Minetest engine Lua libraries should be made better and more correct, when those were first added there was no plans to actually support many engine features.
Now things have changed a bit and a lot of Minetest c++ side things are already implemented. Mineunit is actually able to load significant amount of core Lua scripts and even pulls those directly from Minetest repo when asked to do so.
Activity
S-S-X commentedon Oct 28, 2021
Content id allocation
https://github.com/minetest/minetest/blob/8dfeba02b9f084ddd52090ccd906534200f468b3/src/nodedef.cpp#L1161-L1179
Variable m_next_id is reset to zero. First id returned by allocateId is 1 effectively making content id 1 based.
S-S-X commentedon Jun 11, 2022
This should probably be using VoxelArea from engine core Lua libraries, VoxelArea class itself is just Lua helper and #74 already pulls that in when specified version is not "mineunit".
Having tests from #84 would probably still be useful even while it is engine library, tests would still allow some verification about Mineunit behavior.
Directory structure and loading of Minetest engine Lua libraries should be made better and more correct, when those were first added there was no plans to actually support many engine features.
Now things have changed a bit and a lot of Minetest c++ side things are already implemented. Mineunit is actually able to load significant amount of core Lua scripts and even pulls those directly from Minetest repo when asked to do so.