From 288e1b7ee4d331550dc07732ed0f7b0bbd12b8e6 Mon Sep 17 00:00:00 2001 From: Miguel Martin Date: Wed, 28 Oct 2015 16:52:44 +1030 Subject: [PATCH 01/16] Fix #62 Increase minor version --- CMakeLists.txt | 2 +- include/anax/Component.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7658770..650026b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") set(ANAX_LIBRARY_NAME "anax") set(ANAX_VERSION_MAJOR 2) -set(ANAX_VERSION_MINOR 0) +set(ANAX_VERSION_MINOR 1) set(ANAX_VERSION_PATCH 0) set(PROJECT_VERSION ${ANAX_VERSION_MAJOR}.${ANAX_VERSION_MINOR}.${ANAX_VERSION_PATCH}) diff --git a/include/anax/Component.hpp b/include/anax/Component.hpp index b31aa9b..a4679a3 100644 --- a/include/anax/Component.hpp +++ b/include/anax/Component.hpp @@ -30,6 +30,7 @@ #include #include +#include namespace anax { From 5dfca6f06e7d8cde258f560be351f5f3909384c2 Mon Sep 17 00:00:00 2001 From: Yassine El Khadiri Date: Sat, 23 Jan 2016 12:57:39 +0100 Subject: [PATCH 02/16] Add missing include to algorithm in PlayerInputSystem Examples weren't compiling because the linker was loading cstdio's std::remove symbol instead of algorithm's. --- examples/common/include/Systems/PlayerInputSystem.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/common/include/Systems/PlayerInputSystem.hpp b/examples/common/include/Systems/PlayerInputSystem.hpp index 43b6d8c..33e8384 100755 --- a/examples/common/include/Systems/PlayerInputSystem.hpp +++ b/examples/common/include/Systems/PlayerInputSystem.hpp @@ -29,6 +29,8 @@ #ifndef ANAX_EXAMPLES_MOVEMENT_PLAYERINPUTSYSTEM_HPP #define ANAX_EXAMPLES_MOVEMENT_PLAYERINPUTSYSTEM_HPP +#include + #include #include From 8eeacb59998085114be1383f90ed591ed68c7bf2 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sat, 9 Jul 2016 23:01:19 -0700 Subject: [PATCH 03/16] Move the CMake-generated config header into build tree, instead of dirtying source tree. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650026b..6de5e7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,10 +56,11 @@ set(ANAX_MAX_AMOUNT_OF_COMPONENTS 64 CACHE INTEGER "The maximum amount of compon # set up the configure file for the library -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/anax/Config.hpp.inl ${CMAKE_CURRENT_SOURCE_DIR}/include/anax/Config.hpp) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/anax/Config.hpp.inl ${CMAKE_CURRENT_BINARY_DIR}/include/anax/Config.hpp) # Add include directories include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) # Determine if we're building a shared (dynamic) library # And set appropriate suffixes for the executables From 4eec7cd2428c9db54e4692eb45b6a38c0be676c8 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sun, 10 Jul 2016 09:23:54 -0700 Subject: [PATCH 04/16] Also install the generated header when installing header files. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6de5e7e..568a0b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,11 @@ if(INSTALL_HEADERS) DESTINATION . FILES_MATCHING PATTERN "*.hpp" ) + install( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include + DESTINATION . + FILES_MATCHING PATTERN "*.hpp" + ) endif() # Set properties for the library From d43b5cbfbcf8e71cd1fa7802d16c67fee69565f1 Mon Sep 17 00:00:00 2001 From: spitofland Date: Wed, 14 Dec 2016 16:57:00 -0700 Subject: [PATCH 05/16] Update EntityIdPool.cpp Added some tests to make it easier to check if an entity exists at a given index without throwing asserts. Removed a resize command in the 'clear' function. The code seems to expect the m_counts vector and several other vectors to be the same size. When the World::clear function is called, this call to 'resize' breaks that assumption, which can result in crashes due to out-of-bounds indexes on the other vectors. --- src/anax/detail/EntityIdPool.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/anax/detail/EntityIdPool.cpp b/src/anax/detail/EntityIdPool.cpp index 17fee0c..679f117 100644 --- a/src/anax/detail/EntityIdPool.cpp +++ b/src/anax/detail/EntityIdPool.cpp @@ -69,14 +69,18 @@ namespace anax Entity::Id EntityIdPool::get(std::size_t index) const { - ANAX_ASSERT(index < m_counts.size(), "Entity index is out of range"); - ANAX_ASSERT(!(m_counts[index] == 0), "Entity ID does not exist"); - return Entity::Id{index, m_counts[index]}; + if( index < m_counts.size() ) + return Entity::Id(index, m_counts[index]); + else + return Entity::Id{index, 0}; } bool EntityIdPool::isValid(Entity::Id id) const { - return id.counter == m_counts[id.index]; + if( id.index >= m_counts.size() ) + return false; + else + return (id.counter == m_counts[id.index]) && (id.counter > 0); } std::size_t EntityIdPool::getSize() const @@ -94,8 +98,6 @@ namespace anax m_counts.clear(); m_freeList.clear(); m_nextId = 0; - - m_counts.resize(m_defaultPoolSize); } } } From 9a93eeaadba8b9077a15623cefb7d797002a3b09 Mon Sep 17 00:00:00 2001 From: spitofland Date: Wed, 14 Dec 2016 16:59:44 -0700 Subject: [PATCH 06/16] Update World.cpp Made it easier to test the activation status without hitting asserts by testing validity first. --- src/anax/World.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/anax/World.cpp b/src/anax/World.cpp index 2705011..f980654 100644 --- a/src/anax/World.cpp +++ b/src/anax/World.cpp @@ -114,9 +114,10 @@ namespace anax bool World::isActivated(const Entity& entity) const { - ANAX_ASSERT(isValid(entity), "invalid entity passed to isActivated"); - - return m_entityAttributes.attributes[entity.getId().index].activated; + if( isValid(entity) ) + return m_entityAttributes.attributes[entity.getId().index].activated; + else + return false; } bool World::isValid(const anax::Entity &entity) const From 7e8a008834ac897d535d90409a058f79e77a9809 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 15 Dec 2016 07:51:43 -0700 Subject: [PATCH 07/16] Update Test_Entities.cpp Corrected a test that was expecting an exception and now should expect an invalid entity. --- tests/Test_Entities.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Test_Entities.cpp b/tests/Test_Entities.cpp index fd64bb7..4cd999e 100644 --- a/tests/Test_Entities.cpp +++ b/tests/Test_Entities.cpp @@ -67,7 +67,7 @@ using namespace anax; // ✓ Removing a component => does hasComponent return false? // ✓ Removing all components => does hasComponent return false? // 6. Retrieving an entity via index -// ✓ Invalid index => assertion occurs? +// ✓ Invalid index => invalid entity returned? // ✓ Valid index => appropriate entity returned? // ✓ Multiple entities added/removed => appropriate entity returned? @@ -414,7 +414,7 @@ const lest::test specification[] = anax::World world; auto e = world.createEntity(); - EXPECT_THROWS_AS(world.getEntity(-1), anax::TestException); + EXPECT(!(world.getEntity(-1).isValid())); } }; From 9a080e48f88ba5d281190856109eaff851f138d8 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 16 Dec 2016 07:34:33 -0700 Subject: [PATCH 08/16] Cleanup Formatting (#1) * Update World.cpp * Update EntityIdPool.cpp Correcting the formatting of changes to match coding style. --- src/anax/World.cpp | 2 +- src/anax/detail/EntityIdPool.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/anax/World.cpp b/src/anax/World.cpp index f980654..8fea205 100644 --- a/src/anax/World.cpp +++ b/src/anax/World.cpp @@ -114,7 +114,7 @@ namespace anax bool World::isActivated(const Entity& entity) const { - if( isValid(entity) ) + if(isValid(entity)) return m_entityAttributes.attributes[entity.getId().index].activated; else return false; diff --git a/src/anax/detail/EntityIdPool.cpp b/src/anax/detail/EntityIdPool.cpp index 679f117..f41eae3 100644 --- a/src/anax/detail/EntityIdPool.cpp +++ b/src/anax/detail/EntityIdPool.cpp @@ -69,15 +69,15 @@ namespace anax Entity::Id EntityIdPool::get(std::size_t index) const { - if( index < m_counts.size() ) - return Entity::Id(index, m_counts[index]); + if(index < m_counts.size()) + return Entity::Id{index, m_counts[index]}; else return Entity::Id{index, 0}; } bool EntityIdPool::isValid(Entity::Id id) const { - if( id.index >= m_counts.size() ) + if(id.index >= m_counts.size()) return false; else return (id.counter == m_counts[id.index]) && (id.counter > 0); From 6ab18dd3fb84ea18c43b7e74bf9b2501f6251dac Mon Sep 17 00:00:00 2001 From: TBeihammer Date: Sun, 29 Jan 2017 14:44:37 +0100 Subject: [PATCH 09/16] Update README.md Fixed a little typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ea8f1f..ae1e310 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This section will explain how to use the library, but it will not go into much s ### The World -A World is used to describe you game world or 'entity system' if you will. You must always have at least have one World object in order to use anax. e.g. +A World is used to describe you game world or 'entity system' if you will. You must always have at least one World object in order to use anax. e.g. ```c++ World world; From 6d264a333400ad5ef320987fdb1ee2f4cfaabee6 Mon Sep 17 00:00:00 2001 From: Arkady Shapkin Date: Sat, 6 May 2017 23:41:29 +0300 Subject: [PATCH 10/16] Install dll's to bin directory --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 568a0b9..435c750 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,7 @@ endif() # Library files install( TARGETS ${ANAX_LIBRARY_NAME} + RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) From 9c3e7d9d2d9cf14b4df44be990e319dd1c829153 Mon Sep 17 00:00:00 2001 From: Aljenci Date: Thu, 1 Jun 2017 18:53:36 +0200 Subject: [PATCH 11/16] Add example of anax::Excludes in System creation in Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae1e310..cfc8305 100644 --- a/README.md +++ b/README.md @@ -109,13 +109,13 @@ auto pos = entity.getComponent(); A System is used to contain on entities with specific components (require or exclude a set of component types). It is typically used to update, render or perform some logic these entities. ```c++ -struct MovementSystem : anax::System> +struct MovementSystem : anax::System, anax::Excludes> { // ... }; ``` -That is, a movement system requires entities with a `PositionComponent` and `VelocityComponent`. You may determine if an entity is removed/added to the system via these two override-able (virtual) methods: +That is, a movement system requires entities with a `PositionComponent` and `VelocityComponent`, also excludes entities with a `ParalizedComponent`. You may determine if an entity is removed/added to the system via these two override-able (virtual) methods: - `onEntityAdded(Entity&)` - `onEntityRemoved(Entity&)` From 593eda2b759f0ce4b08afb4ca65418ba05551c90 Mon Sep 17 00:00:00 2001 From: Kim Date: Wed, 4 Oct 2017 18:53:31 +0200 Subject: [PATCH 12/16] Remove duplicate module path in CmakeLists.txt --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 568a0b9..f87b920 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project (ANAX) -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") - set(ANAX_LIBRARY_NAME "anax") set(ANAX_VERSION_MAJOR 2) set(ANAX_VERSION_MINOR 1) From cd84fdfdea3607cc55edb5ea666e6c8df455b377 Mon Sep 17 00:00:00 2001 From: Kira Backes Date: Mon, 16 Oct 2017 17:10:29 +0200 Subject: [PATCH 13/16] Fix data race for type ID generation --- include/anax/detail/ClassTypeId.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/anax/detail/ClassTypeId.hpp b/include/anax/detail/ClassTypeId.hpp index ca35766..9b5799e 100644 --- a/include/anax/detail/ClassTypeId.hpp +++ b/include/anax/detail/ClassTypeId.hpp @@ -27,6 +27,7 @@ #define ANAX_DETAIL_CLASSTYPEID_HPP #include +#include namespace anax { @@ -48,11 +49,11 @@ namespace anax private: - static TypeId m_nextTypeId; + static std::atomic m_nextTypeId; }; template - TypeId ClassTypeId::m_nextTypeId = 0; + std::atomic ClassTypeId::m_nextTypeId{0}; } } From cbf1b1bd4ade8fa0138c49c00c92d6563b860f8b Mon Sep 17 00:00:00 2001 From: ninnghazad Date: Sat, 16 May 2020 12:59:10 +0200 Subject: [PATCH 14/16] Changing 'requires' to 'requirements'. Because 'requires' is a keyword by now. --- include/anax/detail/Filter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/anax/detail/Filter.hpp b/include/anax/detail/Filter.hpp index 8b5eec6..b5311eb 100644 --- a/include/anax/detail/Filter.hpp +++ b/include/anax/detail/Filter.hpp @@ -48,8 +48,8 @@ namespace anax { public: - Filter(ComponentTypeList requires, ComponentTypeList excludes) : - m_requires(requires), m_excludes(excludes) + Filter(ComponentTypeList requirements, ComponentTypeList excludes) : + m_requires(requirements), m_excludes(excludes) { } bool doesPassFilter(const ComponentTypeList& typeList) const; From ab07a730e55d3489a3c4facf947a7b40ec27c643 Mon Sep 17 00:00:00 2001 From: xerdink Date: Thu, 26 Nov 2020 18:01:36 +0300 Subject: [PATCH 15/16] fix(cmake): i386 arch deprecated on OSX --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83cdac2..836ef8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ set_target_properties(${ANAX_LIBRARY_NAME} PROPERTIES ) if(APPLE) - set_target_properties(${ANAX_LIBRARY_NAME} PROPERTIES OSX_ARCHITECTURES "i386;x86_64;") + set_target_properties(${ANAX_LIBRARY_NAME} PROPERTIES OSX_ARCHITECTURES "x86_64;") endif() # Library files From 48b36fe6e0c077a2cdbb130681d04d3cf5fa4297 Mon Sep 17 00:00:00 2001 From: Miguel Martin Date: Thu, 11 Mar 2021 09:29:04 -0800 Subject: [PATCH 16/16] Archived/deprecated --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cfc8305..8ea2fc7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # anax [![Build Status](https://travis-ci.org/miguelmartin75/anax.svg?branch=master)](https://travis-ci.org/miguelmartin75/anax) +**ARCHIVED: as I haven't maintained this library for at least a couple of years. I don't have the time or interest to work on this. Please use another library or just write your game without an ECS ;)** + anax is an open source C++ entity system designed to be portable, lightweight and easy to use. It is aimed toward Game Development, however it would be possible to use it for other projects. # What's an Entity System?