mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Add particle blend mode "clip" (#15444)
This lets modders avoid alpha blending rendering bugs as well as potential (future) performance issues. The appropriate blend modes are also used for node dig particles. --------- Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
@@ -190,8 +190,10 @@ void ServerParticleTexture::serialize(std::ostream &os, u16 protocol_ver,
|
||||
FlagT flags = 0;
|
||||
if (animated)
|
||||
flags |= FlagT(ParticleTextureFlags::animated);
|
||||
if (blendmode != BlendMode::alpha)
|
||||
flags |= FlagT(blendmode) << 1;
|
||||
// Default to `blend = "alpha"` for older clients that don't support `blend = "clip"`
|
||||
auto sent_blendmode = (protocol_ver < 47 && blendmode == BlendMode::clip)
|
||||
? BlendMode::alpha : blendmode;
|
||||
flags |= FlagT(sent_blendmode) << 1;
|
||||
serializeParameterValue(os, flags);
|
||||
|
||||
alpha.serialize(os);
|
||||
@@ -215,6 +217,8 @@ void ServerParticleTexture::deSerialize(std::istream &is, u16 protocol_ver,
|
||||
|
||||
animated = !!(flags & FlagT(ParticleTextureFlags::animated));
|
||||
blendmode = BlendMode((flags & FlagT(ParticleTextureFlags::blend)) >> 1);
|
||||
if (blendmode >= BlendMode::BlendMode_END)
|
||||
throw SerializationError("invalid blend mode");
|
||||
|
||||
alpha.deSerialize(is);
|
||||
scale.deSerialize(is);
|
||||
|
Reference in New Issue
Block a user