entt update to v3.11.1

This commit is contained in:
Green Sky 2022-11-11 16:22:58 +01:00 committed by Erik Scholz
parent 8036fdf2a9
commit 8d24976a13
14 changed files with 26 additions and 35 deletions

View File

@ -26,8 +26,6 @@ jobs:
with: with:
submodules: recursive submodules: recursive
# TODO: cache
- name: Install Dependencies - name: Install Dependencies
run: sudo apt update && sudo apt -y install libsdl2-dev xserver-xorg-video-dummy run: sudo apt update && sudo apt -y install libsdl2-dev xserver-xorg-video-dummy
@ -62,8 +60,6 @@ jobs:
with: with:
submodules: recursive submodules: recursive
# TODO: cache
- name: Install Dependencies - name: Install Dependencies
run: sudo apt update && sudo apt -y install libsdl2-dev run: sudo apt update && sudo apt -y install libsdl2-dev
@ -102,9 +98,6 @@ jobs:
with: with:
submodules: recursive submodules: recursive
#- name: Install Dependencies
#run: sudo apt update && sudo apt -y install libsdl2-dev
- name: Setup emsdk - name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11 uses: mymindstorm/setup-emsdk@v11
with: with:
@ -134,8 +127,6 @@ jobs:
with: with:
submodules: recursive submodules: recursive
# TODO: cache
- name: Install Dependencies - name: Install Dependencies
run: brew install sdl2 run: brew install sdl2
@ -156,7 +147,6 @@ jobs:
submodules: recursive submodules: recursive
# TODO: cache # TODO: cache
- name: Install Dependencies - name: Install Dependencies
run: vcpkg install sdl2[core,vulkan]:x64-windows run: vcpkg install sdl2[core,vulkan]:x64-windows

2
external/entt vendored

@ -1 +1 @@
Subproject commit e4ccb878f47245a319704912435d3c89f34ad6be Subproject commit fef921132cae7588213d0f9bcd2fb9c8ffd8b7fc

View File

@ -85,8 +85,8 @@ private:
bool entityHasComponent(Registry& registry, EntityType& entity, ComponentTypeID type_id) bool entityHasComponent(Registry& registry, EntityType& entity, ComponentTypeID type_id)
{ {
const auto storage_it = registry.storage(type_id); const auto* storage_ptr = registry.storage(type_id);
return storage_it != registry.storage().end() && storage_it->second.contains(entity); return storage_ptr != nullptr && storage_ptr->contains(entity);
} }
public: public:
@ -243,11 +243,11 @@ public:
} }
}); });
} else { } else {
entt::basic_runtime_view<entt::basic_sparse_set<EntityType>> view{}; entt::runtime_view view{};
for (const auto type : comp_list) { for (const auto type : comp_list) {
auto storage_it = registry.storage(type); auto* storage_ptr = registry.storage(type);
if (storage_it != registry.storage().end()) { if (storage_ptr != nullptr) {
view.iterate(registry.storage(type)->second); view.iterate(*storage_ptr);
} }
} }

View File

@ -20,7 +20,7 @@ void Camera3D(MM::Scene& scene) {
ImGui::TextUnformatted("NO CAMERA!"); ImGui::TextUnformatted("NO CAMERA!");
return; return;
} }
auto& camera = scene.ctx().at<MM::OpenGL::Camera3D>(); auto& camera = scene.ctx().get<MM::OpenGL::Camera3D>();
static bool follow_entity = false; static bool follow_entity = false;
static MM::Entity tracking = entt::null; static MM::Entity tracking = entt::null;

View File

@ -157,7 +157,7 @@ namespace MM::Services {
if (_show_time_delta_ctx) { if (_show_time_delta_ctx) {
if (ImGui::Begin("Scene TimeDelta Context", &_show_time_delta_ctx)) { if (ImGui::Begin("Scene TimeDelta Context", &_show_time_delta_ctx)) {
if (scene.ctx().contains<MM::Components::TimeDelta>()) { if (scene.ctx().contains<MM::Components::TimeDelta>()) {
auto& td = scene.ctx().at<MM::Components::TimeDelta>(); auto& td = scene.ctx().get<MM::Components::TimeDelta>();
ImGui::Value("tickDelta", td.tickDelta); ImGui::Value("tickDelta", td.tickDelta);
ImGui::SliderFloat("deltaFactor", &td.deltaFactor, 0.f, 10.f, "%.5f", ImGuiSliderFlags_Logarithmic); ImGui::SliderFloat("deltaFactor", &td.deltaFactor, 0.f, 10.f, "%.5f", ImGuiSliderFlags_Logarithmic);
} else { } else {

View File

@ -117,7 +117,7 @@ void BatchedSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) {
_vertexBuffer->bind(GL_ARRAY_BUFFER); _vertexBuffer->bind(GL_ARRAY_BUFFER);
_vao->bind(); _vao->bind();
auto& cam = scene.ctx().at<Camera3D>(); auto& cam = scene.ctx().get<Camera3D>();
auto vp = cam.getViewProjection(); auto vp = cam.getViewProjection();
_shader->setUniformMat4f("_VP", vp); _shader->setUniformMat4f("_VP", vp);

View File

@ -78,7 +78,7 @@ void FastSky::render(MM::Services::OpenGLRenderer& rs, MM::Engine& engine) {
_vao->bind(); _vao->bind();
{ {
auto& cam = scene.ctx().at<MM::OpenGL::Camera3D>(); auto& cam = scene.ctx().get<MM::OpenGL::Camera3D>();
MM::OpenGL::Camera3D tmp_cam = cam; MM::OpenGL::Camera3D tmp_cam = cam;
// create cam with y up, bc shader says so // create cam with y up, bc shader says so
tmp_cam.up = {0, 1, 0}; tmp_cam.up = {0, 1, 0};
@ -95,7 +95,7 @@ void FastSky::render(MM::Services::OpenGLRenderer& rs, MM::Engine& engine) {
//} //}
auto* ctx_ptr = &_default_context; auto* ctx_ptr = &_default_context;
if (scene.ctx().contains<FastSkyContext>()) { if (scene.ctx().contains<FastSkyContext>()) {
ctx_ptr = &scene.ctx().at<FastSkyContext>(); ctx_ptr = &scene.ctx().get<FastSkyContext>();
} }
_shader->setUniform1f("time", ctx_ptr->time); _shader->setUniform1f("time", ctx_ptr->time);

View File

@ -138,7 +138,7 @@ void LiteParticles2D::uploadParticles(Services::OpenGLRenderer&, Scene& scene) {
return; // nothing to upload return; // nothing to upload
} }
auto& queue = scene.ctx().at<Components::LiteParticles2DUploadQueue>(); auto& queue = scene.ctx().get<Components::LiteParticles2DUploadQueue>();
while (!queue.queue.empty()) { while (!queue.queue.empty()) {
// get range // get range
@ -200,7 +200,7 @@ void LiteParticles2D::computeParticles(Services::OpenGLRenderer&, Scene& scene)
std::chrono::duration<double, std::ratio<1, 1>> deltaTime = newNow - _last_time; std::chrono::duration<double, std::ratio<1, 1>> deltaTime = newNow - _last_time;
_last_time = newNow; _last_time = newNow;
float time_delta = deltaTime.count() * scene.ctx().at<MM::Components::TimeDelta>().deltaFactor; float time_delta = deltaTime.count() * scene.ctx().get<MM::Components::TimeDelta>().deltaFactor;
_time += time_delta; _time += time_delta;
_tf_shader->setUniform1f("_time_delta", time_delta); _tf_shader->setUniform1f("_time_delta", time_delta);
_tf_shader->setUniform1f("_time", _time); _tf_shader->setUniform1f("_time", _time);
@ -269,7 +269,7 @@ void LiteParticles2D::renderParticles(Services::OpenGLRenderer& rs, Scene& scene
auto& rm_t = MM::ResourceManager<Texture>::ref(); auto& rm_t = MM::ResourceManager<Texture>::ref();
rm_t.get("MM::LiteParticles2DTypes::Render"_hs)->bind(0); rm_t.get("MM::LiteParticles2DTypes::Render"_hs)->bind(0);
Camera3D& cam = scene.ctx().at<Camera3D>(); Camera3D& cam = scene.ctx().get<Camera3D>();
_points_shader->setUniformMat4f("_vp", cam.getViewProjection()); _points_shader->setUniformMat4f("_vp", cam.getViewProjection());
GLint view_port[4]; GLint view_port[4];

View File

@ -72,7 +72,7 @@ void SimpleRect::render(Services::OpenGLRenderer& rs, Engine& engine) {
_shader->bind(); _shader->bind();
_vao->bind(); _vao->bind();
Camera3D& cam = scene.ctx().at<Camera3D>(); Camera3D& cam = scene.ctx().get<Camera3D>();
auto vp = cam.getViewProjection(); auto vp = cam.getViewProjection();
scene.view<const Components::Transform4x4>().each([this, &scene, &vp](entt::entity e, const auto& t) { scene.view<const Components::Transform4x4>().each([this, &scene, &vp](entt::entity e, const auto& t) {

View File

@ -80,7 +80,7 @@ void SimpleSprite::render(Services::OpenGLRenderer& rs, Engine& engine) {
_vao->bind(); _vao->bind();
Camera3D& cam = scene.ctx().at<Camera3D>(); Camera3D& cam = scene.ctx().get<Camera3D>();
auto vp = cam.getViewProjection(); auto vp = cam.getViewProjection();
scene.view<const Components::Transform4x4, Components::OpenGL::Texture>().each([this, &scene, &vp](entt::entity e, const auto& t, auto& tex) { scene.view<const Components::Transform4x4, Components::OpenGL::Texture>().each([this, &scene, &vp](entt::entity e, const auto& t, auto& tex) {

View File

@ -81,7 +81,7 @@ void SimpleSpriteSheet::render(Services::OpenGLRenderer& rs, Engine& engine) {
_vertexBuffer->bind(GL_ARRAY_BUFFER); _vertexBuffer->bind(GL_ARRAY_BUFFER);
_vao->bind(); _vao->bind();
Camera3D& cam = scene.ctx().at<Camera3D>(); Camera3D& cam = scene.ctx().get<Camera3D>();
auto vp = cam.getViewProjection(); auto vp = cam.getViewProjection();
scene.view<const Components::Transform4x4, SpriteSheetRenderable>().each([this, &scene, &vp](entt::entity e, const auto& t, auto& spr) { scene.view<const Components::Transform4x4, SpriteSheetRenderable>().each([this, &scene, &vp](entt::entity e, const auto& t, auto& spr) {

View File

@ -96,7 +96,7 @@ void Tilemap::render(MM::Services::OpenGLRenderer& rs, MM::Engine& engine) {
_vertexBuffer->bind(GL_ARRAY_BUFFER); _vertexBuffer->bind(GL_ARRAY_BUFFER);
_vao->bind(); _vao->bind();
MM::OpenGL::Camera3D& cam = scene.ctx().at<MM::OpenGL::Camera3D>(); MM::OpenGL::Camera3D& cam = scene.ctx().get<MM::OpenGL::Camera3D>();
auto vp = cam.getViewProjection(); auto vp = cam.getViewProjection();
_shader->setUniform3f("_ambient_color", ambient_color); _shader->setUniform3f("_ambient_color", ambient_color);

View File

@ -81,7 +81,7 @@ void OrganizerSceneService::sceneFixedUpdate(Engine&) {
_accumulator -= f_delta; _accumulator -= f_delta;
continuous_counter++; continuous_counter++;
for (auto&& v : _scene->ctx().at<std::vector<entt::organizer::vertex>>()) { for (auto&& v : _scene->ctx().get<std::vector<entt::organizer::vertex>>()) {
v.callback()(v.data(), *_scene); v.callback()(v.data(), *_scene);
} }
@ -126,7 +126,8 @@ void OrganizerSceneService::updateOrganizerVertices(Scene& scene) {
scene.ctx().emplace<MM::Components::TimeDelta>(); scene.ctx().emplace<MM::Components::TimeDelta>();
} }
SPDLOG_DEBUG("graph:\n{}", scene.ctx().at<std::vector<entt::organizer::vertex>>()); // TODO: use entt::dot instead
SPDLOG_DEBUG("graph:\n{}", scene.ctx().get<std::vector<entt::organizer::vertex>>());
} }
void OrganizerSceneService::resetTime(void) { void OrganizerSceneService::resetTime(void) {

View File

@ -75,13 +75,13 @@ class ResourceManager {
return reload<Loader>(entt::hashed_string{id}.value(), std::forward<Args>(args)...); return reload<Loader>(entt::hashed_string{id}.value(), std::forward<Args>(args)...);
} }
void discard(const res_id_type id) ENTT_NOEXCEPT { void discard(const res_id_type id) noexcept {
if (auto it = _storage.find(id); it != _storage.end()) { if (auto it = _storage.find(id); it != _storage.end()) {
_storage.erase(it); _storage.erase(it);
} }
} }
void discard(const char* id) ENTT_NOEXCEPT { void discard(const char* id) noexcept {
discard(entt::hashed_string{id}.value()); discard(entt::hashed_string{id}.value());
} }
@ -100,11 +100,11 @@ class ResourceManager {
return _storage.empty(); return _storage.empty();
} }
void clear(void) ENTT_NOEXCEPT { void clear(void) noexcept {
_storage.clear(); _storage.clear();
} }
bool contains(const res_id_type id) const ENTT_NOEXCEPT { bool contains(const res_id_type id) const noexcept {
return (_storage.find(id) != _storage.cend()); return (_storage.find(id) != _storage.cend());
} }