Skip to content
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

Underwater plantlike drawtype #5748

Closed
wants to merge 12 commits into from

Conversation

@numberZero
Copy link
Contributor

commented May 11, 2017

See #5381. In this implementation, plant height is param2 / 16.0 nodes.
screenshot_20170512_001303
Note: collision and selection boxes aren’t implemented yet. But unlike older version, this one draws the cube as a conventional solid node, thus using less faces.
@paramat

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented May 11, 2017

Note that the same way, mesh-on-solid nodes may be implemented, for the same uses.

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented May 11, 2017

Node used on the screenshot:

minetest.register_node("water_plant:papyrus", {
	description = "Papyrus-on-Sand",
	drawtype = "plantlike_rooted", -- updated; was "plantlike_water"
	tiles = {"default_sand.png"},
	special_tiles = {{name = "default_papyrus.png", tileable_vertical = true}},
	paramtype2 = "leveled",
	groups = {snappy = 3, flammable = 2},

	after_place_node = function(pos)
		local node = minetest.get_node(pos)
		node.param2 = math.random(32, 64)
		minetest.swap_node(pos, node)
	end,
})
@paramat

This comment has been minimized.

Copy link
Member

commented May 11, 2017

Good to see this.

I have a request, please can plant height be equal to param2 to disallow non-integer heights?
Through use of visual_scale normal plantlike can of course be scaled to any fractional height, however the whole texture is scaled so the texture is complete. Here a fractional height cuts a texture into a partial texture, which may not be a problem with papyrus but will be crude with other textures. So because this uses tiled textures i feel fractional heights should not be allowed.
Also, fractional heights is inconsistent in design with normal plantlike consisting of stacked plantlike nodes, and looks out of place.

Where in the code is the base cube drawn? all i see is:

+void MapblockMeshGenerator::drawPlantlikeWaterNode()
+{
+	useTile(0, MATERIAL_FLAG_CRACK_OVERLAY, 0, true);
+	origin += v3f(0.0, BS, 0.0);
+	drawPlantlike();
+}

I assume the basic idea is the same as mine, the actual node position is the cube below.

Looks like using 'special tiles' for the plantlike planes means that 6 differing tiles can be used for the base cube, that's good.

@sofar

This comment has been minimized.

Copy link
Member

commented May 12, 2017

Can you add screenshots how this looks in relation with flowing water, or just plainly by itself? What happens when the water around it drains? etc?

@Ferk

This comment has been minimized.

Copy link
Contributor

commented May 12, 2017

Even though I still think it would be awesome if someone manages to figure out a more generic (less hackish) and simple way of preventing bubbles on submerged nodes, I think this is a good idea in this form, not only will this be already enough to get aquatic plantlife in a simple way but it can actually have uses in the surface too.

Maybe the drawtype name could be "plantlike_root", instead of "plantlike_water". After all the node itself is in the root. I can see this being used in dry land for having plants that can grow / shrink in a controllable way without adding tons of lua logic or extra nodes.

Is it possible to have it at length zero with no plant? that way it would be possible in lua to override the on_dig so instead of removing the plant completely the root is left in the ground and on_timer be set for it to regrow after a while.

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented May 12, 2017

to disallow non-integer heights

Er, what? Don’t want fractional height, don’t use it, what’s the problem?

Where in the code is the base cube drawn?

The node is drawn in 2 places: first, as an usual solid node (due to solidness=2), like NDT_NORMAL; there the cube is drawn (only outer faces, if any, as with all true solid nodes); second, in content_mapblock.cpp; there only the plant is drawn, just like that well-known NDT_PLANTLIKE, to which I added an option of custom height plants.

BTW, that’s why I had to use special tiles for the plant. But that appeared to be unsupported by the inventory.

I assume the basic idea is the same as mine, the actual node position is the cube below.

True. In the current version, that’s also its selection and collision box. But that may be fixed the same way as for leveled nodes.

Can you add screenshots how this looks in relation with flowing water, or just plainly by itself?

Okay.

more generic <...> way

#4869 (comment)
https://wiki.minetest.net/User:Numzero/NodeEntity (just a draft)

the drawtype name could be "plantlike_root"

Okay.

Is it possible to have it at length zero with no plant?

Yes, although I hadn’t planned that so added no special handling, thus the zero-height plant may be visible e.g. in the wireframe view.

@@ -340,6 +340,10 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
setExtruded(tsrc->getTextureName(f.tiles[0].layers[0].texture_id),
def.wield_scale, tsrc,
f.tiles[0].layers[0].animation_frame_count);
} else if (f.drawtype == NDT_PLANTLIKE_WATER) {

This comment has been minimized.

Copy link
@nerzhul

nerzhul May 13, 2017

Member

time to start to use a switch case

This comment has been minimized.

Copy link
@paramat

paramat Jun 23, 2017

Member

Seems done.

@paramat

This comment has been minimized.

Copy link
Member

commented May 13, 2017

I have a request, please can plant height be equal to param2 to disallow non-integer heights?

Sorry, i'm actually fine with this, it's like a levelled node and it is down to subgames to either use or not use the feature.

@paramat

This comment has been minimized.

Copy link
Member

commented May 13, 2017

Maybe the drawtype name could be "plantlike_root"

Not sure, 'plantlike_water' describes the primary use clearly, although it should probably be 'plantlike_liquid' to be general. 'root' implies just the root, 'plantlike_rooted' would be better.

It is good that the base cube is the collisionbox, plantlike is almost always non-walkable and the base cube needs to be walkable.

Selectionbox could perhaps be the base cube plus the cube above, to cover the typical minimum size, and to distinguish it from a normal node if the plantlike textures are reduced to zero. This may also stop nodes being placed just above the base cube with the plant passing through the placed node unaffected.

I'm very happy to see you working on this, you are better qualified and have implemented it better than i would have.

@Wuzzy2

This comment has been minimized.

Copy link
Contributor

commented May 19, 2017

Applause! Definitely needed for algae, corals, etc.

Great for adding underwater life. :-)

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2017

Can you add screenshots how this looks in relation with flowing water, or just plainly by itself?

screenshot_20170520_234328
Zero height plants are indistinguishable from usual sand nodes, except of in wireframe view (requires a priv):
screenshot_20170520_234248

@numberZero numberZero force-pushed the numberZero:plantlike-water branch from a4e033f to b9c9666 May 20, 2017

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2017

rebased! @nerzhul

@paramat

This comment has been minimized.

Copy link
Member

commented May 22, 2017

Because the actual node is the base, the flowing, rising or draining of liquids above are unnaffected.

@nerzhul nerzhul added this to Feature PR in Minetest 5.0.0 blockers May 23, 2017

@numberZero numberZero changed the title [WIP] Underwater plantlike drawtype Underwater plantlike drawtype Jun 3, 2017

@paramat

This comment has been minimized.

Copy link
Member

commented Jun 23, 2017

Still WIP?

Switch case now used.

@numberZero numberZero force-pushed the numberZero:plantlike-water branch from 826ec09 to 8d89e46 Jun 24, 2017

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2017

rebased again. Not a WIP, unless you want me to improve it. @paramat @nerzhul

@@ -73,33 +73,49 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector
blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
}

void MapblockMeshGenerator::useTile(int index, bool disable_backface_culling)
void MapblockMeshGenerator::useTile(int index, int set_flags, int reset_flags, bool special)

This comment has been minimized.

Copy link
@SmallJoker

SmallJoker Jun 25, 2017

Member

Tile flags are u8, the same type should be used here.

}
}

void MapblockMeshGenerator::useDefaultTile(bool set_color)
void MapblockMeshGenerator::getTile(const v3s16& direction, TileSpec *tile)

This comment has been minimized.

Copy link
@SmallJoker

SmallJoker Jun 25, 2017

Member

const v3s16 &direction

This comment has been minimized.

Copy link
@nerzhul

nerzhul Jun 25, 2017

Member

you can remove the const ref for v3s16 as it's 48b then its cost less to copy object than transport 64b reference

@numberZero numberZero force-pushed the numberZero:plantlike-water branch from 159d87f to d811164 Jul 5, 2017

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented Jul 5, 2017

rebased

@numberZero

This comment has been minimized.

Copy link
Contributor Author

commented Jul 5, 2017

screenshot_20170706_000921
waving works, too.
screenshot_20170706_002017
liquid papyrus...

Does this make the base cube wave also?

No.

Should plantlike rooted wave like leaves? It doesn't seem to make sense.

Maybe, but who knows... E.g. if the texture has transparent bottom, it may look interesting.

@paramat

This comment has been minimized.

Copy link
Member

commented Jul 6, 2017

Ok, i have no objection to allowing both types of waving.

@paramat

This comment has been minimized.

Copy link
Member

commented Jul 6, 2017

Tested, bug fixed and waving works 👍

@paramat paramat added the One approval label Jul 6, 2017

@paramat

This comment has been minimized.

Copy link
Member

commented Jul 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.