Browse Source

some small stuff

feature/replace-renderer
Martin Dørum 3 years ago
parent
commit
b7347d749d
3 changed files with 8 additions and 15 deletions
  1. 5
    5
      libswan/include/swan/Game.h
  2. 0
    9
      libswan/src/LightServer.cc
  3. 3
    1
      src/main.cc

+ 5
- 5
libswan/include/swan/Game.h View File

@@ -28,17 +28,17 @@ public:
}

void onMouseMove(Sint32 x, Sint32 y) {
mousePos_ = { x, y };
mousePos_ = {x, y};
}

void onMouseDown(Sint32 x, Sint32 y, Uint8 button) {
mousePos_ = { x, y };
mousePos_ = {x, y};
pressedButtons_[button] = true;
didPressButtons_[button] = true;
}

}
void onMouseUp(Sint32 x, Sint32 y, Uint8 button) {
mousePos_ = { x, y };
mousePos_ = {x, y};
pressedButtons_[button] = false;
didReleaseButtons_[button] = true;
}
@@ -65,7 +65,7 @@ public:

std::unique_ptr<World> world_ = NULL;
Cygnet::Renderer renderer_;
Cygnet::RenderCamera cam_;
Cygnet::RenderCamera cam_{ .zoom = 0.25 };

private:
std::bitset<SDL_NUM_SCANCODES> pressedKeys_;

+ 0
- 9
libswan/src/LightServer.cc View File

@@ -161,13 +161,11 @@ void LightServer::processEvent(const Event &evt, std::vector<NewLightChunk> &new
break;

case Event::Tag::LIGHT_ADDED:
info << cpos << ": Add " << evt.f << " light to " << rpos;
ch->lightSources[rpos] += evt.f;
markChunksModified(cpos, rpos, ch->lightSources[rpos]);
break;

case Event::Tag::LIGHT_REMOVED:
info << cpos << ": Remove " << evt.f << " light to " << rpos;
markChunksModified(cpos, rpos, ch->lightSources[rpos]);
ch->lightSources[rpos] -= evt.f;
if (ch->lightSources[rpos] < LIGHT_CUTOFF) {
@@ -534,8 +532,6 @@ void LightServer::run() {
buf.clear();
newChunks.clear();

auto start = std::chrono::steady_clock::now();

for (auto &pos: updatedChunks_) {
auto ch = chunks_.find(pos);
if (ch != chunks_.end()) {
@@ -574,11 +570,6 @@ void LightServer::run() {
}
}

auto end = std::chrono::steady_clock::now();
auto dur = std::chrono::duration<double, std::milli>(end - start);
info << "Generating light for " << updatedChunks_.size()
<< " chunks took " << dur.count() << "ms";

for (auto &pos: updatedChunks_) {
auto ch = chunks_.find(pos);
if (ch != chunks_.end()) {

+ 3
- 1
src/main.cc View File

@@ -104,6 +104,7 @@ int main(int argc, char **argv) {

// Create a world
Game game;
game.cam_.size = window.size();
std::vector<std::string> mods{ "core.mod" };
game.createWorld("core::default", mods);

@@ -171,6 +172,8 @@ int main(int argc, char **argv) {
}
}

game.cam_.size = window.size();

auto now = std::chrono::steady_clock::now();
std::chrono::duration<float> dur(now - prevTime);
prevTime = now;
@@ -239,7 +242,6 @@ int main(int argc, char **argv) {

{
ZoneScopedN("game draw");
game.cam_.size = window.size();
game.draw();
}


Loading…
Cancel
Save