perf improvements in systems

isolation_bkp/dynres
Dominik Madarász 2022-09-13 16:24:43 +00:00 committed by GitHub
parent b4c62e0827
commit b4d09018ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 61 deletions

View File

@ -15,8 +15,8 @@ if(MSVC)
endif() endif()
if (EMSCRIPTEN) if (EMSCRIPTEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g -s USE_GLFW=3 --profiling -s ASSERTIONS=1 -s WASM=1 -s INITIAL_MEMORY=268435456 -s FORCE_FILESYSTEM=1 --preload-file ${CMAKE_SOURCE_DIR}/art@art/ --shell-file ${CMAKE_SOURCE_DIR}/web/eco2d.html") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 --profiling -s ASSERTIONS=1 -s WASM=1 -s INITIAL_MEMORY=268435456 -s FORCE_FILESYSTEM=1 --preload-file ${CMAKE_SOURCE_DIR}/art@art/ --shell-file ${CMAKE_SOURCE_DIR}/web/eco2d.html")
set(CMAKE_EXECUTABLE_SUFFIX ".html") # This line is used to set your executable to build with the emscripten html template so that you can directly open it. set(CMAKE_EXECUTABLE_SUFFIX ".html") # This line is used to set your executable to build with the emscripten html template so that you can directly open it.
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF) set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
endif () endif ()

View File

@ -29,7 +29,7 @@ typedef struct {
#define DBG_FONT_SIZE 22 #define DBG_FONT_SIZE 22
#define DBG_FONT_SPACING DBG_FONT_SIZE * 1.2f #define DBG_FONT_SPACING DBG_FONT_SIZE * 1.2f
#define DBG_START_XPOS 15 #define DBG_START_XPOS 15
#define DBG_START_YPOS 200 #define DBG_START_YPOS 30
#define DBG_LIST_XPOS_OFFSET 10 #define DBG_LIST_XPOS_OFFSET 10
#define DBG_SHADOW_OFFSET_XPOS 1 #define DBG_SHADOW_OFFSET_XPOS 1
#define DBG_SHADOW_OFFSET_YPOS 1 #define DBG_SHADOW_OFFSET_YPOS 1

View File

@ -100,7 +100,7 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
float x = data->x; float x = data->x;
float y = data->y; float y = data->y;
const char *title = TextFormat("Bot %d", key); const char *title = TextFormat("Bot %d", key);
int title_w = MeasureTextEco(title, font_size, font_spacing); float title_w = MeasureTextEco(title, font_size, font_spacing);
DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(GRAY, data->tran_time)); DrawRectangleEco(x-title_w/2.f-title_bg_offset/2.f, y-size-font_size-fixed_title_offset, title_w+title_bg_offset, font_size, ColorAlpha(GRAY, data->tran_time));
DrawTextEco(title, x-title_w/2.f, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing); DrawTextEco(title, x-title_w/2.f, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(BLACK, data->tran_time), font_spacing);
DrawCircleEco(x, y, size, ColorAlpha(PURPLE, data->tran_time)); DrawCircleEco(x, y, size, ColorAlpha(PURPLE, data->tran_time));

View File

@ -27,6 +27,7 @@ void IntegratePositions(ecs_iter_t *it) {
Velocity *v = ecs_field(it, Velocity, 2); Velocity *v = ecs_field(it, Velocity, 2);
for (int i = 0; i < it->count; i++) { for (int i = 0; i < it->count; i++) {
if (zpl_abs(v[i].x) >= 0.001f || zpl_abs(v[i].y) >= 0.001f) {
// NOTE(zaklaus): world bounds // NOTE(zaklaus): world bounds
{ {
float w = (float)world_dim(); float w = (float)world_dim();
@ -58,6 +59,7 @@ void IntegratePositions(ecs_iter_t *it) {
p[i].x += v[i].x * safe_dt(it); p[i].x += v[i].x * safe_dt(it);
p[i].y += v[i].y * safe_dt(it); p[i].y += v[i].y * safe_dt(it);
}
{ {
debug_v2 a = {p[i].x, p[i].y}; debug_v2 a = {p[i].x, p[i].y};
@ -90,10 +92,10 @@ void HurtOnHazardBlock(ecs_iter_t *it) {
Health *h = ecs_field(it, Health, 2); Health *h = ecs_field(it, Health, 2);
for (int i = 0; i < it->count; i++) { for (int i = 0; i < it->count; i++) {
world_block_lookup l = world_block_from_realpos(p[i].x, p[i].y);
if (blocks_get_flags(l.bid) & BLOCK_FLAG_HAZARD) {
if (h->pain_time < 0.0f) { if (h->pain_time < 0.0f) {
h->pain_time = HAZARD_BLOCK_TIME; h->pain_time = HAZARD_BLOCK_TIME;
world_block_lookup l = world_block_from_realpos(p[i].x, p[i].y);
if (blocks_get_flags(l.bid) & BLOCK_FLAG_HAZARD) {
h->hp -= HAZARD_BLOCK_DMG; h->hp -= HAZARD_BLOCK_DMG;
h->hp = zpl_max(0.0f, h->hp); h->hp = zpl_max(0.0f, h->hp);
} }
@ -141,6 +143,7 @@ void ApplyWorldDragOnVelocity(ecs_iter_t *it) {
Velocity *v = ecs_field(it, Velocity, 2); Velocity *v = ecs_field(it, Velocity, 2);
for (int i = 0; i < it->count; i++) { for (int i = 0; i < it->count; i++) {
if (zpl_abs(v[i].x) < 0.001f && zpl_abs(v[i].y) < 0.001f) continue;
world_block_lookup lookup = world_block_from_realpos(p[i].x, p[i].y); world_block_lookup lookup = world_block_from_realpos(p[i].x, p[i].y);
float drag = zpl_clamp(blocks_get_drag(lookup.bid), 0.0f, 1.0f); float drag = zpl_clamp(blocks_get_drag(lookup.bid), 0.0f, 1.0f);
float friction = blocks_get_friction(lookup.bid); float friction = blocks_get_friction(lookup.bid);