diff --git a/changes.txt b/changes.txt index 89217af7..950e088d 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- Add io::IUserData which can be set in SMaterial to make it easer passing additional material values to shaders - Add lens shift support for the camera and the perspective projection functions - TGA loader no longer reduces 24&32 bit TGA's with palettes to 16 bit. Thanks @erlehmann for report: https://irrlicht.sourceforge.io/forum/viewtopic.php?t=52925 - Fix compile error with OS X 10.10 SDK, bug #463. Thanks @Ryan Schmidt for report and patch. diff --git a/include/IUserData.h b/include/IUserData.h new file mode 100644 index 00000000..05ab632f --- /dev/null +++ b/include/IUserData.h @@ -0,0 +1,53 @@ +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef IRR_I_USER_DATA_H_INCLUDED +#define IRR_I_USER_DATA_H_INCLUDED + +#include "irrTypes.h" + +namespace irr +{ +namespace io +{ + class IAttributes; + struct SAttributeReadWriteOptions; + + //! Irrlicht may allow users to set their own data via those pointers + //! Irrlicht has no memory control over IUserData, the user is completely responsible for that + class IUserData + { + public: + //! To identify the class type. + //! You can for example use MAKE_IRR_ID to create four CC codes + virtual irr::u32 getType() const { return 0; } + + //! To be overloaded if comparisons matter + //! You can then cast other to your derived class + virtual bool compare(const IUserData& other) const + { + return getType() == other.getType(); + } + + //! Writes data attributes + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} + + //! Reads data attributes + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) {} + + //! Used internally by Irrlicht to check if data has changed + bool operator!=(const IUserData& other) const + { + return !compare(other); + } + + protected: + // Irrlicht is never allowed to delete this + // If users want to delete such objects they should go over derived classes + ~IUserData() {} + }; + +} // end namespace io +} // end namespace irr + +#endif // IRR_I_USER_DATA_H_INCLUDED diff --git a/include/SMaterial.h b/include/SMaterial.h index d77727f7..58fab42f 100644 --- a/include/SMaterial.h +++ b/include/SMaterial.h @@ -11,6 +11,7 @@ #include "EMaterialTypes.h" #include "EMaterialFlags.h" #include "SMaterialLayer.h" +#include "IUserData.h" namespace irr { @@ -313,7 +314,8 @@ namespace video PolygonOffsetFactor(0), PolygonOffsetDirection(EPO_FRONT), Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), ZWriteEnable(EZW_AUTO), BackfaceCulling(true), FrontfaceCulling(false), - FogEnable(false), NormalizeNormals(false), UseMipMaps(true) + FogEnable(false), NormalizeNormals(false), UseMipMaps(true), + UserData(0) { } //! Texture layer array. @@ -493,6 +495,11 @@ namespace video /** Sometimes, disabling mipmap usage can be useful. Default: true */ bool UseMipMaps:1; + //! Allow users to add their own material data + //! User is resonsible for the memory of this pointer + //! You should override IUserData::compare for user custom data, so SMaterial knows when it changes + io::IUserData* UserData; + //! Gets the texture transformation matrix for level i /** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES \return Texture matrix for texture level i. */ @@ -713,7 +720,8 @@ namespace video PolygonOffsetSlopeScale != b.PolygonOffsetSlopeScale || PolygonOffsetFactor != b.PolygonOffsetFactor || PolygonOffsetDirection != b.PolygonOffsetDirection || - UseMipMaps != b.UseMipMaps + UseMipMaps != b.UseMipMaps || + UserData != b.UserData || (UserData && b.UserData && *UserData != *b.UserData) ; for (u32 i=0; (iaddFloat("PolygonOffsetDepthBias", material.PolygonOffsetDepthBias); attr->addFloat("PolygonOffsetSlopeScale", material.PolygonOffsetSlopeScale); + if ( material.UserData ) + material.UserData->serializeAttributes(attr, options); + // TODO: Would be nice to have a flag that only serializes rest of texture data when a texture pointer exists. prefix = "BilinearFilter"; for (i=0; igetAttributeAsFloat("PolygonOffsetDepthBias", outMaterial.PolygonOffsetDepthBias); outMaterial.PolygonOffsetSlopeScale = attr->getAttributeAsFloat("PolygonOffsetSlopeScale", outMaterial.PolygonOffsetSlopeScale); + if ( outMaterial.UserData ) + outMaterial.UserData->deserializeAttributes(attr); + prefix = "BilinearFilter"; if (attr->existsAttribute(prefix.c_str())) // legacy outMaterial.setFlag(EMF_BILINEAR_FILTER, attr->getAttributeAsBool(prefix.c_str())); diff --git a/source/Irrlicht/Irrlicht-gcc.cbp b/source/Irrlicht/Irrlicht-gcc.cbp index ce0e4459..85c87914 100644 --- a/source/Irrlicht/Irrlicht-gcc.cbp +++ b/source/Irrlicht/Irrlicht-gcc.cbp @@ -421,6 +421,7 @@ + @@ -1014,6 +1015,7 @@ + diff --git a/source/Irrlicht/Irrlicht10.0.vcxproj b/source/Irrlicht/Irrlicht10.0.vcxproj index f82357ae..12ae460d 100644 --- a/source/Irrlicht/Irrlicht10.0.vcxproj +++ b/source/Irrlicht/Irrlicht10.0.vcxproj @@ -871,6 +871,7 @@ + diff --git a/source/Irrlicht/Irrlicht10.0.vcxproj.filters b/source/Irrlicht/Irrlicht10.0.vcxproj.filters index ae0473a6..44edf1ac 100644 --- a/source/Irrlicht/Irrlicht10.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht10.0.vcxproj.filters @@ -1446,6 +1446,9 @@ Irrlicht\scene\sceneNodes + + include\io + diff --git a/source/Irrlicht/Irrlicht11.0.vcxproj b/source/Irrlicht/Irrlicht11.0.vcxproj index 76dc936a..2c3d280c 100644 --- a/source/Irrlicht/Irrlicht11.0.vcxproj +++ b/source/Irrlicht/Irrlicht11.0.vcxproj @@ -868,6 +868,7 @@ + diff --git a/source/Irrlicht/Irrlicht11.0.vcxproj.filters b/source/Irrlicht/Irrlicht11.0.vcxproj.filters index 504bd547..bbf0ab87 100644 --- a/source/Irrlicht/Irrlicht11.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht11.0.vcxproj.filters @@ -1437,7 +1437,19 @@ include - + + + include\scene + + + include\scene + + + Irrlicht\scene\sceneNodes + + + include\io + diff --git a/source/Irrlicht/Irrlicht12.0.vcxproj b/source/Irrlicht/Irrlicht12.0.vcxproj index 10cb6e86..31c2b236 100644 --- a/source/Irrlicht/Irrlicht12.0.vcxproj +++ b/source/Irrlicht/Irrlicht12.0.vcxproj @@ -868,6 +868,7 @@ + diff --git a/source/Irrlicht/Irrlicht12.0.vcxproj.filters b/source/Irrlicht/Irrlicht12.0.vcxproj.filters index 9c37ba74..3d56d1be 100644 --- a/source/Irrlicht/Irrlicht12.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht12.0.vcxproj.filters @@ -1437,7 +1437,19 @@ include - + + + include\scene + + + include\scene + + + Irrlicht\scene\sceneNodes + + + include\io + diff --git a/source/Irrlicht/Irrlicht14.0.vcxproj.filters b/source/Irrlicht/Irrlicht14.0.vcxproj.filters index 330b0260..3a973850 100644 --- a/source/Irrlicht/Irrlicht14.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht14.0.vcxproj.filters @@ -1438,6 +1438,18 @@ include + + include\scene + + + include\scene + + + Irrlicht\scene\sceneNodes + + + include\io + diff --git a/source/Irrlicht/Irrlicht15.0.vcxproj b/source/Irrlicht/Irrlicht15.0.vcxproj index 2378f798..b475c946 100644 --- a/source/Irrlicht/Irrlicht15.0.vcxproj +++ b/source/Irrlicht/Irrlicht15.0.vcxproj @@ -879,6 +879,7 @@ + diff --git a/source/Irrlicht/Irrlicht15.0.vcxproj.filters b/source/Irrlicht/Irrlicht15.0.vcxproj.filters index b4cd73ef..ce95b872 100644 --- a/source/Irrlicht/Irrlicht15.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht15.0.vcxproj.filters @@ -1437,7 +1437,19 @@ include - + + + include\scene + + + include\scene + + + Irrlicht\scene\sceneNodes + + + include\io + diff --git a/source/Irrlicht/Irrlicht16.0.vcxproj b/source/Irrlicht/Irrlicht16.0.vcxproj index 300ee8ec..0b4ef60d 100644 --- a/source/Irrlicht/Irrlicht16.0.vcxproj +++ b/source/Irrlicht/Irrlicht16.0.vcxproj @@ -606,6 +606,7 @@ + diff --git a/source/Irrlicht/Irrlicht16.0.vcxproj.filters b/source/Irrlicht/Irrlicht16.0.vcxproj.filters index 330b0260..3a973850 100644 --- a/source/Irrlicht/Irrlicht16.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht16.0.vcxproj.filters @@ -1438,6 +1438,18 @@ include + + include\scene + + + include\scene + + + Irrlicht\scene\sceneNodes + + + include\io + diff --git a/source/Irrlicht/Irrlicht17.0.vcxproj b/source/Irrlicht/Irrlicht17.0.vcxproj index 5da6b92a..4c2302df 100644 --- a/source/Irrlicht/Irrlicht17.0.vcxproj +++ b/source/Irrlicht/Irrlicht17.0.vcxproj @@ -614,6 +614,7 @@ + diff --git a/source/Irrlicht/Irrlicht17.0.vcxproj.filters b/source/Irrlicht/Irrlicht17.0.vcxproj.filters index 7cb136ed..3a973850 100644 --- a/source/Irrlicht/Irrlicht17.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht17.0.vcxproj.filters @@ -1438,9 +1438,18 @@ include + + include\scene + + + include\scene + Irrlicht\scene\sceneNodes + + include\io + diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 663ce94e..75518824 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Tue Oct 17 17:50:36 2023 +Test suite pass at GMT Tue Nov 07 15:09:58 2023