Material.ZWriteEnable is now of type E_ZWRITE instead of bool and ZWriteFineControl get removed (or merged into ZWriteEnable).

This breaks compiling. To have old values replace false with EZW_OFF and true with EWZ_AUTO.

There's a bit history to this change. ZWriteFineControl got introduced after 1.8 so it was never in a released version.
Basically it was needed after some changes had been made to allow shaders to have zwrite enabled independent
of the material-type (which worked badly for shaders). This had caused other problems as it was then enabled too often instead. 
So to quickly fix those bugs and avoid breaking compatibility I had introduced a new enum ZWriteFineControl in SMaterial.
This worked and didn't break compiling - but I noticed by now that introducing a second flag for this made maintainance for an already 
very hard to understand problem (figuring out the implementation of transparency and zwriting) even more complicated. 
So to keep maintance somewhat sane I decided to break compiling now and merge those two flags. 
The behavior should not be affected by this commit - except for users which set this flag already in their code and have to switch to the enum now.

Serialization is switched on loading old files (so SMaterial has enum already and writes that out).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6026 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2020-01-02 15:34:52 +00:00
parent fc37b383ed
commit 2928a632a4
22 changed files with 85 additions and 69 deletions

View File

@ -196,7 +196,7 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
InitMaterial2D.AntiAliasing=video::EAAM_OFF;
InitMaterial2D.Lighting=false;
InitMaterial2D.ZWriteEnable=false;
InitMaterial2D.ZWriteEnable=video::EZW_OFF;
InitMaterial2D.ZBuffer=video::ECFN_DISABLED;
InitMaterial2D.UseMipMaps=false;
for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i)
@ -1944,7 +1944,7 @@ void CNullDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
mat.AntiAliasing=0;
mat.ColorMask=ECP_NONE;
mat.GouraudShading=false;
mat.ZWriteEnable=false;
mat.ZWriteEnable=EZW_OFF;
setMaterial(mat);
}
setTransform(video::ETS_WORLD, node->getAbsoluteTransformation());
@ -2149,7 +2149,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria
attr->addBool("PointCloud", material.PointCloud);
attr->addBool("GouraudShading", material.GouraudShading);
attr->addBool("Lighting", material.Lighting);
attr->addBool("ZWriteEnable", material.ZWriteEnable);
attr->addEnum("ZWriteEnable", (irr::s32)material.ZWriteEnable, video::ZWriteNames);
attr->addInt("ZBuffer", material.ZBuffer);
attr->addBool("BackfaceCulling", material.BackfaceCulling);
attr->addBool("FrontfaceCulling", material.FrontfaceCulling);
@ -2165,7 +2165,6 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria
attr->addEnum("PolygonOffsetDirection", material.PolygonOffsetDirection, video::PolygonOffsetDirectionNames);
attr->addFloat("PolygonOffsetDepthBias", material.PolygonOffsetDepthBias);
attr->addFloat("PolygonOffsetSlopeScale", material.PolygonOffsetSlopeScale);
attr->addInt("ZWriteFineControl", material.ZWriteFineControl);
// TODO: Would be nice to have a flag that only serializes rest of texture data when a texture pointer exists.
prefix = "BilinearFilter";
@ -2228,7 +2227,13 @@ void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMater
outMaterial.PointCloud = attr->getAttributeAsBool("PointCloud", outMaterial.PointCloud);
outMaterial.GouraudShading = attr->getAttributeAsBool("GouraudShading", outMaterial.GouraudShading);
outMaterial.Lighting = attr->getAttributeAsBool("Lighting", outMaterial.Lighting);
outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable", outMaterial.ZWriteEnable);
io::E_ATTRIBUTE_TYPE attType = attr->getAttributeType("ZWriteEnable");
if (attType == io::EAT_BOOL ) // Before Irrlicht 1.9
outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable", outMaterial.ZWriteEnable != video::EZW_OFF ) ? video::EZW_AUTO : video::EZW_OFF;
else if (attType == io::EAT_ENUM )
outMaterial.ZWriteEnable = (video::E_ZWRITE)attr->getAttributeAsEnumeration("ZWriteEnable", video::ZWriteNames, outMaterial.ZWriteEnable);
outMaterial.ZBuffer = (u8)attr->getAttributeAsInt("ZBuffer", outMaterial.ZBuffer);
outMaterial.BackfaceCulling = attr->getAttributeAsBool("BackfaceCulling", outMaterial.BackfaceCulling);
outMaterial.FrontfaceCulling = attr->getAttributeAsBool("FrontfaceCulling", outMaterial.FrontfaceCulling);
@ -2245,7 +2250,7 @@ void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMater
outMaterial.PolygonOffsetDirection = (video::E_POLYGON_OFFSET)attr->getAttributeAsEnumeration("PolygonOffsetDirection", video::PolygonOffsetDirectionNames, outMaterial.PolygonOffsetDirection);
outMaterial.PolygonOffsetDepthBias = attr->getAttributeAsFloat("PolygonOffsetDepthBias", outMaterial.PolygonOffsetDepthBias);
outMaterial.PolygonOffsetSlopeScale = attr->getAttributeAsFloat("PolygonOffsetSlopeScale", outMaterial.PolygonOffsetSlopeScale);
outMaterial.ZWriteFineControl = (video::E_ZWRITE_FINE_CONTROL)attr->getAttributeAsInt("ZWriteFineControl", outMaterial.ZWriteFineControl);
prefix = "BilinearFilter";
if (attr->existsAttribute(prefix.c_str())) // legacy
outMaterial.setFlag(EMF_BILINEAR_FILTER, attr->getAttributeAsBool(prefix.c_str()));