void mesh::add_triangle(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c) { int index_a = find_index(a); int index_b = find_index(b); int index_c = find_index(c); index_a = update_vertex(a, index_a); index_b = update_vertex(b, index_b); index_c = update_vertex(c, index_c); triangles.push_back(glm::ivec3(index_a, index_b, index_c)); glm::vec3 normal(glm::normalize(glm::cross((b - a), (c - a)))); face_normals.push_back(normal); int tri_index = static_cast<int>(triangles.size()) - 1; update_neighbors(index_a, tri_index); update_neighbors(index_b, tri_index); update_neighbors(index_c, tri_index); }
auto replan(Cells const& cells_to_toggle = {}) { reset_statistics(); for (auto c : cells_to_toggle) { at(c).bad = !at(c).bad; if (!at(c).bad) update_vertex(at(c)); else at(c).g = at(c).r = huge(); update_neighbours_of(c); } compute_shortest_path(); }
auto compute_shortest_path() { Timing t{ run_time }; while (!q.empty() && (Key{ at(q.top()) } < Key{ at(goal) } || at(goal).r != at(goal).g)) { auto c = q.pop(); if (at(c).g > at(c).r) at(c).g = at(c).r; else at(c).g = huge(), update_vertex(at(c)); update_neighbours_of(c); { max_q_size = max(max_q_size, q.size()); expansions.insert(c); } } path = build_path(); }
void Ball::move(){ location.x += velocity.x; location.y += velocity.y; update_vertex(); }
void Ball::change_location(glm::vec2 new_loc){ location = new_loc; update_vertex(); }
auto update_neighbours_of(Cell cell) { for (auto neighbour : valid_neighbours_of(cell)) if (!at(neighbour).bad) update_vertex(at(neighbour)); }