Skip to content

Commit

Permalink
Traktor: Spray feedback manager is now a world component.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Apr 19, 2024
1 parent 39d255b commit b05ca7e
Show file tree
Hide file tree
Showing 35 changed files with 181 additions and 331 deletions.
25 changes: 12 additions & 13 deletions code/Runtime/Engine/SplitWorldLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "Runtime/Engine/SplitWorldLayer.h"
#include "Scene/Scene.h"
#include "Sound/Filters/SurroundEnvironment.h"
#include "Spray/Feedback/FeedbackManager.h"
#include "World/IWorldRenderer.h"
#include "World/WorldRenderSettings.h"
#include "World/Entity.h"
Expand Down Expand Up @@ -69,12 +68,12 @@ SplitWorldLayer::SplitWorldLayer(
m_fieldOfView = m_environment->getSettings()->getProperty< float >(L"World.FieldOfView", 70.0f);

// Register ourself for camera shake.
spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
if (feedbackManager)
{
feedbackManager->addListener(spray::FbtCamera, this);
feedbackManager->addListener(spray::FbtImageProcess, this);
}
//spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
//if (feedbackManager)
//{
// feedbackManager->addListener(spray::FbtCamera, this);
// feedbackManager->addListener(spray::FbtImageProcess, this);
//}

// Set index in each view.
m_worldRenderViews[0].setIndex(0);
Expand All @@ -84,12 +83,12 @@ SplitWorldLayer::SplitWorldLayer(
void SplitWorldLayer::destroy()
{
// Remove ourself from feedback manager.
spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
if (feedbackManager)
{
feedbackManager->removeListener(spray::FbtImageProcess, this);
feedbackManager->removeListener(spray::FbtCamera, this);
}
//spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
//if (feedbackManager)
//{
// feedbackManager->removeListener(spray::FbtImageProcess, this);
// feedbackManager->removeListener(spray::FbtCamera, this);
//}

m_environment = nullptr;
m_cameraEntities[0] = nullptr;
Expand Down
25 changes: 12 additions & 13 deletions code/Runtime/Engine/WorldLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "Runtime/Engine/Stage.h"
#include "Runtime/Engine/WorldLayer.h"
#include "Scene/Scene.h"
#include "Spray/Feedback/FeedbackManager.h"
#include "World/IWorldRenderer.h"
#include "World/World.h"
#include "World/WorldRenderSettings.h"
Expand Down Expand Up @@ -62,23 +61,23 @@ WorldLayer::WorldLayer(
m_fieldOfView = m_environment->getSettings()->getProperty< float >(L"World.FieldOfView", 70.0f);

// Register ourself for camera shake.
spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
if (feedbackManager)
{
feedbackManager->addListener(spray::FbtCamera, this);
feedbackManager->addListener(spray::FbtImageProcess, this);
}
//spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
//if (feedbackManager)
//{
// feedbackManager->addListener(spray::FbtCamera, this);
// feedbackManager->addListener(spray::FbtImageProcess, this);
//}
}

void WorldLayer::destroy()
{
// Remove ourself from feedback manager.
spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
if (feedbackManager)
{
feedbackManager->removeListener(spray::FbtImageProcess, this);
feedbackManager->removeListener(spray::FbtCamera, this);
}
//spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
//if (feedbackManager)
//{
// feedbackManager->removeListener(spray::FbtImageProcess, this);
// feedbackManager->removeListener(spray::FbtCamera, this);
//}

m_environment = nullptr;
m_cameraEntity = nullptr;
Expand Down
9 changes: 0 additions & 9 deletions code/Runtime/IWorldServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
# define T_DLLCLASS T_DLLIMPORT
#endif

namespace traktor::spray
{

class IFeedbackManager;

}

namespace traktor::world
{

Expand Down Expand Up @@ -62,8 +55,6 @@ class T_DLLCLASS IWorldServer : public IServer

virtual world::WorldEntityRenderers* getEntityRenderers() = 0;

virtual spray::IFeedbackManager* getFeedbackManager() = 0;

virtual Ref< world::IWorldRenderer > createWorldRenderer(const world::WorldRenderSettings* worldRenderSettings) = 0;
};

Expand Down
8 changes: 0 additions & 8 deletions code/Runtime/Impl/WorldServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "Scene/SceneFactory.h"
#include "Sound/Player/ISoundPlayer.h"
#include "Spray/EffectRenderer.h"
#include "Spray/Feedback/FeedbackManager.h"
#include "Terrain/EntityRenderer.h"
#include "Weather/Precipitation/PrecipitationRenderer.h"
#include "Weather/Sky/SkyRenderer.h"
Expand Down Expand Up @@ -103,7 +102,6 @@ bool WorldServer::create(const PropertyGroup* defaultSettings, const PropertyGro
m_renderServer = renderServer;
m_resourceServer = resourceServer;
m_entityFactory = new world::EntityFactory();
m_feedbackManager = new spray::FeedbackManager();
m_entityRenderers = new world::WorldEntityRenderers();

return true;
Expand All @@ -116,7 +114,6 @@ void WorldServer::destroy()
m_renderServer = nullptr;
m_resourceServer = nullptr;
m_effectEntityRenderer = nullptr;
m_feedbackManager = nullptr;
m_terrainEntityRenderer = nullptr;
m_worldType = nullptr;
}
Expand Down Expand Up @@ -273,11 +270,6 @@ world::WorldEntityRenderers* WorldServer::getEntityRenderers()
return m_entityRenderers;
}

spray::IFeedbackManager* WorldServer::getFeedbackManager()
{
return m_feedbackManager;
}

Ref< world::IWorldRenderer > WorldServer::createWorldRenderer(const world::WorldRenderSettings* worldRenderSettings)
{
world::WorldCreateDesc wcd;
Expand Down
4 changes: 0 additions & 4 deletions code/Runtime/Impl/WorldServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace traktor::spray
{

class EffectRenderer;
class FeedbackManager;

}

Expand Down Expand Up @@ -79,8 +78,6 @@ class WorldServer : public IWorldServer

virtual world::WorldEntityRenderers* getEntityRenderers() override final;

virtual spray::IFeedbackManager* getFeedbackManager() override final;

virtual Ref< world::IWorldRenderer > createWorldRenderer(const world::WorldRenderSettings* worldRenderSettings) override final;

private:
Expand All @@ -89,7 +86,6 @@ class WorldServer : public IWorldServer
Ref< IRenderServer > m_renderServer;
Ref< IResourceServer > m_resourceServer;
Ref< spray::EffectRenderer > m_effectEntityRenderer;
Ref< spray::FeedbackManager > m_feedbackManager;
Ref< terrain::EntityRenderer > m_terrainEntityRenderer;
const TypeInfo* m_worldType = nullptr;
world::Quality m_motionBlurQuality = world::Quality::Medium;
Expand Down
25 changes: 12 additions & 13 deletions code/Spark/Runtime/SparkLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "Spark/Debug/MovieDebugger.h"
#include "Spark/Runtime/SparkLayer.h"
#include "Spark/Sound/SoundRenderer.h"
#include "Spray/Feedback/IFeedbackManager.h"

namespace traktor::spark
{
Expand Down Expand Up @@ -145,23 +144,23 @@ SparkLayer::SparkLayer(
, m_lastMouseY(-1)
{
// Register ourself for UI shake.
if (m_environment->getWorld())
{
spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
if (feedbackManager)
feedbackManager->addListener(spray::FbtUI, this);
}
//if (m_environment->getWorld())
//{
// spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
// if (feedbackManager)
// feedbackManager->addListener(spray::FbtUI, this);
//}
}

void SparkLayer::destroy()
{
// Remove ourself from feedback manager.
if (m_environment && m_environment->getWorld())
{
spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
if (feedbackManager)
feedbackManager->removeListener(spray::FbtUI, this);
}
//if (m_environment && m_environment->getWorld())
//{
// spray::IFeedbackManager* feedbackManager = m_environment->getWorld()->getFeedbackManager();
// if (feedbackManager)
// feedbackManager->removeListener(spray::FbtUI, this);
//}

m_environment = nullptr;
m_movie.clear();
Expand Down
2 changes: 1 addition & 1 deletion code/Spray/Editor/SprayEditorProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void SprayEditorProfile::createEntityFactories(
RefArray< const world::IEntityFactory >& outEntityFactories
) const
{
outEntityFactories.push_back(new spray::EffectEntityFactory(context->getResourceManager(), nullptr, nullptr));
outEntityFactories.push_back(new spray::EffectEntityFactory(context->getResourceManager(), nullptr));
}

void SprayEditorProfile::createEntityRenderers(
Expand Down
10 changes: 3 additions & 7 deletions code/Spray/EffectEntityFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "Spray/SpawnEffectEventData.h"
#include "Spray/Feedback/EnvelopeFeedbackEvent.h"
#include "Spray/Feedback/EnvelopeFeedbackEventData.h"
#include "Spray/Feedback/IFeedbackManager.h"
#include "Spray/Feedback/OscillateFeedbackEvent.h"
#include "Spray/Feedback/OscillateFeedbackEventData.h"
#include "World/IEntityBuilder.h"
Expand All @@ -36,20 +35,17 @@ T_IMPLEMENT_RTTI_FACTORY_CLASS(L"traktor.spray.EffectEntityFactory", 0, EffectEn

EffectEntityFactory::EffectEntityFactory(
resource::IResourceManager* resourceManager,
sound::ISoundPlayer* soundPlayer,
IFeedbackManager* feedbackManager
sound::ISoundPlayer* soundPlayer
)
: m_resourceManager(resourceManager)
, m_soundPlayer(soundPlayer)
, m_feedbackManager(feedbackManager)
{
}

bool EffectEntityFactory::initialize(const ObjectStore& objectStore)
{
m_resourceManager = objectStore.get< resource::IResourceManager >();
m_soundPlayer = objectStore.get< sound::ISoundPlayer >();
m_feedbackManager = objectStore.get< IFeedbackManager >();
return true;
}

Expand All @@ -76,11 +72,11 @@ Ref< world::IEntityEvent > EffectEntityFactory::createEntityEvent(const world::I
{
if (auto envelopeFeedbackEventData = dynamic_type_cast< const EnvelopeFeedbackEventData* >(&entityEventData))
{
return new EnvelopeFeedbackEvent(envelopeFeedbackEventData, m_feedbackManager);
return new EnvelopeFeedbackEvent(envelopeFeedbackEventData);
}
else if (auto oscillateFeedbackEventData = dynamic_type_cast< const OscillateFeedbackEventData* >(&entityEventData))
{
return new OscillateFeedbackEvent(oscillateFeedbackEventData, m_feedbackManager);
return new OscillateFeedbackEvent(oscillateFeedbackEventData);
}
else if (auto soundEventData = dynamic_type_cast< const SoundEventData* >(&entityEventData))
{
Expand Down
6 changes: 1 addition & 5 deletions code/Spray/EffectEntityFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class ISoundPlayer;
namespace traktor::spray
{

class IFeedbackManager;

/*! Effect entity factory.
* \ingroup Spray
*/
Expand All @@ -49,8 +47,7 @@ class T_DLLCLASS EffectEntityFactory : public world::AbstractEntityFactory

explicit EffectEntityFactory(
resource::IResourceManager* resourceManager,
sound::ISoundPlayer* soundPlayer,
IFeedbackManager* feedbackManager
sound::ISoundPlayer* soundPlayer
);

virtual bool initialize(const ObjectStore& objectStore) override final;
Expand All @@ -66,7 +63,6 @@ class T_DLLCLASS EffectEntityFactory : public world::AbstractEntityFactory
private:
Ref< resource::IResourceManager > m_resourceManager;
Ref< sound::ISoundPlayer > m_soundPlayer;
Ref< IFeedbackManager > m_feedbackManager;
};

}
10 changes: 3 additions & 7 deletions code/Spray/Feedback/EnvelopeFeedbackEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@
#include "Spray/Feedback/EnvelopeFeedbackEvent.h"
#include "Spray/Feedback/EnvelopeFeedbackEventInstance.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_CLASS(L"traktor.spray.EnvelopeFeedbackEvent", EnvelopeFeedbackEvent, world::IEntityEvent)

EnvelopeFeedbackEvent::EnvelopeFeedbackEvent(const EnvelopeFeedbackEventData* data, IFeedbackManager* feedbackManager)
EnvelopeFeedbackEvent::EnvelopeFeedbackEvent(const EnvelopeFeedbackEventData* data)
: m_data(data)
, m_feedbackManager(feedbackManager)
{
}

Ref< world::IEntityEventInstance > EnvelopeFeedbackEvent::createInstance(world::EntityEventManager* eventManager, world::Entity* sender, const Transform& Toffset) const
{
return new EnvelopeFeedbackEventInstance(m_data, m_feedbackManager);
return new EnvelopeFeedbackEventInstance(m_data);
}

}
}
9 changes: 2 additions & 7 deletions code/Spray/Feedback/EnvelopeFeedbackEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,23 @@

#include "World/IEntityEvent.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

class EnvelopeFeedbackEventData;
class IFeedbackManager;

class EnvelopeFeedbackEvent : public world::IEntityEvent
{
T_RTTI_CLASS;

public:
EnvelopeFeedbackEvent(const EnvelopeFeedbackEventData* data, IFeedbackManager* feedbackManager);
explicit EnvelopeFeedbackEvent(const EnvelopeFeedbackEventData* data);

virtual Ref< world::IEntityEventInstance > createInstance(world::EntityEventManager* eventManager, world::Entity* sender, const Transform& Toffset) const override final;

private:
Ref< const EnvelopeFeedbackEventData > m_data;
IFeedbackManager* m_feedbackManager;
};

}
}

16 changes: 1 addition & 15 deletions code/Spray/Feedback/EnvelopeFeedbackEventData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@
#include "Core/Serialization/MemberStl.h"
#include "Spray/Feedback/EnvelopeFeedbackEventData.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_FACTORY_CLASS(L"traktor.spray.EnvelopeFeedbackEventData", 0, EnvelopeFeedbackEventData, world::IEntityEventData)

EnvelopeFeedbackEventData::EnvelopeFeedbackEventData()
: m_type(FbtNone)
{
}

void EnvelopeFeedbackEventData::serialize(ISerializer& s)
{
const MemberEnum< FeedbackType >::Key c_FeedbackType_keys[] =
Expand All @@ -41,17 +34,10 @@ void EnvelopeFeedbackEventData::serialize(ISerializer& s)
s >> MemberStaticArray< std::vector< TimedValue >, 4, MemberStlVector< TimedValue, MemberComposite< TimedValue > > >(L"envelopes", m_envelopes);
}

EnvelopeFeedbackEventData::TimedValue::TimedValue()
: at(0.0f)
, value(0.0f)
{
}

void EnvelopeFeedbackEventData::TimedValue::serialize(ISerializer& s)
{
s >> Member< float >(L"at", at);
s >> Member< float >(L"value", value);
}

}
}
Loading

0 comments on commit b05ca7e

Please sign in to comment.