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

Add lighting test and benchmark (#12802)

This commit is contained in:
Jude Melton-Houghton 2022-09-26 06:49:08 -04:00 committed by GitHub
parent 8dec3a5ecb
commit f916398a54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 292 additions and 63 deletions

View file

@ -22,10 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/sound.h"
#include "nodedef.h"
#include "itemdef.h"
#include "gamedef.h"
#include "dummygamedef.h"
#include "modchannels.h"
#include "content/mods.h"
#include "database/database-dummy.h"
#include "util/numeric.h"
#include "porting.h"
@ -42,36 +40,13 @@ content_t t_CONTENT_BRICK;
//// TestGameDef
////
class TestGameDef : public IGameDef {
class TestGameDef : public DummyGameDef {
public:
TestGameDef();
~TestGameDef();
IItemDefManager *getItemDefManager() { return m_itemdef; }
const NodeDefManager *getNodeDefManager() { return m_nodedef; }
ICraftDefManager *getCraftDefManager() { return m_craftdef; }
ITextureSource *getTextureSource() { return m_texturesrc; }
IShaderSource *getShaderSource() { return m_shadersrc; }
ISoundManager *getSoundManager() { return m_soundmgr; }
scene::ISceneManager *getSceneManager() { return m_scenemgr; }
IRollbackManager *getRollbackManager() { return m_rollbackmgr; }
EmergeManager *getEmergeManager() { return m_emergemgr; }
ModMetadataDatabase *getModStorageDatabase() { return m_mod_storage_database; }
scene::IAnimatedMesh *getMesh(const std::string &filename) { return NULL; }
bool checkLocalPrivilege(const std::string &priv) { return false; }
u16 allocateUnknownNodeId(const std::string &name) { return 0; }
~TestGameDef() = default;
void defineSomeNodes();
virtual const std::vector<ModSpec> &getMods() const
{
static std::vector<ModSpec> testmodspec;
return testmodspec;
}
virtual const ModSpec* getModSpec(const std::string &modname) const { return NULL; }
virtual bool registerModStorage(ModMetadata *meta) { return true; }
virtual void unregisterModStorage(const std::string &name) {}
bool joinModChannel(const std::string &channel);
bool leaveModChannel(const std::string &channel);
bool sendModChannelMessage(const std::string &channel, const std::string &message);
@ -81,39 +56,18 @@ public:
}
private:
IItemDefManager *m_itemdef = nullptr;
const NodeDefManager *m_nodedef = nullptr;
ICraftDefManager *m_craftdef = nullptr;
ITextureSource *m_texturesrc = nullptr;
IShaderSource *m_shadersrc = nullptr;
ISoundManager *m_soundmgr = nullptr;
scene::ISceneManager *m_scenemgr = nullptr;
IRollbackManager *m_rollbackmgr = nullptr;
EmergeManager *m_emergemgr = nullptr;
ModMetadataDatabase *m_mod_storage_database = nullptr;
std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
};
TestGameDef::TestGameDef() :
m_mod_storage_database(new Database_Dummy()),
DummyGameDef(),
m_modchannel_mgr(new ModChannelMgr())
{
m_itemdef = createItemDefManager();
m_nodedef = createNodeDefManager();
defineSomeNodes();
}
TestGameDef::~TestGameDef()
{
delete m_itemdef;
delete m_nodedef;
delete m_mod_storage_database;
}
void TestGameDef::defineSomeNodes()
{
IWritableItemDefManager *idef = (IWritableItemDefManager *)m_itemdef;
@ -185,6 +139,8 @@ void TestGameDef::defineSomeNodes()
f = ContentFeatures();
f.name = itemdef.name;
f.alpha = ALPHAMODE_BLEND;
f.light_propagates = true;
f.param_type = CPT_LIGHT;
f.liquid_type = LIQUID_SOURCE;
f.liquid_viscosity = 4;
f.is_ground_content = true;