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

Biome API: Add decoration flags for underground decorations #6519

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
4 participants
@paramat
Member

paramat commented Oct 11, 2017

Biome API: Add decoration flags for underground decorations

Add "all_floors" and "all_ceilings" flags for simple and schematic
decorations. Decorations are placed on all floor and/or ceiling surfaces.
Decorations are placed before dungeon generation so placement in dungeons
is not possible.

Add 'getSurfaces()' function to mapgen.cpp that returns 2 arrays of y
coordinates for all floor and ceiling surfaces in a specified node column.

Move 'getHeight()' checks into DecoSimple and DecoSchematic. Delete
'getHeight()' functions.
////////////////

screenshot_20171011_213919

Addresses #3871

Works for simple and schematic decorations, all existing functionality is preserved, but ceiling decorations necessarily have an inverted 'place offset y' parameter, so that '-1' always results in decorations being buried into their surface by 1 node.
Schematic ceiling decorations are shifted vertically such that by default their top node layer is level with the ceiling, to be an exact inversion of floor behaviour.

2 new decoration flags are added, a decoration can have either or both. If it has both the decoration will be generated on floors and ceilings within a single node column, the useful result is that this can then be used for realistically-vertically-aligned stalactites and stalagmites that sometimes meet in the middle to form columns.
If this vertical alignment is not wanted 2 separate decoration registrations can be used instead.

A getSurfaces() function is added to mapgen.cpp. For a specified node column in the specified volume it looks at node 'walkable' parameters and compiles 2 arrays: one for all floor surfaces and one for all ceiling surfaces. It also returns the size of each array.

Decoration code in current master randomly chooses a node column, finds the highest surface from the 'heightmap' array and places the decoration.

Now in this PR, for each node column chosen:
If the decoration has either or both of the 'floor' or 'ceiling' flags getSurfaces() is called to create the 2 arrays.
According to the flags for the decoration, either or both arrays are iterated through to place the decorations.

The getHeight() checks have been moved into DecoSimple and DecoSchematic as this is now the best place for checks for placement outside the voxelmanip. So the getHeight() functions have been deleted.

@C1ffisme

This comment has been minimized.

C1ffisme commented Oct 11, 2017

I assume the answer is yes, but will there be schematic support?

@paramat

This comment has been minimized.

Member

paramat commented Oct 11, 2017

Yes.

@paramat paramat changed the title from Biome API: Underground decorations to Biome API: Add underground decorations Oct 15, 2017

@paramat paramat added WIP and removed WIP labels Oct 15, 2017

@paramat

This comment has been minimized.

Member

paramat commented Oct 16, 2017

Updated to allow a decoration to be both 'all floors' and 'all ceilings', the result is that the decoration floor version lines up with the ceiling version and they sometimes meet in the middle, ideal for stalactites and stalagmites.

// Get all floors and ceilings in node column
s16 floors[1024];
s16 ceilings[1024];

This comment has been minimized.

@SmallJoker

SmallJoker Oct 16, 2017

Member

Why 1024? The array size should be set, depending on the block size.
(ymax - ymin) / 2 would be the maximal size of the array, if I'm not mistaken.

This comment has been minimized.

@paramat

paramat Oct 16, 2017

Member

Because placeAllDecos() can be called from minetest.generate_decorations which applies decorations to a lua voxelmanip of any size, i chose 1024 to be plenty big enough.

This comment has been minimized.

@paramat

paramat Oct 16, 2017

Member

Ah but we can get the size from nmax.Y - nmin.Y, ok will do.

This comment has been minimized.

@paramat

paramat Oct 16, 2017

Member

Tried but can't get it to work. When i replace 1024 with a variable both here and in getSurfaces() i get lots of errors, how should the arguments be in getSurfaces()?
Not sure it's worth it for saving just 2000 memory locations.

This comment has been minimized.

@SmallJoker

SmallJoker Oct 17, 2017

Member

What prevents you from passing pointers as arguments for these functions?

This comment has been minimized.

@paramat

paramat Oct 17, 2017

Member

Ok i know that's an alternative method, i'll try that.

This comment has been minimized.

@paramat

paramat Oct 27, 2017

Member

Done.

@paramat paramat added the WIP label Oct 20, 2017

@paramat

This comment has been minimized.

Member

paramat commented Oct 25, 2017

Updated to pass the arrays by pointer, this allows the arrays to be the minimum size necessary (nmax.Y - nmin.y + 1) / 2.

@paramat

This comment has been minimized.

Member

paramat commented Oct 25, 2017

Retested, now just need a better commit message and docs.

@paramat paramat removed the WIP label Oct 25, 2017

@paramat paramat changed the title from Biome API: Add underground decorations to Biome API: Add decoration flags for underground decorations Oct 27, 2017

@paramat

This comment has been minimized.

Member

paramat commented Oct 27, 2017

Done, now ready for merge.

@@ -193,6 +193,9 @@ class Mapgen {
s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
s16 findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax);
void updateHeightmap(v3s16 nmin, v3s16 nmax);
void getSurfaces(v2s16 p2d, s16 ymin, s16 ymax,
s16 *floors, s16 *ceilings, u16 *num_floors, u16 *num_ceilings);

This comment has been minimized.

@sfan5

sfan5 Oct 27, 2017

Member

2 more tabs

This comment has been minimized.

@paramat

paramat Oct 28, 2017

Member

Oops ok.

This comment has been minimized.

@paramat

paramat Oct 28, 2017

Member

Done with 1 tab indent to match the rest of the file.

Biome API: Add decoration flags for underground decorations
Add "all_floors" and "all_ceilings" flags for simple and schematic
decorations. Decorations are placed on all floor and/or ceiling surfaces.
Decorations are placed before dungeon generation so placement in dungeons
is not possible.

Add 'getSurfaces()' function to mapgen.cpp that returns 2 arrays of y
coordinates for all floor and ceiling surfaces in a specified node column.

Move 'getHeight()' checks into DecoSimple and DecoSchematic. Delete
'getHeight()' functions.
@paramat

This comment has been minimized.

Member

paramat commented Oct 28, 2017

@paramat

This comment has been minimized.

Member

paramat commented Oct 29, 2017

@paramat paramat closed this Oct 29, 2017

@paramat paramat referenced this pull request Oct 29, 2017

Closed

Underground decorations #3871

@paramat paramat deleted the paramat:underdecos branch Nov 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment