Skip to content

Commit

Permalink
instanced fix
Browse files Browse the repository at this point in the history
effect emitters fix
  • Loading branch information
hotstreams committed Jul 2, 2023
1 parent 469234f commit f858540
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions demo/effects_demoscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ void EffectsScene::addInstances(Limitless::Assets& assets) {
add<EffectInstance>(assets.effects.at("lightning"), glm::vec3{29.0f, 1.0f, 16.0f});

auto& bob = add<SkeletalInstance>(assets.models.at("bob"), glm::vec3(29.0f, 1.0f, 19.0f))
.play("")
.setScale(glm::vec3(0.025f))
.setRotation(glm::vec3{0.0f, -M_PI_2, M_PI})
.play("");
.setRotation(glm::vec3{0.0f, -M_PI_2, M_PI});

const auto& module = add<EffectInstance>(assets.effects.at("modeldrop"), glm::vec3{0.0f})
.get<fx::SpriteEmitter>("sparks")
.getModule(fx::ModuleType::InitialMeshLocation);
dynamic_cast<fx::InitialMeshLocation<fx::SpriteParticle>&>(*module)
.attachModelInstance(&bob);
.attachModelInstance(dynamic_cast<SkeletalInstance*>(&bob));

add<EffectInstance>(assets.effects.at("skeleton"), glm::vec3{23.0f, 1.0f, 1.0f});
add<EffectInstance>(assets.effects.at("aura"), glm::vec3{23.0f, 1.0f, 4.0f});
Expand Down
4 changes: 2 additions & 2 deletions demo/models_demoscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ void ModelsScene::addInstances(Limitless::Assets& assets) {
.setRotation(glm::vec3{-M_PI_2, -M_PI_2, 0.0f});

add<SkeletalInstance>(assets.models.at("bob"), glm::vec3(25.0f, 1.0f, 16.0f))
.play("")
.setScale(glm::vec3(0.03f))
.setRotation(glm::vec3{M_PI, -M_PI_2, 0.0f})
.play("");
.setRotation(glm::vec3{M_PI, -M_PI_2, 0.0f});

add<ModelInstance>(assets.models.at("backpack"), glm::vec3(25.0f, 1.5f, 19.0f))
.setScale(glm::vec3(0.5f))
Expand Down
5 changes: 3 additions & 2 deletions include/limitless/instances/effect_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <limitless/instances/abstract_instance.hpp>
#include <unordered_map>
#include <stdexcept>
#include <iostream>

namespace Limitless {
namespace fx {
Expand Down Expand Up @@ -89,7 +90,7 @@ namespace Limitless {
template<typename EmitterType>
const EmitterType& get(const std::string& emitter_name) const {
try {
return static_cast<EmitterType&>(*emitters.at(name));
return static_cast<EmitterType&>(*emitters.at(emitter_name));
} catch (...) {
throw no_such_emitter("with name " + emitter_name);
}
Expand All @@ -101,7 +102,7 @@ namespace Limitless {
template<typename EmitterType>
EmitterType& get(const std::string& emitter_name) {
try {
return static_cast<EmitterType&>(*emitters.at(name));
return static_cast<EmitterType&>(*emitters.at(emitter_name));
} catch (...) {
throw no_such_emitter("with name " + emitter_name);
}
Expand Down
6 changes: 3 additions & 3 deletions include/limitless/instances/instanced_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ namespace Limitless {
: AbstractInstance(rhs.shader_type, rhs.position) {
initializeBuffer(rhs.instances.size());
for (const auto& instance : rhs.instances) {
instances.emplace_back(instance->clone());
instances.emplace_back((ModelInstance*)instance->clone().release());
}
}
InstancedInstance(InstancedInstance&&) noexcept = default;

InstancedInstance* clone() noexcept override {
return new InstancedInstance<ModelInstance>(*this);
std::unique_ptr<AbstractInstance> clone() noexcept override {
return std::make_unique<InstancedInstance>(*this);
}

void addInstance(std::unique_ptr<ModelInstance> instance) {
Expand Down

0 comments on commit f858540

Please sign in to comment.