1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Purge some dead code (mostly Irrlicht) (#16111)

* Remove obsolete Irrlicht attributes system

* Remove dead GUI element types

* Remove some obsolete Irrlicht headers

* Fix some oopsies from d96f5e1
This commit is contained in:
Lars Müller 2025-05-04 16:31:44 +02:00 committed by GitHub
parent 377fa5bb14
commit f4285a59ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 24 additions and 831 deletions

View file

@ -1,141 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CAttributes.h"
namespace irr
{
namespace io
{
/*
Basic types, check documentation in IAttribute.h to see how they generally work.
*/
// Attribute implemented for boolean values
class CBoolAttribute : public IAttribute
{
public:
CBoolAttribute(const char *name, bool value)
{
Name = name;
setBool(value);
}
s32 getInt() const override
{
return BoolValue ? 1 : 0;
}
f32 getFloat() const override
{
return BoolValue ? 1.0f : 0.0f;
}
bool getBool() const override
{
return BoolValue;
}
void setInt(s32 intValue) override
{
BoolValue = (intValue != 0);
}
void setFloat(f32 floatValue) override
{
BoolValue = (floatValue != 0);
}
void setBool(bool boolValue) override
{
BoolValue = boolValue;
}
E_ATTRIBUTE_TYPE getType() const override
{
return EAT_BOOL;
}
bool BoolValue;
};
// Attribute implemented for integers
class CIntAttribute : public IAttribute
{
public:
CIntAttribute(const char *name, s32 value)
{
Name = name;
setInt(value);
}
s32 getInt() const override
{
return Value;
}
f32 getFloat() const override
{
return (f32)Value;
}
void setInt(s32 intValue) override
{
Value = intValue;
}
void setFloat(f32 floatValue) override
{
Value = (s32)floatValue;
};
E_ATTRIBUTE_TYPE getType() const override
{
return EAT_INT;
}
s32 Value;
};
// Attribute implemented for floats
class CFloatAttribute : public IAttribute
{
public:
CFloatAttribute(const char *name, f32 value)
{
Name = name;
setFloat(value);
}
s32 getInt() const override
{
return (s32)Value;
}
f32 getFloat() const override
{
return Value;
}
void setInt(s32 intValue) override
{
Value = (f32)intValue;
}
void setFloat(f32 floatValue) override
{
Value = floatValue;
}
E_ATTRIBUTE_TYPE getType() const override
{
return EAT_FLOAT;
}
f32 Value;
};
} // end namespace io
} // end namespace irr

View file

@ -1,121 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CAttributes.h"
#include "CAttributeImpl.h"
#include "ITexture.h"
#include "IVideoDriver.h"
namespace irr
{
namespace io
{
CAttributes::CAttributes() {}
CAttributes::~CAttributes()
{
clear();
}
//! Removes all attributes
void CAttributes::clear()
{
for (auto it : Attributes)
delete it.second;
Attributes.clear();
}
//! Sets a attribute as boolean value
void CAttributes::setAttribute(const c8 *attributeName, bool value)
{
auto it = Attributes.find(attributeName);
if (it != Attributes.end()) {
it->second->setBool(value);
} else {
Attributes[attributeName] = new CBoolAttribute(attributeName, value);
}
}
//! Gets a attribute as boolean value
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute() as bool
//! or 0 if attribute is not set.
bool CAttributes::getAttributeAsBool(const c8 *attributeName, bool defaultNotFound) const
{
auto it = Attributes.find(attributeName);
if (it != Attributes.end())
return it->second->getBool();
else
return defaultNotFound;
}
//! Sets a attribute as integer value
void CAttributes::setAttribute(const c8 *attributeName, s32 value)
{
auto it = Attributes.find(attributeName);
if (it != Attributes.end()) {
it->second->setInt(value);
} else {
Attributes[attributeName] = new CIntAttribute(attributeName, value);
}
}
//! Gets a attribute as integer value
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute() as integer
//! or 0 if attribute is not set.
s32 CAttributes::getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound) const
{
auto it = Attributes.find(attributeName);
if (it != Attributes.end())
return it->second->getInt();
else
return defaultNotFound;
}
//! Sets a attribute as float value
void CAttributes::setAttribute(const c8 *attributeName, f32 value)
{
auto it = Attributes.find(attributeName);
if (it != Attributes.end()) {
it->second->setFloat(value);
} else {
Attributes[attributeName] = new CFloatAttribute(attributeName, value);
}
}
//! Gets a attribute as integer value
//! \param attributeName: Name of the attribute to get.
//! \return Returns value of the attribute previously set by setAttribute() as float value
//! or 0 if attribute is not set.
f32 CAttributes::getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound) const
{
auto it = Attributes.find(attributeName);
if (it != Attributes.end())
return it->second->getFloat();
else
return defaultNotFound;
}
//! Returns the type of an attribute
E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8 *attributeName) const
{
E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN;
auto it = Attributes.find(attributeName);
if (it != Attributes.end())
ret = it->second->getType();
return ret;
}
//! Returns if an attribute with a name exists
bool CAttributes::existsAttribute(const c8 *attributeName) const
{
return Attributes.find(attributeName) != Attributes.end();
}
} // end namespace io
} // end namespace irr

View file

@ -1,102 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#pragma once
#include <map>
#include <string>
#include "IAttributes.h"
#include "IAttribute.h"
namespace irr
{
namespace io
{
//! Implementation of the IAttributes interface
class CAttributes : public IAttributes
{
public:
CAttributes();
~CAttributes();
//! Returns the type of an attribute
//! \param attributeName: Name for the attribute
E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const override;
//! Returns if an attribute with a name exists
bool existsAttribute(const c8 *attributeName) const override;
//! Removes all attributes
void clear() override;
/*
Integer Attribute
*/
//! Adds an attribute as integer
void addInt(const c8 *attributeName, s32 value) override {
setAttribute(attributeName, value);
}
//! Sets an attribute as integer value
void setAttribute(const c8 *attributeName, s32 value) override;
//! Gets an attribute as integer value
//! \param attributeName: Name of the attribute to get.
//! \param defaultNotFound Value returned when attributeName was not found
//! \return Returns value of the attribute previously set by setAttribute()
s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const override;
/*
Float Attribute
*/
//! Adds an attribute as float
void addFloat(const c8 *attributeName, f32 value) override {
setAttribute(attributeName, value);
}
//! Sets a attribute as float value
void setAttribute(const c8 *attributeName, f32 value) override;
//! Gets an attribute as float value
//! \param attributeName: Name of the attribute to get.
//! \param defaultNotFound Value returned when attributeName was not found
//! \return Returns value of the attribute previously set by setAttribute()
f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const override;
/*
Bool Attribute
*/
//! Adds an attribute as bool
void addBool(const c8 *attributeName, bool value) override {
setAttribute(attributeName, value);
}
//! Sets an attribute as boolean value
void setAttribute(const c8 *attributeName, bool value) override;
//! Gets an attribute as boolean value
//! \param attributeName: Name of the attribute to get.
//! \param defaultNotFound Value returned when attributeName was not found
//! \return Returns value of the attribute previously set by setAttribute()
bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const override;
protected:
typedef std::basic_string<c8> string;
// specify a comparator so we can directly look up in the map with const c8*
// (works since C++14)
std::map<string, IAttribute*, std::less<>> Attributes;
};
} // end namespace io
} // end namespace irr

View file

@ -10,7 +10,6 @@
#include "IGUISpriteBank.h"
#include "IGUIElement.h"
#include "IVideoDriver.h"
#include "IAttributes.h"
namespace irr
{

View file

@ -13,7 +13,6 @@
#include "CTimer.h"
#include "CLogger.h"
#include "irrString.h"
#include "IrrCompileConfig.h" // for IRRLICHT_SDK_VERSION
namespace irr
{

View file

@ -401,7 +401,6 @@ add_library(IRRIOOBJ OBJECT
CReadFile.cpp
CWriteFile.cpp
CZipReader.cpp
CAttributes.cpp
)
add_library(IRROTHEROBJ OBJECT

View file

@ -3,9 +3,10 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CNullDriver.h"
#include "IVideoDriver.h"
#include "SMaterial.h"
#include "os.h"
#include "CImage.h"
#include "CAttributes.h"
#include "IReadFile.h"
#include "IWriteFile.h"
#include "IImageLoader.h"
@ -55,20 +56,6 @@ CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &scre
ViewPort(0, 0, 0, 0), ScreenSize(screenSize), MinVertexCountForVBO(500),
TextureCreationFlags(0), OverrideMaterial2DEnabled(false), AllowZWriteOnTransparent(false)
{
DriverAttributes = new io::CAttributes();
DriverAttributes->addInt("MaxTextures", MATERIAL_MAX_TEXTURES);
DriverAttributes->addInt("MaxSupportedTextures", MATERIAL_MAX_TEXTURES);
DriverAttributes->addInt("MaxAnisotropy", 1);
// DriverAttributes->addInt("MaxAuxBuffers", 0);
DriverAttributes->addInt("MaxMultipleRenderTargets", 1);
DriverAttributes->addInt("MaxIndices", -1);
DriverAttributes->addInt("MaxTextureSize", -1);
// DriverAttributes->addInt("MaxGeometryVerticesOut", 0);
// DriverAttributes->addFloat("MaxTextureLODBias", 0.f);
DriverAttributes->addInt("Version", 1);
// DriverAttributes->addInt("ShaderLanguageVersion", 0);
// DriverAttributes->addInt("AntiAlias", 0);
setFog();
setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true);
@ -113,9 +100,6 @@ CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &scre
//! destructor
CNullDriver::~CNullDriver()
{
if (DriverAttributes)
DriverAttributes->drop();
if (FileSystem)
FileSystem->drop();
@ -236,12 +220,6 @@ bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return false;
}
//! Get attributes of the actual video driver
const io::IAttributes &CNullDriver::getDriverAttributes() const
{
return *DriverAttributes;
}
//! sets transformation
void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat)
{

View file

@ -9,7 +9,6 @@
#include "IGPUProgrammingServices.h"
#include "irrArray.h"
#include "irrString.h"
#include "IAttributes.h"
#include "IMesh.h"
#include "IMeshBuffer.h"
#include "IMeshSceneNode.h"
@ -50,9 +49,6 @@ public:
//! queries the features of the driver, returns true if feature is available
bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const override;
//! Get attributes of the actual video driver
const io::IAttributes &getDriverAttributes() const override;
//! sets transformation
void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) override;
@ -717,8 +713,6 @@ protected:
SColor FogColor;
SExposedVideoData ExposedData;
io::IAttributes *DriverAttributes;
SOverrideMaterial OverrideMaterial;
SMaterial OverrideMaterial2D;
SMaterial InitMaterial2D;

View file

@ -9,7 +9,6 @@
#include "SMeshBuffer.h"
#include "SAnimatedMesh.h"
#include "IReadFile.h"
#include "IAttributes.h"
#include "fast_atof.h"
#include "coreutil.h"
#include "os.h"
@ -74,8 +73,6 @@ IAnimatedMesh *COBJMeshFileLoader::createMesh(io::IReadFile *file)
const c8 *bufPtr = buf;
core::stringc grpName, mtlName;
bool mtlChanged = false;
bool useGroups = !SceneManager->getParameters()->getAttributeAsBool(OBJ_LOADER_IGNORE_GROUPS);
bool useMaterials = !SceneManager->getParameters()->getAttributeAsBool(OBJ_LOADER_IGNORE_MATERIAL_FILES);
[[maybe_unused]] irr::u32 lineNr = 1; // only counts non-empty lines, still useful in debugging to locate errors
core::array<int> faceCorners;
faceCorners.reallocate(32); // should be large enough
@ -85,15 +82,7 @@ IAnimatedMesh *COBJMeshFileLoader::createMesh(io::IReadFile *file)
while (bufPtr != bufEnd) {
switch (bufPtr[0]) {
case 'm': // mtllib (material)
{
if (useMaterials) {
c8 name[WORD_BUFFER_LENGTH];
bufPtr = goAndCopyNextWord(name, bufPtr, WORD_BUFFER_LENGTH, bufEnd);
#ifdef _IRR_DEBUG_OBJ_LOADER_
os::Printer::log("Ignoring material file", name);
#endif
}
} break;
break; // not supported
case 'v': // v, vn, vt
switch (bufPtr[1]) {
@ -127,12 +116,7 @@ IAnimatedMesh *COBJMeshFileLoader::createMesh(io::IReadFile *file)
#ifdef _IRR_DEBUG_OBJ_LOADER_
os::Printer::log("Loaded group start", grp, ELL_DEBUG);
#endif
if (useGroups) {
if (0 != grp[0])
grpName = grp;
else
grpName = "default";
}
grpName = ('\0' != grp[0]) ? grp : "default";
mtlChanged = true;
} break;

View file

@ -116,18 +116,6 @@ bool COpenGLDriver::genericDriverInit()
os::Printer::log("GLSL version", buf, ELL_INFORMATION);
} else
os::Printer::log("GLSL not available.", ELL_INFORMATION);
DriverAttributes->setAttribute("MaxTextures", (s32)Feature.MaxTextureUnits);
DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits);
DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy);
DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers);
DriverAttributes->setAttribute("MaxMultipleRenderTargets", (s32)Feature.MultipleRenderTarget);
DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices);
DriverAttributes->setAttribute("MaxTextureSize", (s32)MaxTextureSize);
DriverAttributes->setAttribute("MaxGeometryVerticesOut", (s32)MaxGeometryVerticesOut);
DriverAttributes->setAttribute("MaxTextureLODBias", MaxTextureLODBias);
DriverAttributes->setAttribute("Version", Version);
DriverAttributes->setAttribute("ShaderLanguageVersion", ShaderLanguageVersion);
DriverAttributes->setAttribute("AntiAlias", AntiAlias);
glPixelStorei(GL_PACK_ALIGNMENT, 1);

View file

@ -42,7 +42,7 @@ CSceneManager::CSceneManager(video::IVideoDriver *driver,
ISceneNode(0, 0),
Driver(driver),
CursorControl(cursorControl),
ActiveCamera(0), Parameters(0),
ActiveCamera(0),
MeshCache(cache), CurrentRenderPass(ESNRP_NONE)
{
// root node's scene manager
@ -60,9 +60,6 @@ CSceneManager::CSceneManager(video::IVideoDriver *driver,
else
MeshCache->grab();
// set scene parameters
Parameters = new io::CAttributes();
// create collision manager
CollisionManager = new CSceneCollisionManager(this, Driver);
@ -105,9 +102,6 @@ CSceneManager::~CSceneManager()
if (MeshCache)
MeshCache->drop();
if (Parameters)
Parameters->drop();
// remove all nodes before dropping the driver
// as render targets may be destroyed twice
@ -472,8 +466,7 @@ void CSceneManager::drawAll()
Driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
for (u32 i = video::ETS_COUNT - 1; i >= video::ETS_TEXTURE_0; --i)
Driver->setTransform((video::E_TRANSFORMATION_STATE)i, core::IdentityMatrix);
// TODO: This should not use an attribute here but a real parameter when necessary (too slow!)
Driver->setAllowZWriteOnTransparent(Parameters->getAttributeAsBool(ALLOW_ZWRITE_ON_TRANSPARENT));
Driver->setAllowZWriteOnTransparent(true);
// do animations and other stuff.
OnAnimate(os::Timer::getTime());
@ -743,12 +736,6 @@ void CSceneManager::clear()
removeAll();
}
//! Returns interface to the parameters set in this scene.
io::IAttributes *CSceneManager::getParameters()
{
return Parameters;
}
//! Returns current render pass.
E_SCENE_NODE_RENDER_PASS CSceneManager::getSceneNodeRenderPass() const
{

View file

@ -11,7 +11,6 @@
#include "irrString.h"
#include "irrArray.h"
#include "IMeshLoader.h"
#include "CAttributes.h"
namespace irr
{
@ -158,9 +157,6 @@ public:
//! Removes all children of this scene node
void removeAll() override;
//! Returns interface to the parameters set in this scene.
io::IAttributes *getParameters() override;
//! Returns current render pass.
E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const override;
@ -266,10 +262,6 @@ private:
ICameraSceneNode *ActiveCamera;
core::vector3df camWorldPos; // Position of camera for transparent nodes.
//! String parameters
// NOTE: Attributes are slow and should only be used for debug-info and not in release
io::CAttributes *Parameters;
//! Mesh cache
IMeshCache *MeshCache;

View file

@ -1,35 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#pragma once
#include "irrTypes.h"
#include "irrString.h"
#include "EAttributes.h"
namespace irr
{
namespace io
{
class IAttribute
{
public:
virtual ~IAttribute(){};
virtual s32 getInt() const { return 0; }
virtual f32 getFloat() const { return 0; }
virtual bool getBool() const { return false; }
virtual void setInt(s32 intValue){};
virtual void setFloat(f32 floatValue){};
virtual void setBool(bool boolValue){};
core::stringc Name;
virtual E_ATTRIBUTE_TYPE getType() const = 0;
};
} // end namespace io
} // end namespace irr

View file

@ -27,7 +27,7 @@ static const char *const copyright = "Irrlicht Engine (c) 2002-2017 Nikolaus Geb
namespace irr
{
//! stub for calling createDeviceEx
IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
IrrlichtDevice *createDevice(video::E_DRIVER_TYPE driverType,
const core::dimension2d<u32> &windowSize,
u32 bits, bool fullscreen,
bool stencilbuffer, bool vsync, IEventReceiver *res)
@ -46,7 +46,7 @@ IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDevice(video::E_DRIVER_TYPE drive
return createDeviceEx(p);
}
extern "C" IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters &params)
extern "C" IrrlichtDevice *createDeviceEx(const SIrrlichtCreationParameters &params)
{
IrrlichtDevice *dev = 0;
@ -90,7 +90,7 @@ namespace video
{
const SMaterial IdentityMaterial;
extern "C" IRRLICHT_API bool IRRCALLCONV isDriverSupported(E_DRIVER_TYPE driver)
extern "C" bool isDriverSupported(E_DRIVER_TYPE driver)
{
switch (driver) {
case EDT_NULL:

View file

@ -261,16 +261,6 @@ bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d<u32> &screenS
StencilBuffer = stencilBuffer;
DriverAttributes->setAttribute("MaxTextures", (s32)Feature.MaxTextureUnits);
DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits);
DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy);
DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices);
DriverAttributes->setAttribute("MaxTextureSize", (s32)MaxTextureSize);
DriverAttributes->setAttribute("MaxArrayTextureLayers", (s32)MaxArrayTextureLayers);
DriverAttributes->setAttribute("MaxTextureLODBias", MaxTextureLODBias);
DriverAttributes->setAttribute("Version", 100 * Version.Major + Version.Minor);
DriverAttributes->setAttribute("AntiAlias", AntiAlias);
GL.PixelStorei(GL_PACK_ALIGNMENT, 1);
for (s32 i = 0; i < ETS_COUNT; ++i)