Closed smarchevsky closed 5 years ago
#include <entityx/entityx.h> #include <iostream> #include <cassert> namespace ex = entityx; using namespace std; struct vec2 { float x, y; vec2(float x, float y) : x(x), y(y) {} vec2() : x(0), y(0) {} vec2 operator+(const vec2 &v) { return vec2(x + v.x, y + v.y); } vec2 &operator+=(const vec2 &v) { return *this = *this + v; } void log() { std::cout << x << " " << y << std::endl; } }; struct Position : vec2 { Position() {} Position(float x, float y) : vec2(x, y) {} }; struct Direction : vec2 { Direction() {} Direction(float x, float y) : vec2(x, y) {} }; struct MovementSystem : public ex::System<MovementSystem> { void update(entityx::EntityManager &es, entityx::EventManager &events, ex::TimeDelta dt) override { const float fdt = static_cast<float>(dt); es.each<Position, Direction>([fdt](ex::Entity entity, Position &pos, Direction &dir) { pos.x += dir.x * fdt; pos.y += dir.y * fdt; }); } }; int main() { entityx::EntityX world; world.systems.add<MovementSystem>(); world.systems.configure(); world.systems.update<MovementSystem>(1.2); entityx::Entity entity = world.entities.create(); entity.assign<Position>(1.0f, 2.0f); entity.assign<Direction>(1.0f, 2.0f); }
When add line "world.systems.add();" - I receive a runtime assert:
CppTest: malloc.c:2401: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed. The program has unexpectedly finished.
What OS/compiler/versions?
Sorry, I just noticed while debugging. I linked Anax and EntityX in one project. Just did it to try different ECS. Breakpoint moved to Anax headers.
Ok.
When add line "world.systems.add();" - I receive a runtime assert: