-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add VoxelArea support #34
Comments
-- mapnode.h
-- Built-in Content IDs (for use with VoxelManip API)
core.CONTENT_UNKNOWN = 125
core.CONTENT_AIR = 126
core.CONTENT_IGNORE = 127 Content id allocation // returns CONTENT_IGNORE if no free ID found
content_t NodeDefManager::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 found
return CONTENT_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. |
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 byMinEdge
andMaxEdge
.getVolume()
: returns the volume of the area formed byMinEdge
andMaxEdge
.index(x, y, z)
: returns the index of an absolute position in a flat arraystarting at
1
.x
,y
andz
must be integers to avoid an incorrect index result.being outside can cause an incorrect index result.
VoxelManip
, raw Schematic specifiers,PerlinNoiseMap:get2d
/3dMap
, and so on.indexp(p)
: same functionality asindex(x, y, z)
but takes a vector.index(x, y, z)
, the components ofp
must be integers, andp
is not checked for being inside the area volume.
position(i)
: returns the absolute position vector corresponding to indexi
.contains(x, y, z)
: check if (x
,y
,z
) is inside area formed byMinEdge
andMaxEdge
.containsp(p)
: same as above, except takes a vectorcontainsi(i)
: same as above, except takes an indexi
iter(minx, miny, minz, maxx, maxy, maxz)
: returns an iterator that returnsindices.
minx
,miny
,minz
) to (maxx
,maxy
,maxz
) in the order of[z [y [x]]]
.iterp(minp, maxp)
: same as above, except takes a vectorThe text was updated successfully, but these errors were encountered: