summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common.hpp3
-rw-r--r--src/game/game.cpp6
-rw-r--r--src/game/game.hpp3
-rw-r--r--src/game/interface.cpp2
-rw-r--r--src/game/pseudostate.cpp2
-rw-r--r--src/render.cpp13
6 files changed, 12 insertions, 17 deletions
diff --git a/src/common.hpp b/src/common.hpp
index d3ec041..7e449a2 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -317,6 +317,7 @@ namespace render {
void register_tile(uint8_t type, const char *top, const char *side, float height, layer_t layer);
bool rendering_order(const world::entity_t *x, const world::entity_t *y);
bool visibility_order(const world::entity_t *x, const world::entity_t *y);
+ rectf_t window_bounds(sf::RenderWindow *window);
class state_t {
sf::RenderWindow *window;
@@ -349,8 +350,6 @@ namespace render {
void render_ring_sect(v2f_t x, float r0, float r1, float t0, float t1, sf::Color color);
void debug_path(v2f_t x, std::list<v2f_t> *path);
-
- rectf_t window_in_world_space(void);
};
}
diff --git a/src/game/game.cpp b/src/game/game.cpp
index b10bc08..3adfd85 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -528,15 +528,13 @@ void state_t::tick(ntime_t time_)
#define XRES 9
#define YRES 9
-void state_t::compute_ambience(render::state_t *render)
+void state_t::compute_ambience(void)
{
const size_t samples = XRES * YRES;
- rectf_t area;
+ rectf_t area = interface.world_view;
v2f_t origins[AMBIENT_COUNT];
size_t hits[AMBIENT_COUNT];
- area = render->window_in_world_space();
-
for (size_t i = 0; i < AMBIENT_COUNT; i++) {
origins[i] = v2f_t(0, 0);
hits[i] = 0;
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 4066b02..c378524 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -94,6 +94,7 @@ namespace interface {
void stop_following(void);
public:
+ rectf_t world_view;
v3f_t camera_3d; // for audio
void tick(double dt);
@@ -134,7 +135,7 @@ namespace game {
void start(void);
void stop(void);
void tick(ntime_t time);
- void compute_ambience(render::state_t *render);
+ void compute_ambience(void);
void pause(void);
void resume(void);
diff --git a/src/game/interface.cpp b/src/game/interface.cpp
index f6106e2..10ab751 100644
--- a/src/game/interface.cpp
+++ b/src/game/interface.cpp
@@ -285,6 +285,8 @@ void state_t::tick(double dt)
if (pie_menu.is_open)
pie_menu.update(mouse);
+
+ world_view = render::window_bounds(window);
}
void state_t::print(std::string str)
diff --git a/src/game/pseudostate.cpp b/src/game/pseudostate.cpp
index 0f2d0c5..5b64b9e 100644
--- a/src/game/pseudostate.cpp
+++ b/src/game/pseudostate.cpp
@@ -57,7 +57,7 @@ void pseudostate_t::render_interface_to(render::state_t *render)
{
pimpl->interface.render_to(render);
- pimpl->compute_ambience(render);
+ pimpl->compute_ambience();
audio::update(pimpl->interface.camera_3d, pimpl->paused);
}
diff --git a/src/render.cpp b/src/render.cpp
index bcd28e1..57c1185 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -180,7 +180,7 @@ void state_t::render_tile(world::world_t *world, v2f_t tx, world::tile_t *tile)
stats.tiles++;
}
-static rectf_t window_bounds(sf::RenderWindow *window)
+rectf_t window_bounds(sf::RenderWindow *window)
{
const v2f_t margin(1.5f, 1.5f);
@@ -197,18 +197,10 @@ static rectf_t window_bounds(sf::RenderWindow *window)
bounds[0][1] = std::min({A[1], B[1], C[1], D[1]});
bounds[1][0] = std::max({A[0], B[0], C[0], D[0]});
bounds[1][1] = std::max({A[1], B[1], C[1], D[1]});
- bounds[0] -= margin;
- bounds[1] += margin;
return bounds;
}
-// NOTE: this includes the margin
-rectf_t state_t::window_in_world_space(void)
-{
- return window_bounds(window);
-}
-
bool rendering_order(const world::entity_t *x, const world::entity_t *y)
{
return x->render_bounds[1][1] < y->render_bounds[1][1];
@@ -269,11 +261,14 @@ void state_t::render_layer(world::world_t *world, rect_t<world::coord_t, 2> &sec
void state_t::render(world::world_t *world)
{
+ const v2f_t margin = {1.5f, 1.5f};
rectf_t bounds;
std::list<world::entity_t*> ents;
rect_t<world::coord_t, 2> sectors;
bounds = window_bounds(window);
+ bounds[0] -= margin;
+ bounds[1] += margin;
sectors[0] = world::sector_index_at(bounds[0]);
sectors[1] = world::sector_index_at(bounds[1]);