Skip to content

Commit

Permalink
gh-12: gh-36: setup scene update
Browse files Browse the repository at this point in the history
- clear node workflow
- add trasforms setup
- rework ecs systems
- add hier update system
- add node events
- rename string id to strid
  • Loading branch information
EgorOrachyov committed Mar 4, 2024
1 parent 4c76429 commit 69bfdd7
Show file tree
Hide file tree
Showing 229 changed files with 1,949 additions and 11,299 deletions.
6 changes: 4 additions & 2 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ add_library(wmoge STATIC
event/event_window.hpp
event/event_resource.cpp
event/event_resource.hpp
event/event_scene.cpp
event/event_scene.hpp
event/register_classes_event.cpp
event/register_classes_event.hpp
gameplay/action_manager.cpp
Expand Down Expand Up @@ -276,6 +278,8 @@ add_library(wmoge STATIC
render/camera.hpp
render/canvas.cpp
render/canvas.hpp
render/culling.cpp
render/culling.hpp
render/deferred_pipeline.cpp
render/deferred_pipeline.hpp
render/graphics_pipeline.cpp
Expand Down Expand Up @@ -304,8 +308,6 @@ add_library(wmoge STATIC
render/view.hpp
render/view_manager.cpp
render/view_manager.hpp
render/visibility.cpp
render/visibility.hpp
resource/array_mesh.cpp
resource/array_mesh.hpp
resource/audio_stream.cpp
Expand Down
4 changes: 2 additions & 2 deletions engine/audio/audio_bus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ namespace wmoge {
virtual void set_pitch_scale(float value) = 0;
virtual void get_playbacks(std::vector<Ref<AudioPlayback>>& playbacks) = 0;

const StringId& get_name() const { return m_name; }
const Strid& get_name() const { return m_name; }

protected:
StringId m_name;
Strid m_name;
};

}// namespace wmoge
Expand Down
28 changes: 14 additions & 14 deletions engine/audio/audio_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@ namespace wmoge {
public:
virtual ~AudioEngine() = default;

virtual void update() = 0;
virtual void shutdown() = 0;
virtual Ref<AudioPlayback> make_playback(Ref<AudioStream> stream, const StringId& bus, const StringId& name) = 0;
virtual Ref<AudioBus> make_bus(const StringId& name) = 0;
virtual Ref<AudioBus> find_bus(const StringId& name) = 0;
virtual bool has_bus(const StringId& name) = 0;
virtual void update() = 0;
virtual void shutdown() = 0;
virtual Ref<AudioPlayback> make_playback(Ref<AudioStream> stream, const Strid& bus, const Strid& name) = 0;
virtual Ref<AudioBus> make_bus(const Strid& name) = 0;
virtual Ref<AudioBus> find_bus(const Strid& name) = 0;
virtual bool has_bus(const Strid& name) = 0;

const AudioDriverCaps& get_caps() const { return m_caps; }
const StringId& get_engine_name() const { return m_engine_name; }
const StringId& get_driver_name() const { return m_driver_name; }
const StringId& get_device_name() const { return m_device_name; }
const StringId& get_default_bus() const { return m_default_bus; }
const Strid& get_engine_name() const { return m_engine_name; }
const Strid& get_driver_name() const { return m_driver_name; }
const Strid& get_device_name() const { return m_device_name; }
const Strid& get_default_bus() const { return m_default_bus; }

protected:
AudioDriverCaps m_caps;
StringId m_engine_name;
StringId m_driver_name;
StringId m_device_name;
StringId m_default_bus;
Strid m_engine_name;
Strid m_driver_name;
Strid m_device_name;
Strid m_default_bus;
};

}// namespace wmoge
Expand Down
8 changes: 4 additions & 4 deletions engine/audio/audio_playback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ namespace wmoge {
virtual void set_loop(bool value) = 0;

const Ref<AudioStream>& get_stream() const { return m_stream; }
const StringId& get_name() const { return m_name; }
const StringId& get_bus_name() const { return m_bus_name; }
const Strid& get_name() const { return m_name; }
const Strid& get_bus_name() const { return m_bus_name; }

protected:
Ref<AudioStream> m_stream;
StringId m_name;
StringId m_bus_name;
Strid m_name;
Strid m_bus_name;
};

}// namespace wmoge
Expand Down
2 changes: 1 addition & 1 deletion engine/audio/openal/al_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace wmoge {

ALAudioBus::ALAudioBus(StringId name, class ALAudioEngine& engine) : m_engine(engine) {
ALAudioBus::ALAudioBus(Strid name, class ALAudioEngine& engine) : m_engine(engine) {
assert(!name.empty());
m_name = std::move(name);
}
Expand Down
2 changes: 1 addition & 1 deletion engine/audio/openal/al_bus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace wmoge {
*/
class ALAudioBus final : public AudioBus {
public:
ALAudioBus(StringId name, class ALAudioEngine& engine);
ALAudioBus(Strid name, class ALAudioEngine& engine);
~ALAudioBus() override;

void add_playback(ALAudioPlayback* playback);
Expand Down
10 changes: 5 additions & 5 deletions engine/audio/openal/al_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace wmoge {
WG_LOG_INFO("shutdown openal audio engine");
}

Ref<AudioPlayback> ALAudioEngine::make_playback(Ref<AudioStream> stream, const StringId& bus, const StringId& name) {
Ref<AudioPlayback> ALAudioEngine::make_playback(Ref<AudioStream> stream, const Strid& bus, const Strid& name) {
WG_AUTO_PROFILE_OPENAL("ALAudioEngine::make_playback");

std::lock_guard guard(m_mutex);
Expand All @@ -92,7 +92,7 @@ namespace wmoge {

return make_ref<ALAudioPlayback>(std::move(stream), bus, name, *this);
}
Ref<AudioBus> ALAudioEngine::make_bus(const StringId& name) {
Ref<AudioBus> ALAudioEngine::make_bus(const Strid& name) {
WG_AUTO_PROFILE_OPENAL("ALAudioEngine::make_bus");

std::lock_guard guard(m_mutex);
Expand All @@ -111,17 +111,17 @@ namespace wmoge {

return (m_bus[name] = make_ref<ALAudioBus>(name, *this)).as<AudioBus>();
}
Ref<AudioBus> ALAudioEngine::find_bus(const StringId& name) {
Ref<AudioBus> ALAudioEngine::find_bus(const Strid& name) {
std::lock_guard guard(m_mutex);
auto query = m_bus.find(name);
return query != m_bus.end() ? query->second.as<AudioBus>() : Ref<AudioBus>{};
}
bool ALAudioEngine::has_bus(const StringId& name) {
bool ALAudioEngine::has_bus(const Strid& name) {
std::lock_guard guard(m_mutex);
return m_bus.find(name) != m_bus.end();
}

ALAudioBus* ALAudioEngine::get_bus(const StringId& name) {
ALAudioBus* ALAudioEngine::get_bus(const Strid& name) {
auto query = m_bus.find(name);
assert(query != m_bus.end());
return query != m_bus.end() ? query->second.get() : nullptr;
Expand Down
18 changes: 9 additions & 9 deletions engine/audio/openal/al_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ namespace wmoge {

void update() override;
void shutdown() override;
Ref<AudioPlayback> make_playback(Ref<AudioStream> stream, const StringId& bus, const StringId& name) override;
Ref<AudioBus> make_bus(const StringId& name) override;
Ref<AudioBus> find_bus(const StringId& name) override;
bool has_bus(const StringId& name) override;
Ref<AudioPlayback> make_playback(Ref<AudioStream> stream, const Strid& bus, const Strid& name) override;
Ref<AudioBus> make_bus(const Strid& name) override;
Ref<AudioBus> find_bus(const Strid& name) override;
bool has_bus(const Strid& name) override;

ALAudioBus* get_bus(const StringId& name);
ALAudioBus* get_bus(const Strid& name);
ALCdevice* get_device();
ALCcontext* get_context();
std::recursive_mutex& get_mutex();
Expand All @@ -65,10 +65,10 @@ namespace wmoge {
bool init_caps();

private:
fast_map<StringId, Ref<ALAudioBus>> m_bus;
ALCdevice* m_device = nullptr;
ALCcontext* m_context = nullptr;
std::recursive_mutex m_mutex;
fast_map<Strid, Ref<ALAudioBus>> m_bus;
ALCdevice* m_device = nullptr;
ALCcontext* m_context = nullptr;
std::recursive_mutex m_mutex;
};

}// namespace wmoge
Expand Down
2 changes: 1 addition & 1 deletion engine/audio/openal/al_playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace wmoge {

ALAudioPlayback::ALAudioPlayback(Ref<AudioStream> stream, StringId bus, const StringId& name, class ALAudioEngine& engine)
ALAudioPlayback::ALAudioPlayback(Ref<AudioStream> stream, Strid bus, const Strid& name, class ALAudioEngine& engine)
: m_engine(engine) {

WG_AUTO_PROFILE_OPENAL("ALAudioPlayback::ALAudioPlayback");
Expand Down
2 changes: 1 addition & 1 deletion engine/audio/openal/al_playback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace wmoge {
*/
class ALAudioPlayback final : public AudioPlayback {
public:
ALAudioPlayback(Ref<AudioStream> stream, StringId bus, const StringId& name, class ALAudioEngine& engine);
ALAudioPlayback(Ref<AudioStream> stream, Strid bus, const Strid& name, class ALAudioEngine& engine);
~ALAudioPlayback() override;

void play() override;
Expand Down
24 changes: 12 additions & 12 deletions engine/core/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@

namespace wmoge {

ClassMember::ClassMember(StringId name)
ClassMember::ClassMember(Strid name)
: m_name(name) {
}

ClassProperty::ClassProperty(VarType type, StringId name, StringId getter, StringId setter)
ClassProperty::ClassProperty(VarType type, Strid name, Strid getter, Strid setter)
: ClassMember(name), m_getter(getter), m_setter(setter), m_type(type) {
}

ClassField::ClassField(VarType type, StringId name)
ClassField::ClassField(VarType type, Strid name)
: ClassProperty(type, name) {
}

ClassMethod::ClassMethod(VarType ret, StringId name, std::vector<StringId> args)
ClassMethod::ClassMethod(VarType ret, Strid name, std::vector<Strid> args)
: ClassMember(name), m_args_names(std::move(args)), m_ret(ret) {
}
Status ClassMethod::call(Object* object, int argc, const Var* argv, Var& ret) const {
return m_callable(*this, object, argc, argv, ret);
}

Class* ClassDB::class_emplace(StringId name) {
Class* ClassDB::class_emplace(Strid name) {
Class* ptr = class_ptr(name);
if (!ptr) {
auto& storage = m_db[name];
Expand All @@ -59,7 +59,7 @@ namespace wmoge {
}
return ptr;
}
Class* ClassDB::class_ptr(StringId name) {
Class* ClassDB::class_ptr(Strid name) {
auto query = m_db.find(name);
return query != m_db.end() ? query->second.get() : nullptr;
}
Expand All @@ -71,15 +71,15 @@ namespace wmoge {
const Class* Class::super() const {
return class_ptr(super_name());
}
const ClassProperty* Class::property(const StringId& name) const {
const ClassProperty* Class::property(const Strid& name) const {
auto query = m_properties.find(name);
return query != m_properties.end() ? query->second : nullptr;
}
const ClassField* Class::field(const StringId& name) const {
const ClassField* Class::field(const Strid& name) const {
auto query = m_fields.find(name);
return query != m_fields.end() ? query->second : nullptr;
}
const ClassMethod* Class::method(const StringId& name) const {
const ClassMethod* Class::method(const Strid& name) const {
auto query = m_methods.find(name);
return query != m_methods.end() ? query->second : nullptr;
}
Expand All @@ -103,15 +103,15 @@ namespace wmoge {
return Ref<Object>(m_instantiate());
}

bool Class::is_inherited_from(const StringId& name) const {
bool Class::is_inherited_from(const Strid& name) const {
return m_supers.find(name) != m_supers.end();
}

Class* Class::class_ptr(StringId name) {
Class* Class::class_ptr(Strid name) {
ClassDB* db = class_db();
return db->class_ptr(name);
}
Class* Class::register_class(const StringId& name, const StringId& super, std::size_t size, std::function<Object*()> instantiate) {
Class* Class::register_class(const Strid& name, const Strid& super, std::size_t size, std::function<Object*()> instantiate) {
if (!class_ptr(super)) {
WG_LOG_ERROR("no such supper class: " << super << " registered");
return nullptr;
Expand Down
Loading

0 comments on commit 69bfdd7

Please sign in to comment.