Skip to content

Commit

Permalink
#124 rename ecs_rows_t to ecs_view_t
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jun 4, 2020
1 parent 08bfc88 commit bc885a5
Show file tree
Hide file tree
Showing 104 changed files with 1,927 additions and 1,927 deletions.
230 changes: 115 additions & 115 deletions Manual.md

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ typedef struct Position {

typedef float Speed;

void Move(ecs_rows_t *rows) {
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Speed, s, 2);
void Move(ecs_view_t *view) {
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Speed, s, 2);

for (int i = 0; i < rows->count; i ++) {
p[i].x += s[i] * rows->delta_time;
p[i].y += s[i] * rows->delta_time;
for (int i = 0; i < view->count; i ++) {
p[i].x += s[i] * view->delta_time;
p[i].y += s[i] * view->delta_time;
}
}

Expand Down Expand Up @@ -322,9 +322,9 @@ ECS_SYSTEM(world, LogPoints, EcsOnUpdate, Point);
In this statement, `LogPoints` refers to a C function that will be associated with the system. `EcsOnUpdate` identifies the stage in which the system is executed. The `Point` identifies the component interest expression. The system is implemented as a regular C function, like this:

```c
void LogPoints(ecs_rows_t *rows) {
Point *p = ecs_column(rows, Point, 1);
for (int i = 0; i < rows->count; i ++) {
void LogPoints(ecs_view_t *view) {
Point *p = ecs_column(view, Point, 1);
for (int i = 0; i < view->count; i ++) {
printf("Log point (%d, %d)\n", p[i].x, p[i].y);
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/build/bazel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ int main(int argc, char *argv[]) {
flecs::component<Velocity>(world, "Velocity");

flecs::system<Position, Velocity>(world)
.action([](const flecs::rows& rows,
.action([](const flecs::view& view,
flecs::column<Position> p,
flecs::column<Velocity> v)
{
for (auto row : rows) {
for (auto row : view) {
p[row].x += v[row].x;
p[row].y += v[row].y;

std::cout << "Moved " << rows.entity(row).name() << " to {" <<
std::cout << "Moved " << view.entity(row).name() << " to {" <<
p[row].x << ", " << p[row].y << "}" << std::endl;
}
});
Expand Down
6 changes: 3 additions & 3 deletions examples/c/02_simple_system/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ typedef struct Message {
} Message;

/* Must have the same name as the ECS_SYSTEM definition */
void PrintMessage(ecs_rows_t *rows) {
void PrintMessage(ecs_view_t *view) {
/* Get a pointer to the array of the first column in the system. The order
* of columns is the same as the one provided in the system signature. */
ECS_COLUMN(rows, Message, msg, 1);
ECS_COLUMN(view, Message, msg, 1);

/* Iterate all the messages */
for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
printf("%s\n", msg[i].text);
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/c/03_move_system/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ typedef Vector2D Position;
typedef Vector2D Velocity;

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
void Move(ecs_view_t *view) {
/* Get the two columns from the system signature */
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Velocity, v, 2);
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Velocity, v, 2);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x += v[i].x;
p[i].y += v[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/c/04_simple_module/src/simple_module.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include <simple_module.h>

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Velocity, v, 2);
void Move(ecs_view_t *view) {
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Velocity, v, 2);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x += v[i].x;
p[i].y += v[i].y;

printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/c/05_add_remove_system/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ typedef struct Position {
} Position;

/* This system will be called when Position is added */
void AddPosition(ecs_rows_t *rows) {
ECS_COLUMN(rows, Position, p, 1);
void AddPosition(ecs_view_t *view) {
ECS_COLUMN(view, Position, p, 1);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x = 10;
p[i].y = 20;
printf("Position added\n");
}
}

/* This system will be called when Position is removed */
void RemovePosition(ecs_rows_t *rows) {
ECS_COLUMN(rows, Position, p, 1);
void RemovePosition(ecs_view_t *view) {
ECS_COLUMN(view, Position, p, 1);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
printf("Position removed -> {%f, %f}\n",
p[i].x, p[i].y);
}
Expand Down
12 changes: 6 additions & 6 deletions examples/c/06_set_system/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ typedef struct Position {
} Position;

/* This system will be called when Position is added */
void AddPosition(ecs_rows_t *rows) {
ECS_COLUMN(rows, Position, p, 1);
void AddPosition(ecs_view_t *view) {
ECS_COLUMN(view, Position, p, 1);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x = 10;
p[i].y = 20;
printf("Position added\n");
}
}

/* This system will be called when Position is set */
void SetPosition(ecs_rows_t *rows) {
ECS_COLUMN(rows, Position, p, 1);
void SetPosition(ecs_view_t *view) {
ECS_COLUMN(view, Position, p, 1);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
printf("Position set -> {%f, %f}\n",
p[i].x, p[i].y);
}
Expand Down
10 changes: 5 additions & 5 deletions examples/c/07_no_macros/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ typedef Vector2D Position;
typedef Vector2D Velocity;

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
void Move(ecs_view_t *view) {
/* Get the two columns from the system signature */
Position *p = _ecs_column(rows, sizeof(Position), 1);
Velocity *v = _ecs_column(rows, sizeof(Velocity), 2);
Position *p = _ecs_column(view, sizeof(Position), 1);
Velocity *v = _ecs_column(view, sizeof(Velocity), 2);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x += v[i].x;
p[i].y += v[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand Down
26 changes: 13 additions & 13 deletions examples/c/08_hierarchy/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ typedef Vector2D WorldPosition;
typedef Vector2D Velocity;

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
void Move(ecs_view_t *view) {
/* Get the two columns from the system signature */
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Velocity, v, 2);
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Velocity, v, 2);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x += v[i].x;
p[i].y += v[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand All @@ -33,32 +33,32 @@ void Move(ecs_rows_t *rows) {
* will be used to then transform Position to WorldPosition of the child.
* If the CASCADE column is not set, the system matched a root. In that case,
* just assign the Position to the WorldPosition. */
void Transform(ecs_rows_t *rows) {
void Transform(ecs_view_t *view) {
/* Get the two columns from the system signature */
WorldPosition *parent_wp = ecs_column(rows, WorldPosition, 1);
WorldPosition *wp = ecs_column(rows, WorldPosition, 2);
Position *p = ecs_column(rows, Position, 3);
WorldPosition *parent_wp = ecs_column(view, WorldPosition, 1);
WorldPosition *wp = ecs_column(view, WorldPosition, 2);
Position *p = ecs_column(view, Position, 3);

if (!parent_wp) {
for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
wp[i].x = p[i].x;
wp[i].y = p[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s transformed to {.x = %f, .y = %f} <<root>>\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
wp[i].x, wp[i].y);
}
} else {
for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
wp[i].x = parent_wp->x + p[i].x;
wp[i].y = parent_wp->y + p[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s transformed to {.x = %f, .y = %f} <<child>>\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
wp[i].x, wp[i].y);
}
}
Expand Down
26 changes: 13 additions & 13 deletions examples/c/09_hierarchy_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ typedef Vector2D WorldPosition;
typedef Vector2D Velocity;

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
void Move(ecs_view_t *view) {
/* Get the two columns from the system signature */
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Velocity, v, 2);
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Velocity, v, 2);

for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
p[i].x += v[i].x;
p[i].y += v[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand All @@ -33,32 +33,32 @@ void Move(ecs_rows_t *rows) {
* will be used to then transform Position to WorldPosition of the child.
* If the CASCADE column is not set, the system matched a root. In that case,
* just assign the Position to the WorldPosition. */
void Transform(ecs_rows_t *rows) {
void Transform(ecs_view_t *view) {
/* Get the two columns from the system signature */
WorldPosition *parent_wp = ecs_column(rows, WorldPosition, 1);
WorldPosition *wp = ecs_column(rows, WorldPosition, 2);
Position *p = ecs_column(rows, Position, 3);
WorldPosition *parent_wp = ecs_column(view, WorldPosition, 1);
WorldPosition *wp = ecs_column(view, WorldPosition, 2);
Position *p = ecs_column(view, Position, 3);

if (!parent_wp) {
for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
wp[i].x = p[i].x;
wp[i].y = p[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s transformed to {.x = %f, .y = %f} <<root>>\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
wp[i].x, wp[i].y);
}
} else {
for (int i = 0; i < rows->count; i ++) {
for (int i = 0; i < view->count; i ++) {
wp[i].x = parent_wp->x + p[i].x;
wp[i].y = parent_wp->y + p[i].y;

/* Print something to the console so we can see the system is being
* invoked */
printf("%s transformed to {.x = %f, .y = %f} <<child>>\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
wp[i].x, wp[i].y);
}
}
Expand Down
14 changes: 7 additions & 7 deletions examples/c/10_inheritance/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ typedef Vector2D Force;
typedef float Mass;

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
void Move(ecs_view_t *view) {
/* Get the two columns from the system signature */
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Force, v, 2);
ECS_COLUMN(rows, Mass, m, 3);
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Force, v, 2);
ECS_COLUMN(view, Mass, m, 3);

for (int i = 0; i < rows->count; i ++) {
if (ecs_is_shared(rows, 3)) {
for (int i = 0; i < view->count; i ++) {
if (ecs_is_shared(view, 3)) {
p[i].x += v[i].x / m[0];
p[i].y += v[i].y / m[0];
} else {
Expand All @@ -29,7 +29,7 @@ void Move(ecs_rows_t *rows) {
/* Print something to the console so we can see the system is being
* invoked */
printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand Down
14 changes: 7 additions & 7 deletions examples/c/11_inheritance_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ typedef Vector2D Force;
typedef float Mass;

/* Implement a simple move system */
void Move(ecs_rows_t *rows) {
void Move(ecs_view_t *view) {
/* Get the two columns from the system signature */
ECS_COLUMN(rows, Position, p, 1);
ECS_COLUMN(rows, Force, v, 2);
ECS_COLUMN(rows, Mass, m, 3);
ECS_COLUMN(view, Position, p, 1);
ECS_COLUMN(view, Force, v, 2);
ECS_COLUMN(view, Mass, m, 3);

for (int i = 0; i < rows->count; i ++) {
if (ecs_is_shared(rows, 3)) {
for (int i = 0; i < view->count; i ++) {
if (ecs_is_shared(view, 3)) {
p[i].x += v[i].x / m[0];
p[i].y += v[i].y / m[0];
} else {
Expand All @@ -29,7 +29,7 @@ void Move(ecs_rows_t *rows) {
/* Print something to the console so we can see the system is being
* invoked */
printf("%s moved to {.x = %f, .y = %f}\n",
ecs_get_name(rows->world, rows->entities[i]),
ecs_get_name(view->world, view->entities[i]),
p[i].x, p[i].y);
}
}
Expand Down
Loading

0 comments on commit bc885a5

Please sign in to comment.