Browse Source

organizer: fix organizer::vertex::prepare not creating component pools (#1014)

DonutVikingChap 2 years ago
parent
commit
319ecd8084
2 changed files with 11 additions and 1 deletions
  1. 1 1
      src/entt/entity/organizer.hpp
  2. 10 0
      test/entt/entity/organizer.cpp

+ 1 - 1
src/entt/entity/organizer.hpp

@@ -126,7 +126,7 @@ class basic_organizer final {
         if constexpr(std::is_same_v<Type, Registry>) {
             return reg;
         } else if constexpr(internal::is_view_v<Type>) {
-            return as_view{reg};
+            return static_cast<Type>(as_view{reg});
         } else {
             return reg.ctx().template emplace<std::remove_reference_t<Type>>();
         }

+ 10 - 0
test/entt/entity/organizer.cpp

@@ -1,5 +1,7 @@
 #include <cstddef>
+#include <utility>
 #include <gtest/gtest.h>
+#include <entt/core/type_info.hpp>
 #include <entt/entity/organizer.hpp>
 #include <entt/entity/registry.hpp>
 
@@ -363,6 +365,10 @@ TEST(Organizer, Prepare) {
     ASSERT_FALSE(registry.ctx().contains<char>());
     ASSERT_FALSE(registry.ctx().contains<double>());
 
+    ASSERT_EQ(std::as_const(registry).storage<int>(), nullptr);
+    ASSERT_EQ(std::as_const(registry).storage<char>(), nullptr);
+    ASSERT_EQ(std::as_const(registry).storage<double>(), nullptr);
+
     for(auto &&vertex: graph) {
         vertex.prepare(registry);
     }
@@ -370,6 +376,10 @@ TEST(Organizer, Prepare) {
     ASSERT_FALSE(registry.ctx().contains<int>());
     ASSERT_FALSE(registry.ctx().contains<char>());
     ASSERT_TRUE(registry.ctx().contains<double>());
+
+    ASSERT_NE(std::as_const(registry).storage<int>(), nullptr);
+    ASSERT_NE(std::as_const(registry).storage<char>(), nullptr);
+    ASSERT_EQ(std::as_const(registry).storage<double>(), nullptr);
 }
 
 TEST(Organizer, Dependencies) {