Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions engine/includes/components/pointlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ENGINE_EXPORT PointLight : public BaseLight {

A_PROPERTIES(
A_PROPERTY(float, attenuationRadius, PointLight::attenuationRadius, PointLight::setAttenuationRadius),
A_PROPERTY(float, sourceRadius, PointLight::sourceRadius, PointLight::setSourceRadius),
A_PROPERTY(float, sourceLength, PointLight::sourceLength, PointLight::setSourceLength)
A_PROPERTY(float, sourceRadius, PointLight::sourceRadius, PointLight::setSourceRadius),
A_PROPERTY(float, sourceLength, PointLight::sourceLength, PointLight::setSourceLength)
)
A_NOMETHODS()

Expand All @@ -33,7 +33,6 @@ class ENGINE_EXPORT PointLight : public BaseLight {
void drawGizmos() override;
void drawGizmosSelected() override;


private:
AABBox m_box;

Expand Down
7 changes: 5 additions & 2 deletions engine/includes/components/postprocessvolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class PostProcessSettings;

class ENGINE_EXPORT PostProcessVolume : public Component {
A_REGISTER(PostProcessVolume, Component, General)
A_REGISTER(PostProcessVolume, Component, Components/Volumes)

A_PROPERTIES(
A_PROPERTY(int, priority, PostProcessVolume::priority, PostProcessVolume::setPriority),
Expand All @@ -16,6 +16,7 @@ class ENGINE_EXPORT PostProcessVolume : public Component {

public:
PostProcessVolume();
~PostProcessVolume();

int priority() const;
void setPriority(int priority);
Expand All @@ -28,11 +29,13 @@ class ENGINE_EXPORT PostProcessVolume : public Component {

AABBox bound() const;

const PostProcessSettings &settings() const;
const PostProcessSettings *settings() const;

private:
void setProperty(const char *name, const Variant &value) override;

void setSystem(ObjectSystem *system) override;

void drawGizmos() override;

private:
Expand Down
21 changes: 7 additions & 14 deletions engine/includes/components/private/postprocessorsettings.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
#ifndef POSTPROCESSORSETTINGS_H
#define POSTPROCESSORSETTINGS_H

#include <string>

#include <variant.h>

using namespace std;

namespace {
static map<string, Variant> s_settingsMap;
};

class PostProcessSettings {
public:
PostProcessSettings();

static map<string, Variant> &settings();
static std::map<std::string, Variant> &settings();

static void registerSetting(const string &name, const Variant &value);
static void registerSetting(const std::string &name, const Variant &value);

Variant readValue(const string &name) const;
void writeValue(const string &name, const Variant &value);
static Variant defaultValue(const std::string &name);

void lerp(const PostProcessSettings &settings, float t);
Variant readValue(const std::string &name) const;
void writeValue(const std::string &name, const Variant &value);

void resetDefault();

private:
unordered_map<string, Variant> m_currentValues;
std::unordered_map<std::string, Variant> m_currentValues;

static std::map<std::string, Variant> s_settingsMap;
};

#endif // POSTPROCESSORSETTINGS_H
9 changes: 5 additions & 4 deletions engine/includes/pipelinecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ENGINE_EXPORT PipelineContext : public Object {
std::list<Renderable *> &culledComponents();
std::list<BaseLight *> &sceneLights();

std::list<std::pair<const PostProcessSettings *, float> > &culledPostEffectSettings();

std::list<Renderable *> frustumCulling(const std::array<Vector3, 8> &frustum, std::list<Renderable *> &list, AABBox &box);

void setPipeline(Pipeline *pipeline);
Expand Down Expand Up @@ -97,8 +99,11 @@ class ENGINE_EXPORT PipelineContext : public Object {

std::list<Renderable *> m_sceneComponents;
std::list<Renderable *> m_culledComponents;

std::list<BaseLight *> m_sceneLights;

std::list<std::pair<const PostProcessSettings *, float>> m_culledPostProcessSettings;

BuffersMap m_textureBuffers;

std::list<PipelineTask *> m_renderTasks;
Expand All @@ -109,14 +114,10 @@ class ENGINE_EXPORT PipelineContext : public Object {

CommandBuffer *m_buffer;

PostProcessSettings *m_postProcessSettings;

MaterialInstance *m_finalMaterial;

RenderTarget *m_defaultTarget;

Texture *m_radianceMap;

Camera *m_camera;

int32_t m_width;
Expand Down
4 changes: 0 additions & 4 deletions engine/includes/pipelinetask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class ENGINE_EXPORT PipelineTask : public Object {
std::string outputName(int index) const;
virtual Texture *output(int index);

virtual void setProperty(const std::string &name, const Variant &value);

virtual void setSettings(const PostProcessSettings &settings);

void setEnabled(bool enable);
bool isEnabled() const;

Expand Down
8 changes: 4 additions & 4 deletions engine/includes/pipelinetasks/ambientocclusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AmbientOcclusion : public PipelineTask {
private:
void exec(PipelineContext &context) override;

void setSettings(const PostProcessSettings &settings) override;
void resize(int32_t width, int32_t height) override;

void setInput(int index, Texture *texture) override;

Expand All @@ -28,14 +28,14 @@ class AmbientOcclusion : public PipelineTask {
float m_power;

Texture *m_noiseTexture;
Texture *m_aoTexture;
Texture *m_blurTexture;

RenderTarget *m_ssaoTarget;
RenderTarget *m_aoTarget;
RenderTarget *m_blurTarget;
RenderTarget *m_combineTarget;

MaterialInstance *m_occlusion;
MaterialInstance *m_blur;
MaterialInstance *m_combine;

};

Expand Down
5 changes: 4 additions & 1 deletion engine/includes/pipelinetasks/antialiasing.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ class AntiAliasing : public PipelineTask {

public:
AntiAliasing();
~AntiAliasing();

private:
void exec(PipelineContext &context) override;

void setInput(int index, Texture *texture) override;

private:
Texture *m_resultTexture;

RenderTarget *m_resultTarget;

MaterialInstance *m_material;
MaterialInstance *m_resultMaterial;

};

Expand Down
3 changes: 1 addition & 2 deletions engine/includes/pipelinetasks/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ class Bloom : public PipelineTask {

public:
Bloom();
~Bloom();

private:
void exec(PipelineContext &context) override;

void resize(int32_t width, int32_t height) override;

void setSettings(const PostProcessSettings &settings) override;

void setInput(int index, Texture *source) override;

void generateKernel(float radius, int32_t steps, float *points);
Expand Down
4 changes: 4 additions & 0 deletions engine/includes/pipelinetasks/deferredlighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
#include "pipelinetask.h"

class RenderTarget;
class MaterialInstance;

class DeferredLighting : public PipelineTask {
A_REGISTER(DeferredLighting, PipelineTask, Pipeline)

public:
DeferredLighting();
~DeferredLighting();

private:
void exec(PipelineContext &context) override;

void setInput(int index, Texture *texture) override;

private:
Vector3 m_sunDirection;

RenderTarget *m_lightPass;

};
Expand Down
33 changes: 33 additions & 0 deletions engine/includes/pipelinetasks/indirect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DEFERREDINDIRECT_H
#define DEFERREDINDIRECT_H

#include "pipelinetask.h"

class RenderTarget;
class MaterialInstance;

class DeferredIndirect : public PipelineTask {
A_REGISTER(DeferredIndirect, PipelineTask, Pipeline)

public:
DeferredIndirect();

private:
void analyze(World *world) override;
void exec(PipelineContext &context) override;

void setInput(int index, Texture *texture) override;

private:
Vector4 m_cameraColor;

MaterialInstance *m_iblMaterial;

Texture *m_cameraTexture;
Texture *m_iblTexture;

RenderTarget *m_iblTarget;

};

#endif // DEFERREDINDIRECT_H
11 changes: 4 additions & 7 deletions engine/includes/pipelinetasks/reflections.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

#include "pipelinetask.h"

class Texture;
class MaterialInstance;
class RenderTarget;
class MaterialInstance;

class Reflections : public PipelineTask {
A_REGISTER(Reflections, PipelineTask, Pipeline)
Expand All @@ -19,13 +18,11 @@ class Reflections : public PipelineTask {
void setInput(int index, Texture *texture) override;

private:
MaterialInstance *m_slrMaterial;
MaterialInstance *m_combineMaterial;
MaterialInstance *m_sslrMaterial;

Texture *m_environmentTexture;
Texture *m_sslrTexture;

RenderTarget *m_slrTarget;
RenderTarget *m_combineTarget;
RenderTarget *m_sslrTarget;

};

Expand Down
42 changes: 34 additions & 8 deletions engine/src/components/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,26 @@ Object *loadObjectHelper(const Variant &value, const MetaObject *meta, Object *r
void Component::loadUserData(const VariantMap &data) {
PROFILE_FUNCTION();

std::list<std::pair<std::string, std::string>> properties;
const MetaObject *meta = metaObject();
for(int index = 0; index < meta->propertyCount(); index++) {
MetaProperty property = meta->property(index);
auto field = data.find(property.name());
properties.push_back(std::make_pair(property.name(), property.type().name()));
}
for(auto it : dynamicPropertyNames()) {
properties.push_back(std::make_pair(it, ""));
}

for(auto it : properties) {
auto field = data.find(it.first);
if(field != data.end()) {
bool isArray = false;
std::string typeName = property.type().name();
std::string typeName = it.second;
if(typeName.empty()) {
Variant value = property(it.first.c_str());
typeName = MetaType::name(value.userType());
}

trimmType(typeName, isArray);
auto factory = System::metaFactory(typeName);
if(factory) {
Expand All @@ -204,11 +217,11 @@ void Component::loadUserData(const VariantMap &data) {
Object *object = loadObjectHelper(it, factory->first, root);
list.push_back(Variant(type, &object));
}
property.write(this, list);
setProperty(it.first.c_str(), list);
} else {
Object *object = loadObjectHelper(field->second, factory->first, root);
if(object) {
property.write(this, Variant(type, &object));
setProperty(it.first.c_str(), Variant(type, &object));
}
}
}
Expand All @@ -233,25 +246,38 @@ VariantMap Component::saveUserData() const {
PROFILE_FUNCTION();
VariantMap result;

std::list<std::pair<std::string, std::string>> properties;

const MetaObject *meta = metaObject();
for(int index = 0; index < meta->propertyCount(); index++) {
MetaProperty property = meta->property(index);
properties.push_back(std::make_pair(property.name(), property.type().name()));
}
for(auto it : dynamicPropertyNames()) {
properties.push_back(std::make_pair(it, ""));
}

for(auto it : properties) {
Variant value = property(it.first.c_str());

bool isArray = false;
std::string typeName = property.type().name();
std::string typeName = it.second;
if(typeName.empty()) {
typeName = MetaType::name(value.userType());
}
trimmType(typeName, isArray);
auto factory = System::metaFactory(typeName);
if(factory) {
Variant value = property.read(this);
if(isArray) {
VariantList list;
for(auto it : value.toList()) {
Object *object = (value.data() == nullptr) ? nullptr : *(reinterpret_cast<Object **>(it.data()));
list.push_back(saveObjectHelper(object, factory->first));
}
result[property.name()] = list;
result[it.first] = list;
} else {
Object *object = (value.data() == nullptr) ? nullptr : *(reinterpret_cast<Object **>(value.data()));
result[property.name()] = saveObjectHelper(object, factory->first);
result[it.first] = saveObjectHelper(object, factory->first);
}
}
}
Expand Down
Loading