From 60263cf95d35c8c086afd09db297a706b933054b Mon Sep 17 00:00:00 2001 From: Rodrigo Delduca Date: Sun, 22 Dec 2024 15:58:47 -0300 Subject: [PATCH] Work in progress --- CMakeLists.txt | 44 +++++++++++++++++++++++++++++-------------- Makefile | 2 +- src/entitymanager.cpp | 4 +++- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0d9691..5cf5a32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,25 +45,41 @@ elseif (CMAKE_BUILD_TYPE MATCHES "Release") if (MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /O2 /GL) else() - target_compile_options(${PROJECT_NAME} PRIVATE -O3 -flto) + target_compile_options(${PROJECT_NAME} PRIVATE -O2 -flto) endif() endif() -if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") +if (${CMAKE_SYSTEM_NAME} MATCHES Emscripten) set(EMSCRIPTEN_OPTIONS - "-s EVAL_CTORS=1" - "-s WASM_BIGINT=1" - "-s ALLOW_MEMORY_GROWTH=1" - "-s INITIAL_MEMORY=128MB" - "-l websocket.js" - "-s USE_SDL=2" - "-s WEBSOCKET_SUBPROTOCOL=text" - "-s EXPORTED_RUNTIME_METHODS=['callMain']" - # Debug - "-s ASSERTIONS=1" - "-s NO_DISABLE_EXCEPTION_CATCHING" + -sEVAL_CTORS=1 + -sWASM_BIGINT=1 + -sALLOW_MEMORY_GROWTH=1 + -sINITIAL_MEMORY=128MB + -lwebsocket.js + -sUSE_SDL=2 + -sWEBSOCKET_SUBPROTOCOL=text + -sEXPORTED_RUNTIME_METHODS=['callMain'] ) - target_link_libraries(${PROJECT_NAME} PRIVATE ${EMSCRIPTEN_OPTIONS}) + + if (ENABLE_PROFILING) + list(APPEND EMSCRIPTEN_OPTIONS + -O0 + -g + -gsource-map + -sDEMANGLE_SUPPORT=1 + -sASSERTIONS=1 + -sNO_DISABLE_EXCEPTION_CATCHING + --profiling-funcs + -sSAFE_HEAP=0 + -sSTACK_OVERFLOW_CHECK=2 + ) + else() + list(APPEND EMSCRIPTEN_OPTIONS + -O2 + ) + endif() + + target_link_options(${PROJECT_NAME} PRIVATE ${EMSCRIPTEN_OPTIONS}) endif() option(LOCAL "Use local environment" OFF) diff --git a/Makefile b/Makefile index 452e68c..7060ffe 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,4 @@ build: ## Build configure: clean ## Configure conan remote update conancenter --url https://center2.conan.io conan install . --output-folder=build --build=missing --profile=webassembly --settings compiler.cppstd=20 --settings build_type=Release - cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DSDL2_DIR=generators -DCMAKE_BUILD_TYPE=Release -DLOCAL=ON -DSANDBOX=OFF + cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DSDL2_DIR=generators -DCMAKE_BUILD_TYPE=Release -DLOCAL=ON -DSANDBOX=OFF -DENABLE_PROFILING=OFF diff --git a/src/entitymanager.cpp b/src/entitymanager.cpp index 3b33fd8..74a6444 100644 --- a/src/entitymanager.cpp +++ b/src/entitymanager.cpp @@ -1,5 +1,6 @@ #include "entitymanager.hpp" #include "common.hpp" +#include using namespace framework; @@ -86,8 +87,9 @@ void entitymanager::update(float_t delta) noexcept { } for (const auto &entity1 : _entities) { - if (entity1->_collisionmapping.empty()) [[unlikely]] + if (entity1->_collisionmapping.empty()) [[likely]] { continue; + } const auto &pos1 = entity1->position(); const auto &size1 = entity1->size().resized();