From: Daniel Karbach Date: Fri, 4 Dec 2015 12:12:32 +0000 (+0100) Subject: fix multiple application support in makefile X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=04bca2c5e74df466312c69abadf38e1f84aa70a9;p=blank.git fix multiple application support in makefile --- diff --git a/.gitignore b/.gitignore index 5a84607..334f308 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ build cachegrind.out.* callgrind.out.* client-saves +generate.profile saves diff --git a/Makefile b/Makefile index 4e4d994..42300ac 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,11 @@ BIN_SRC := $(wildcard $(SOURCE_DIR)/*.cpp) SRC := $(LIB_SRC) $(BIN_SRC) TEST_SRC := $(wildcard $(TEST_SRC_DIR)/*.cpp) $(wildcard $(TEST_SRC_DIR)/*/*.cpp) RELEASE_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(RELEASE_DIR)/%.o, $(SRC)) +RELEASE_LIB_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(RELEASE_DIR)/%.o, $(LIB_SRC)) DEBUG_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(DEBUG_DIR)/%.o, $(SRC)) +DEBUG_LIB_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(DEBUG_DIR)/%.o, $(LIB_SRC)) PROFILE_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(PROFILE_DIR)/%.o, $(SRC)) +PROFILE_LIB_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(PROFILE_DIR)/%.o, $(LIB_SRC)) TEST_OBJ := $(patsubst $(TEST_SRC_DIR)/%.cpp, $(TEST_DIR)/%.o, $(TEST_SRC)) $(patsubst $(SOURCE_DIR)/%.cpp, $(TEST_DIR)/src/%.o, $(LIB_SRC)) RELEASE_DEP := $(RELEASE_OBJ:.o=.d) DEBUG_DEP := $(DEBUG_OBJ:.o=.d) @@ -45,7 +48,7 @@ PROFILE_DEP := $(PROFILE_OBJ:.o=.d) TEST_DEP := $(TEST_OBJ:.o=.d) RELEASE_BIN := blank DEBUG_BIN := blank.debug -PROFILE_BIN := blank.profile +PROFILE_BIN := blank.profile generate.profile TEST_BIN := blank.test OBJ := $(RELEASE_OBJ) $(DEBUG_OBJ) $(PROFILE_OBJ) $(TEST_OBJ) DEP := $(RELEASE_DEP) $(DEBUG_DEP) $(PROFILE_DEP) $(TEST_DEP) @@ -98,15 +101,15 @@ distclean: clean -include $(DEP) -$(RELEASE_BIN): $(RELEASE_OBJ) +$(RELEASE_BIN): %: $(RELEASE_DIR)/%.o $(RELEASE_LIB_OBJ) @echo link: $@ @$(LDXX) -o $@ $(CXXFLAGS) $(LDXXFLAGS) $(RELEASE_FLAGS) $^ -$(DEBUG_BIN): $(DEBUG_OBJ) +$(DEBUG_BIN): %.debug: $(DEBUG_DIR)/%.o $(DEBUG_LIB_OBJ) @echo link: $@ @$(LDXX) -o $@ $(CXXFLAGS) $(LDXXFLAGS) $(DEBUG_FLAGS) $^ -$(PROFILE_BIN): $(PROFILE_OBJ) +$(PROFILE_BIN): %.profile: $(PROFILE_DIR)/%.o $(PROFILE_LIB_OBJ) @echo link: $@ @$(LDXX) -o $@ $(CXXFLAGS) $(LDXXFLAGS) $(PROFILE_FLAGS) $^ diff --git a/src/generate.cpp b/src/generate.cpp new file mode 100644 index 0000000..d98f059 --- /dev/null +++ b/src/generate.cpp @@ -0,0 +1,52 @@ +#include "app/Assets.hpp" +#include "shared/WorldResources.hpp" +#include "world/Chunk.hpp" +#include "world/Generator.hpp" + +#include +#include +#include + +using namespace blank; +using namespace std; +using namespace chrono; + + +int main() { + AssetLoader loader("assets/"); + WorldResources res; + res.Load(loader, "default"); + Generator::Config conf; + Generator gen(conf); + gen.LoadTypes(res.block_types); + Chunk chunk(res.block_types); + + const ExactLocation::Coarse begin(-6); + const ExactLocation::Coarse end(6); + size_t total_chunks = ((end.x - begin.x) * (end.y - begin.y) * (end.z - begin.z)); + + size_t candidates = 0; + for (const BlockType &type : res.block_types) { + if (type.generate) { + ++candidates; + } + } + + cout << "generating " << total_chunks << " chunks from " << begin << " to " << (end - 1) << endl; + cout << candidates << " of " << res.block_types.size() << " block types applicable for generation" << endl; + auto enter = high_resolution_clock::now(); + + for (int z = begin.z; z < end.z; ++z) { + for (int y = begin.y; y < end.y; ++y) { + for (int x = begin.x; x < end.x; ++x) { + chunk.Position({ x, y, z }); + gen(chunk); + } + } + } + + auto exit = high_resolution_clock::now(); + cout << duration_cast(exit - enter).count() << "ms (" + << (duration_cast(exit - enter).count() / total_chunks / 1.0e6f) << "ms chunk avg)" << endl; + return 0; +}