Skip to content

Commit

Permalink
renderer: Use correct world space transformation for terrain model.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Nov 10, 2023
1 parent 7e8c9c6 commit addd493
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions libopenage/gamestate/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,16 @@ void Game::generate_terrain(const std::shared_ptr<TerrainFactory> &terrain_facto
auto chunk1 = terrain_factory->add_chunk(this->state,
util::Vector2s{10, 10},
coord::tile_delta{10, 0});
auto chunk2 = terrain_factory->add_chunk(this->state,
util::Vector2s{10, 10},
coord::tile_delta{0, 10});
auto chunk3 = terrain_factory->add_chunk(this->state,
util::Vector2s{10, 10},
coord::tile_delta{10, 10});
terrain->add_chunk(chunk0);
terrain->add_chunk(chunk1);
terrain->add_chunk(chunk2);
terrain->add_chunk(chunk3);

this->state->set_terrain(terrain);
}
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/stages/terrain/terrain_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const std::shared_ptr<renderer::UniformInput> &TerrainRenderMesh::get_uniforms()
void TerrainRenderMesh::create_model_matrix(const coord::scene2_delta &offset) {
// TODO: Needs input from engine
auto model = Eigen::Affine3f::Identity();
model.translate(Eigen::Vector3f{offset.ne.to_float(), offset.se.to_float(), 0.0f});
model.translate(offset.to_world_space());
this->model_matrix = model.matrix();
}

Expand Down

0 comments on commit addd493

Please sign in to comment.