aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/clientenvironment.cpp2
-rw-r--r--src/client/clientobject.h6
-rw-r--r--src/client/content_cao.cpp30
-rw-r--r--src/client/content_cao.h2
-rw-r--r--src/unittest/test_clientactiveobjectmgr.cpp1
5 files changed, 20 insertions, 21 deletions
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index 1bdf5390d..9c40484bf 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -352,7 +352,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
if (!m_ao_manager.registerObject(object))
return 0;
- object->addToScene(m_texturesource);
+ object->addToScene(m_texturesource, RenderingEngine::get_scene_manager());
// Update lighting immediately
object->updateLight(getDayNightRatio());
diff --git a/src/client/clientobject.h b/src/client/clientobject.h
index ecd8059ef..dbc2f22cf 100644
--- a/src/client/clientobject.h
+++ b/src/client/clientobject.h
@@ -33,13 +33,17 @@ class LocalPlayer;
struct ItemStack;
class WieldMeshSceneNode;
+namespace irr { namespace scene {
+ class ISceneManager;
+}}
+
class ClientActiveObject : public ActiveObject
{
public:
ClientActiveObject(u16 id, Client *client, ClientEnvironment *env);
virtual ~ClientActiveObject();
- virtual void addToScene(ITextureSource *tsrc) {}
+ virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) = 0;
virtual void removeFromScene(bool permanent) {}
virtual void updateLight(u32 day_night_ratio) {}
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index 63b8821f4..a2fbbf001 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IMeshManipulator.h>
#include <IAnimatedMeshSceneNode.h>
#include "client/client.h"
-#include "client/renderingengine.h"
#include "client/sound.h"
#include "client/tile.h"
#include "util/basic_macros.h"
@@ -189,7 +188,7 @@ public:
static ClientActiveObject* create(Client *client, ClientEnvironment *env);
- void addToScene(ITextureSource *tsrc);
+ void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr);
void removeFromScene(bool permanent);
void updateLight(u32 day_night_ratio);
void updateNodePos();
@@ -220,7 +219,7 @@ ClientActiveObject* TestCAO::create(Client *client, ClientEnvironment *env)
return new TestCAO(client, env);
}
-void TestCAO::addToScene(ITextureSource *tsrc)
+void TestCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr)
{
if(m_node != NULL)
return;
@@ -249,7 +248,7 @@ void TestCAO::addToScene(ITextureSource *tsrc)
// Add to mesh
mesh->addMeshBuffer(buf);
buf->drop();
- m_node = RenderingEngine::get_scene_manager()->addMeshSceneNode(mesh, NULL);
+ m_node = smgr->addMeshSceneNode(mesh, NULL);
mesh->drop();
updateNodePos();
}
@@ -591,9 +590,9 @@ void GenericCAO::removeFromScene(bool permanent)
m_client->getMinimap()->removeMarker(&m_marker);
}
-void GenericCAO::addToScene(ITextureSource *tsrc)
+void GenericCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr)
{
- m_smgr = RenderingEngine::get_scene_manager();
+ m_smgr = smgr;
if (getSceneNode() != NULL) {
return;
@@ -625,8 +624,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
}
auto grabMatrixNode = [this] {
- m_matrixnode = RenderingEngine::get_scene_manager()->
- addDummyTransformationSceneNode();
+ m_matrixnode = m_smgr->addDummyTransformationSceneNode();
m_matrixnode->grab();
};
@@ -644,7 +642,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
if (m_prop.visual == "sprite") {
grabMatrixNode();
- m_spritenode = RenderingEngine::get_scene_manager()->addBillboardSceneNode(
+ m_spritenode = m_smgr->addBillboardSceneNode(
m_matrixnode, v2f(1, 1), v3f(0,0,0), -1);
m_spritenode->grab();
m_spritenode->setMaterialTexture(0,
@@ -729,8 +727,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
mesh->addMeshBuffer(buf);
buf->drop();
}
- m_meshnode = RenderingEngine::get_scene_manager()->
- addMeshSceneNode(mesh, m_matrixnode);
+ m_meshnode = m_smgr->addMeshSceneNode(mesh, m_matrixnode);
m_meshnode->grab();
mesh->drop();
// Set it to use the materials of the meshbuffers directly.
@@ -739,8 +736,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
} else if (m_prop.visual == "cube") {
grabMatrixNode();
scene::IMesh *mesh = createCubeMesh(v3f(BS,BS,BS));
- m_meshnode = RenderingEngine::get_scene_manager()->
- addMeshSceneNode(mesh, m_matrixnode);
+ m_meshnode = m_smgr->addMeshSceneNode(mesh, m_matrixnode);
m_meshnode->grab();
mesh->drop();
@@ -753,8 +749,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
grabMatrixNode();
scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true);
if (mesh) {
- m_animated_meshnode = RenderingEngine::get_scene_manager()->
- addAnimatedMeshSceneNode(mesh, m_matrixnode);
+ m_animated_meshnode = m_smgr->addAnimatedMeshSceneNode(mesh, m_matrixnode);
m_animated_meshnode->grab();
mesh->drop(); // The scene node took hold of it
@@ -795,8 +790,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
infostream << "serialized form: " << m_prop.wield_item << std::endl;
item.deSerialize(m_prop.wield_item, m_client->idef());
}
- m_wield_meshnode = new WieldMeshSceneNode(
- RenderingEngine::get_scene_manager(), -1);
+ m_wield_meshnode = new WieldMeshSceneNode(m_smgr, -1);
m_wield_meshnode->setItem(item, m_client,
(m_prop.visual == "wielditem"));
@@ -1074,7 +1068,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
}
removeFromScene(false);
- addToScene(m_client->tsrc());
+ addToScene(m_client->tsrc(), m_smgr);
// Attachments, part 2: Now that the parent has been refreshed, put its attachments back
for (u16 cao_id : m_attachment_child_ids) {
diff --git a/src/client/content_cao.h b/src/client/content_cao.h
index cc026d34e..32ec9c1c3 100644
--- a/src/client/content_cao.h
+++ b/src/client/content_cao.h
@@ -236,7 +236,7 @@ public:
void removeFromScene(bool permanent);
- void addToScene(ITextureSource *tsrc);
+ void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr);
inline void expireVisuals()
{
diff --git a/src/unittest/test_clientactiveobjectmgr.cpp b/src/unittest/test_clientactiveobjectmgr.cpp
index 4d2846c8d..a43855c19 100644
--- a/src/unittest/test_clientactiveobjectmgr.cpp
+++ b/src/unittest/test_clientactiveobjectmgr.cpp
@@ -29,6 +29,7 @@ public:
TestClientActiveObject() : ClientActiveObject(0, nullptr, nullptr) {}
~TestClientActiveObject() = default;
ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; }
+ virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) {}
};
class TestClientActiveObjectMgr : public TestBase