update color scheme
This commit is contained in:
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
|
|
||||||
// TODO: Using the octree from the last frame completely breaks the physics :/
|
// TODO: Using the octree from the last frame completely breaks the physics :/
|
||||||
// #define ASYNC_OCTREE
|
// #define ASYNC_OCTREE
|
||||||
|
|
||||||
@ -46,12 +45,14 @@ constexpr int FONT_SIZE = 26;
|
|||||||
// Camera Controls
|
// Camera Controls
|
||||||
constexpr float CAMERA_FOV = 90.0;
|
constexpr float CAMERA_FOV = 90.0;
|
||||||
constexpr float FOV_SPEED = 1.0;
|
constexpr float FOV_SPEED = 1.0;
|
||||||
|
constexpr float FOV_MULTIPLIER = 4.0;
|
||||||
constexpr float MIN_FOV = 10.0;
|
constexpr float MIN_FOV = 10.0;
|
||||||
constexpr float MAX_FOV = 180.0;
|
constexpr float MAX_PERSP_FOV = 120.0;
|
||||||
|
constexpr float MAX_ORTHO_FOV = 540.0;
|
||||||
constexpr float CAMERA_DISTANCE = 150.0;
|
constexpr float CAMERA_DISTANCE = 150.0;
|
||||||
constexpr float ZOOM_SPEED = 2.5;
|
|
||||||
constexpr float MIN_CAMERA_DISTANCE = 2.0;
|
constexpr float MIN_CAMERA_DISTANCE = 2.0;
|
||||||
constexpr float MAX_CAMERA_DISTANCE = 2000.0;
|
constexpr float MAX_CAMERA_DISTANCE = 2000.0;
|
||||||
|
constexpr float ZOOM_SPEED = 2.5;
|
||||||
constexpr float ZOOM_MULTIPLIER = 4.0;
|
constexpr float ZOOM_MULTIPLIER = 4.0;
|
||||||
constexpr float PAN_SPEED = 2.0;
|
constexpr float PAN_SPEED = 2.0;
|
||||||
constexpr float PAN_MULTIPLIER = 10.0;
|
constexpr float PAN_MULTIPLIER = 10.0;
|
||||||
@ -63,26 +64,26 @@ constexpr float TARGET_UPS = 90; // How often to update physics
|
|||||||
constexpr float TIMESTEP = 1.0 / TARGET_UPS; // Update interval in seconds
|
constexpr float TIMESTEP = 1.0 / TARGET_UPS; // Update interval in seconds
|
||||||
constexpr float SIM_SPEED = 4.0; // How large each update should be
|
constexpr float SIM_SPEED = 4.0; // How large each update should be
|
||||||
constexpr float MASS = 1.0; // Mass spring system
|
constexpr float MASS = 1.0; // Mass spring system
|
||||||
constexpr float SPRING_CONSTANT = 5.0; // Mass spring system
|
constexpr float SPRING_K = 4.0; // Mass spring system
|
||||||
constexpr float DAMPENING_CONSTANT = 1.0; // Mass spring system
|
constexpr float DAMPENING_K = 1.0; // Mass spring system
|
||||||
constexpr float REST_LENGTH = 3.0; // Mass spring system
|
constexpr float REST_LENGTH = 3.0; // Mass spring system
|
||||||
constexpr float VERLET_DAMPENING = 0.05; // [0, 1]
|
constexpr float VERLET_DAMPENING = 0.1; // [0, 1]
|
||||||
constexpr float BH_FORCE = 2.5; // Barnes-Hut [1.0, 3.0]
|
constexpr float BH_FORCE = 2.5; // Barnes-Hut [1.0, 3.0]
|
||||||
constexpr float THETA = 0.8; // Barnes-Hut [0.5, 1.0]
|
constexpr float THETA = 0.8; // Barnes-Hut [0.5, 1.0]
|
||||||
constexpr float SOFTENING = 0.01; // Barnes-Hut [0.01, 1.0]
|
constexpr float SOFTENING = 0.05; // Barnes-Hut [0.01, 1.0]
|
||||||
|
|
||||||
// Graph Drawing
|
// Graph Drawing
|
||||||
static const Color EDGE_COLOR = Fade(PURPLE, 0.75);
|
static const Color EDGE_COLOR = Fade(BLUE, 0.3);
|
||||||
constexpr float VERTEX_SIZE = 0.75;
|
constexpr float VERTEX_SIZE = 0.75;
|
||||||
static const Color VERTEX_COLOR = Fade(BLUE, 0.5);
|
|
||||||
constexpr Color VERTEX_VISITED_COLOR = DARKPURPLE;
|
|
||||||
constexpr Color VERTEX_PATH_COLOR = GREEN;
|
|
||||||
constexpr Color VERTEX_TARGET_COLOR = RED;
|
|
||||||
constexpr Color VERTEX_START_COLOR = ORANGE;
|
|
||||||
constexpr Color VERTEX_CURRENT_COLOR = DARKBLUE;
|
|
||||||
static const Color VERTEX_CLOSEST_COLOR = Fade(PINK, 0.85);
|
|
||||||
static const Color VERTEX_FARTHEST_COLOR = Fade(BLUE, 0.5);
|
|
||||||
constexpr int DRAW_VERTICES_LIMIT = 1000000;
|
constexpr int DRAW_VERTICES_LIMIT = 1000000;
|
||||||
|
static const Color VERTEX_COLOR = Fade(BLUE, 0.8);
|
||||||
|
constexpr Color VERTEX_VISITED_COLOR = ORANGE;
|
||||||
|
constexpr Color VERTEX_START_COLOR = ORANGE;
|
||||||
|
constexpr Color VERTEX_CURRENT_COLOR = ORANGE;
|
||||||
|
constexpr Color VERTEX_PATH_COLOR = GREEN;
|
||||||
|
constexpr Color VERTEX_TARGET_COLOR = GREEN;
|
||||||
|
static const Color VERTEX_CLOSEST_COLOR = Fade(PINK, 1.0);
|
||||||
|
static const Color VERTEX_FARTHEST_COLOR = Fade(DARKBLUE, 0.8);
|
||||||
|
|
||||||
// Klotski Drawing
|
// Klotski Drawing
|
||||||
constexpr int BOARD_PADDING = 10;
|
constexpr int BOARD_PADDING = 10;
|
||||||
@ -97,5 +98,4 @@ constexpr Color WALL_COLOR = BLACK;
|
|||||||
static constexpr int SMALL_TASK_BLOCK_SIZE = 256; // Weirdly larger blocks decrease performance...
|
static constexpr int SMALL_TASK_BLOCK_SIZE = 256; // Weirdly larger blocks decrease performance...
|
||||||
static constexpr int LARGE_TASK_BLOCK_SIZE = 256;
|
static constexpr int LARGE_TASK_BLOCK_SIZE = 256;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -75,6 +75,7 @@ public:
|
|||||||
bool mark_path = false;
|
bool mark_path = false;
|
||||||
bool mark_solutions = false;
|
bool mark_solutions = false;
|
||||||
bool connect_solutions = false;
|
bool connect_solutions = false;
|
||||||
|
bool color_by_distance = false;
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
bool camera_lock = true;
|
bool camera_lock = true;
|
||||||
@ -139,6 +140,7 @@ public:
|
|||||||
auto clear_graph() -> void;
|
auto clear_graph() -> void;
|
||||||
auto toggle_mark_solutions() -> void;
|
auto toggle_mark_solutions() -> void;
|
||||||
auto toggle_connect_solutions() -> void;
|
auto toggle_connect_solutions() -> void;
|
||||||
|
auto toggle_color_by_distance() -> void;
|
||||||
auto toggle_mark_path() -> void;
|
auto toggle_mark_path() -> void;
|
||||||
auto goto_optimal_next_state() const -> void;
|
auto goto_optimal_next_state() const -> void;
|
||||||
auto goto_most_distant_state() const -> void;
|
auto goto_most_distant_state() const -> void;
|
||||||
|
|||||||
@ -87,8 +87,8 @@ auto cpu_spring_system::calculate_spring_force(const size_t s) -> void
|
|||||||
const float inv_len = 1.0f / sqrt(sq_len);
|
const float inv_len = 1.0f / sqrt(sq_len);
|
||||||
const float len = sq_len * inv_len;
|
const float len = sq_len * inv_len;
|
||||||
|
|
||||||
const float hooke = SPRING_CONSTANT * (len - REST_LENGTH);
|
const float hooke = SPRING_K * (len - REST_LENGTH);
|
||||||
const float dampening = DAMPENING_CONSTANT * Vector3DotProduct(delta_vel, delta_pos) * inv_len;
|
const float dampening = DAMPENING_K * Vector3DotProduct(delta_vel, delta_pos) * inv_len;
|
||||||
|
|
||||||
const Vector3 a_force = Vector3Scale(delta_pos, -(hooke + dampening) * inv_len);
|
const Vector3 a_force = Vector3Scale(delta_pos, -(hooke + dampening) * inv_len);
|
||||||
const Vector3 b_force = a_force * -1.0f;
|
const Vector3 b_force = a_force * -1.0f;
|
||||||
|
|||||||
@ -42,6 +42,7 @@ auto input_handler::init_handlers() -> void
|
|||||||
register_key_pressed_handler(KEY_C, &input_handler::clear_graph);
|
register_key_pressed_handler(KEY_C, &input_handler::clear_graph);
|
||||||
register_key_pressed_handler(KEY_I, &input_handler::toggle_mark_solutions);
|
register_key_pressed_handler(KEY_I, &input_handler::toggle_mark_solutions);
|
||||||
register_key_pressed_handler(KEY_O, &input_handler::toggle_connect_solutions);
|
register_key_pressed_handler(KEY_O, &input_handler::toggle_connect_solutions);
|
||||||
|
register_key_pressed_handler(KEY_Z, &input_handler::toggle_color_by_distance);
|
||||||
|
|
||||||
register_key_pressed_handler(KEY_TAB, &input_handler::toggle_editing);
|
register_key_pressed_handler(KEY_TAB, &input_handler::toggle_editing);
|
||||||
register_key_pressed_handler(KEY_F, &input_handler::toggle_restricted_movement);
|
register_key_pressed_handler(KEY_F, &input_handler::toggle_restricted_movement);
|
||||||
@ -142,12 +143,17 @@ auto input_handler::camera_zoom() const -> void
|
|||||||
|
|
||||||
auto input_handler::camera_fov() const -> void
|
auto input_handler::camera_fov() const -> void
|
||||||
{
|
{
|
||||||
if (!mouse_in_graph_pane() || !IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_LEFT_SHIFT)) {
|
if (!mouse_in_graph_pane() || !IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float wheel = GetMouseWheelMove();
|
const float wheel = GetMouseWheelMove();
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
||||||
|
camera.fov -= wheel * FOV_SPEED * FOV_MULTIPLIER;
|
||||||
|
} else {
|
||||||
camera.fov -= wheel * FOV_SPEED;
|
camera.fov -= wheel * FOV_SPEED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_handler::select_block() -> void
|
auto input_handler::select_block() -> void
|
||||||
@ -407,6 +413,11 @@ auto input_handler::toggle_connect_solutions() -> void
|
|||||||
connect_solutions = !connect_solutions;
|
connect_solutions = !connect_solutions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto input_handler::toggle_color_by_distance() -> void
|
||||||
|
{
|
||||||
|
color_by_distance = !color_by_distance;
|
||||||
|
}
|
||||||
|
|
||||||
auto input_handler::toggle_mark_path() -> void
|
auto input_handler::toggle_mark_path() -> void
|
||||||
{
|
{
|
||||||
mark_path = !mark_path;
|
mark_path = !mark_path;
|
||||||
|
|||||||
@ -63,7 +63,11 @@ auto orbit_camera::update(const Vector3& current_target, const Vector3& mass_cen
|
|||||||
const float y = sin(angle_y) * actual_distance;
|
const float y = sin(angle_y) * actual_distance;
|
||||||
const float z = cos(angle_y) * cos(angle_x) * actual_distance;
|
const float z = cos(angle_y) * cos(angle_x) * actual_distance;
|
||||||
|
|
||||||
fov = Clamp(fov, MIN_FOV, MAX_FOV);
|
if (projection == CAMERA_ORTHOGRAPHIC) {
|
||||||
|
fov = Clamp(fov, MIN_FOV, MAX_ORTHO_FOV);
|
||||||
|
} else {
|
||||||
|
fov = Clamp(fov, MIN_FOV, MAX_PERSP_FOV);
|
||||||
|
}
|
||||||
|
|
||||||
camera.position = Vector3Add(target, Vector3(x, y, z));
|
camera.position = Vector3Add(target, Vector3(x, y, z));
|
||||||
camera.target = target;
|
camera.target = target;
|
||||||
|
|||||||
@ -104,7 +104,7 @@ auto renderer::draw_mass_springs(const std::vector<Vector3>& masses) -> void
|
|||||||
} else if (state.get_visit_counts().at(mass) > 0) {
|
} else if (state.get_visit_counts().at(mass) > 0) {
|
||||||
// Visited vertex
|
// Visited vertex
|
||||||
c = VERTEX_VISITED_COLOR;
|
c = VERTEX_VISITED_COLOR;
|
||||||
} else if (distances.size() == masses.size()) {
|
} else if (input.color_by_distance && distances.size() == masses.size()) {
|
||||||
c = lerp_color(VERTEX_FARTHEST_COLOR,
|
c = lerp_color(VERTEX_FARTHEST_COLOR,
|
||||||
VERTEX_CLOSEST_COLOR,
|
VERTEX_CLOSEST_COLOR,
|
||||||
static_cast<float>(distances[mass]));
|
static_cast<float>(distances[mass]));
|
||||||
|
|||||||
Reference in New Issue
Block a user