Compare commits

..

2 Commits

5 changed files with 67 additions and 28 deletions

View File

@ -10,10 +10,10 @@ void CVirtualContainer::add (const std::filesystem::path& filename, const std::s
} }
void CVirtualContainer::add (const std::filesystem::path& filename, const std::string& contents) { void CVirtualContainer::add (const std::filesystem::path& filename, const std::string& contents) {
size_t length = contents.length () + 1; // do not copy the null terminator
size_t length = contents.length ();
std::shared_ptr<uint8_t[]> copy = std::shared_ptr<uint8_t[]> (new uint8_t [length]); std::shared_ptr<uint8_t[]> copy = std::shared_ptr<uint8_t[]> (new uint8_t [length]);
// copy the text AND the \0
memcpy (copy.get(), contents.c_str (), length); memcpy (copy.get(), contents.c_str (), length);
// finally add to the container // finally add to the container

View File

@ -63,7 +63,12 @@ std::map <int, std::string> MaterialParser::parseTextures (const JSON& it) {
for (const auto& cur : it) { for (const auto& cur : it) {
if (!cur.is_null ()) { if (!cur.is_null ()) {
result.emplace (index, cur); if (!cur.is_string ()) {
sLog.error ("Detected a non-string texture, most likely a special value: ", cur.dump ());
result.emplace (index, "");
} else {
result.emplace (index, cur);
}
} }
index++; index++;

View File

@ -234,11 +234,7 @@ void CImage::setup () {
return; return;
} }
// TODO: SETUP RECALCULATION OF THINGS WHEN A VISIBILITY VALUE CHANGES!! // TODO: CHECK ORDER OF THINGS, 2419444134'S ID 27 DEPENDS ON 104'S COMPOSITE_A WHEN OUR LAST RENDER IS ON COMPOSITE_B
if (!this->m_image.visible->value->getBool ()) {
return;
}
// TODO: SUPPORT PASSTHROUGH (IT'S A SHADER) // TODO: SUPPORT PASSTHROUGH (IT'S A SHADER)
// passthrough images without effects are bad, do not draw them // passthrough images without effects are bad, do not draw them
if (this->m_image.model->passthrough && this->m_image.effects.empty ()) { if (this->m_image.model->passthrough && this->m_image.effects.empty ()) {
@ -317,19 +313,18 @@ void CImage::setup () {
new CPass (*this, fboProvider, config, std::nullopt, std::nullopt, (*curEffect)->target.value ()) new CPass (*this, fboProvider, config, std::nullopt, std::nullopt, (*curEffect)->target.value ())
); );
} else { } else {
auto curPass = (*curEffect)->material.value ()->passes.begin (); for (auto& pass : (*curEffect)->material.value ()->passes) {
auto endPass = (*curEffect)->material.value ()->passes.end (); const auto override =
curOverride != endOverride
? **curOverride
: std::optional<std::reference_wrapper<const ImageEffectPassOverride>> (std::nullopt);
const auto target = (*curEffect)->target.has_value ()
? *(*curEffect)->target
: std::optional<std::reference_wrapper<std::string>> (std::nullopt);
const auto override = this->m_passes.push_back (
curOverride != endOverride new CPass (*this, fboProvider, *pass, override, (*curEffect)->binds, target));
? **curOverride }
: std::optional<std::reference_wrapper<const ImageEffectPassOverride>> (std::nullopt);
const auto target = (*curEffect)->target.has_value ()
? *(*curEffect)->target
: std::optional<std::reference_wrapper<std::string>> (std::nullopt);
this->m_passes.push_back (
new CPass (*this, fboProvider, **curPass, override, (*curEffect)->binds, target));
if (curOverride != endOverride) { if (curOverride != endOverride) {
curOverride++; curOverride++;

View File

@ -64,14 +64,8 @@ CScene::CScene (
this->createObject (*object); this->createObject (*object);
// copy over objects by render order // copy over objects by render order
for (const auto& cur : scene->objects) { for (const auto& object : scene->objects) {
auto obj = this->m_objects.find (cur->id); this->addObjectToRenderOrder (*object);
// ignores not created objects like particle systems
if (obj == this->m_objects.end ())
continue;
this->m_objectsByRenderOrder.emplace_back (obj->second);
} }
// create extra framebuffers for the bloom effect // create extra framebuffers for the bloom effect
@ -203,6 +197,50 @@ Render::CObject* CScene::createObject (const Object& object) {
return renderObject; return renderObject;
} }
void CScene::addObjectToRenderOrder (const Object& object) {
auto obj = this->m_objects.find (object.id);
// ignores not created objects like particle systems
if (obj == this->m_objects.end ())
return;
// take into account any dependency first
for (const auto& dep : object.dependencies) {
// self-dependency is possible
if (dep == object.id) {
continue;
}
// add the dependency to the list if it's created
auto depIt = std::find_if (
this->getScene ().objects.begin (),
this->getScene ().objects.end (),
[&dep] (const auto& o) {
return o->id == dep;
}
);
if (depIt != this->getScene ().objects.end ()) {
this->addObjectToRenderOrder (**depIt);
} else {
sLog.error ("Cannot find dependency ", dep, " for object ", object.id);
}
}
// ensure we're added only once to the render list
const auto renderIt = std::find_if (
this->m_objectsByRenderOrder.begin (),
this->m_objectsByRenderOrder.end (),
[&object] (const auto& o) {
return o->getId () == object.id;
}
);
if (renderIt == this->m_objectsByRenderOrder.end ()) {
this->m_objectsByRenderOrder.emplace_back (obj->second);
}
}
CCamera& CScene::getCamera () const { CCamera& CScene::getCamera () const {
return *this->m_camera; return *this->m_camera;
} }

View File

@ -40,6 +40,7 @@ class CScene final : public CWallpaper {
private: private:
Render::CObject* createObject (const Object& object); Render::CObject* createObject (const Object& object);
void addObjectToRenderOrder (const Object& object);
std::unique_ptr<CCamera> m_camera; std::unique_ptr<CCamera> m_camera;
ObjectUniquePtr m_bloomObjectData; ObjectUniquePtr m_bloomObjectData;