Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cgmb committed Aug 29, 2017
1 parent 73de42e commit 81de9fa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ struct sparse_entry_t {
} g_a[Y][X];

// marker particle data
const size_t N = 4*Y*X;
const size_t k_max_marker_count = 4*Y*X;
size_t g_markers_length;
bool g_source_exhausted;
vec2f g_markers[N];
vec2f g_markers[k_max_marker_count];
uint8_t g_marker_count[Y][X];
uint8_t g_old_marker_count[Y][X];

Expand Down Expand Up @@ -301,15 +301,14 @@ void sim_init(args_t in) {
if (g_rainbow_enabled) {
colorize();
}

}

void update_fluid_sources() {
// If we ever hit the max number of markers, that's it.
// The current extrapolation implementation assumes that the fluid is never
// more than one cell from a cell where fluid was in the previous step. If
// we stop and then later restart generating fluid, that may not hold true.
g_source_exhausted |= (g_markers_length == N-1);
g_source_exhausted |= (g_markers_length == k_max_marker_count-1);

float t = 0.6f / k_source_color_period * g_frame_count;
for (size_t y = 0; y < Y; ++y) {
Expand All @@ -318,7 +317,7 @@ void update_fluid_sources() {
if (!g_source_exhausted && g_marker_count[y][x] < 4) {
g_markers[g_markers_length++] = k_s*vec2f{x+g_rng(), y+g_rng()};
g_marker_count[y][x]++;
g_source_exhausted |= (g_markers_length == N-1);
g_source_exhausted |= (g_markers_length == k_max_marker_count-1);
}
g_r[y][x] = hsv_basis(t + 2.f);
g_g[y][x] = hsv_basis(t);
Expand Down

0 comments on commit 81de9fa

Please sign in to comment.