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)
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)
-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) $^
--- /dev/null
+#include "app/Assets.hpp"
+#include "shared/WorldResources.hpp"
+#include "world/Chunk.hpp"
+#include "world/Generator.hpp"
+
+#include <chrono>
+#include <iostream>
+#include <glm/gtx/io.hpp>
+
+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<milliseconds>(exit - enter).count() << "ms ("
+ << (duration_cast<nanoseconds>(exit - enter).count() / total_chunks / 1.0e6f) << "ms chunk avg)" << endl;
+ return 0;
+}