Editor panning with mouse

main
parent 3cf492b0b4
commit 1ce259537b

@ -118,6 +118,14 @@
{ {
filepath: "RightArrow.png", filepath: "RightArrow.png",
} }
@image move:
{
filepath: "Move.png",
}
@image select:
{
filepath: "Select.png",
}
@image white_square: @image white_square:
{ {
filepath: "white square.png", filepath: "white square.png",

BIN
assets/Select.png (Stored with Git LFS)

Binary file not shown.

@ -74,5 +74,4 @@ ActionInfo actions[] = {
.description = "Holsters your shotgun, no longer threatening who you're aiming at.", .description = "Holsters your shotgun, no longer threatening who you're aiming at.",
NO_ARGUMENT, NO_ARGUMENT,
}, },
}; };

@ -387,6 +387,7 @@ void play_audio(AudioSample *sample, float volume)
#define SAPP_KEYCODE_MAX SAPP_KEYCODE_MENU #define SAPP_KEYCODE_MAX SAPP_KEYCODE_MENU
bool keydown[SAPP_KEYCODE_MAX] = { 0 }; bool keydown[SAPP_KEYCODE_MAX] = { 0 };
bool keypressed[SAPP_KEYCODE_MAX] = { 0 }; bool keypressed[SAPP_KEYCODE_MAX] = { 0 };
Vec2 mouse_movement = { 0 };
typedef struct { typedef struct {
bool open; bool open;
@ -5528,22 +5529,26 @@ void frame(void)
text_input_fade = Lerp(text_input_fade, unwarped_dt * 8.0f, receiving_text_input ? 1.0f : 0.0f); text_input_fade = Lerp(text_input_fade, unwarped_dt * 8.0f, receiving_text_input ? 1.0f : 0.0f);
Vec3 cam_target_pos = V3(0,0,0); Vec3 cam_target_pos = V3(0,0,0);
if(gs.edit.enabled) {
cam_target_pos.x = gs.edit.camera_panning.x;
cam_target_pos.z = gs.edit.camera_panning.y;
}
//dbgline(V2(0,0), V2(500, 500)); //dbgline(V2(0,0), V2(500, 500));
const float vertical_to_horizontal_ratio = CAM_VERTICAL_TO_HORIZONTAL_RATIO; const float vertical_to_horizontal_ratio = CAM_VERTICAL_TO_HORIZONTAL_RATIO;
const float cam_distance = CAM_DISTANCE; const float cam_distance = CAM_DISTANCE;
Vec3 away_from_player; Vec3 cam_offset_from_target;
{ {
float ratio = vertical_to_horizontal_ratio; float ratio = vertical_to_horizontal_ratio;
float x = sqrtf( (cam_distance * cam_distance) / (1 + (ratio*ratio)) ); float x = sqrtf( (cam_distance * cam_distance) / (1 + (ratio*ratio)) );
float y = ratio * x; float y = ratio * x;
away_from_player = V3(x, y, 0.0); cam_offset_from_target = V3(x, y, 0.0);
} }
away_from_player = MulM4V4(Rotate_RH(-PI32/3.0f + PI32, V3(0,1,0)), IsPoint(away_from_player)).xyz; cam_offset_from_target = MulM4V4(Rotate_RH(-PI32/3.0f + PI32, V3(0,1,0)), IsPoint(cam_offset_from_target)).xyz;
if(get_cur_room(&gs, &level_threedee)->camera_offset_is_overridden) if(get_cur_room(&gs, &level_threedee)->camera_offset_is_overridden)
{ {
away_from_player = get_cur_room(&gs, &level_threedee)->camera_offset; cam_offset_from_target = get_cur_room(&gs, &level_threedee)->camera_offset;
} }
Vec3 cam_pos = AddV3(cam_target_pos, away_from_player); Vec3 cam_pos = AddV3(cam_target_pos, cam_offset_from_target);
Vec2 movement = { 0 }; Vec2 movement = { 0 };
if (mobile_controls) if (mobile_controls)
@ -5843,6 +5848,19 @@ void frame(void)
if(right) gs.edit.room_index += 1; if(right) gs.edit.room_index += 1;
// gs.edit.room_index %= num_rooms(&level_threedee); Why the fuck doesn't this just work // gs.edit.room_index %= num_rooms(&level_threedee); Why the fuck doesn't this just work
gs.edit.room_index = mod(gs.edit.room_index, num_rooms(&level_threedee)); gs.edit.room_index = mod(gs.edit.room_index, num_rooms(&level_threedee));
if(mouse_down) {
Vec2 to_pos = mouse_pos;
Vec2 from_pos = AddV2(mouse_pos, mouse_movement);
// dbgline(from_pos, to_pos);
Vec3 to_plane = point_on_plane_from_camera_point(view, to_pos);
Vec3 from_plane = point_on_plane_from_camera_point(view, from_pos);
Vec3 movement_on_plane = SubV3(to_plane, from_plane);
// dbg3dline(from_plane, to_plane);
Vec2 movement = V2(movement_on_plane.x, movement_on_plane.z);
gs.edit.camera_panning_target = AddV2(gs.edit.camera_panning_target, movement);
}
gs.edit.camera_panning = LerpV2(gs.edit.camera_panning, unwarped_dt * 19.0f, gs.edit.camera_panning_target);
} }
} }
PROFILE_SCOPE("Entity UI Rendering") PROFILE_SCOPE("Entity UI Rendering")
@ -6832,12 +6850,6 @@ void frame(void)
} }
#ifdef DEVTOOLS #ifdef DEVTOOLS
if(keypressed[SAPP_KEYCODE_J])
{
Log("Judgement Day!\n");
}
// statistics @Place(devtools drawing developer menu drawing) // statistics @Place(devtools drawing developer menu drawing)
if (show_devtools) if (show_devtools)
PROFILE_SCOPE("devtools drawing") PROFILE_SCOPE("devtools drawing")
@ -7073,6 +7085,7 @@ void frame(void)
memset(keypressed, 0, sizeof(keypressed)); memset(keypressed, 0, sizeof(keypressed));
pressed = (PressedState) { 0 }; pressed = (PressedState) { 0 };
mouse_movement = V2(0,0);
} }
} }
@ -7372,6 +7385,8 @@ void event(const sapp_event *e)
} }
if (e->type == SAPP_EVENTTYPE_MOUSE_MOVE) if (e->type == SAPP_EVENTTYPE_MOUSE_MOVE)
{ {
mouse_movement.x += e->mouse_dx;
mouse_movement.y -= e->mouse_dy;
bool ignore_movement = false; bool ignore_movement = false;
#ifdef DEVTOOLS #ifdef DEVTOOLS
if (mouse_frozen) ignore_movement = true; if (mouse_frozen) ignore_movement = true;

@ -288,6 +288,8 @@ typedef struct Npc {
typedef struct EditorState { typedef struct EditorState {
bool enabled; bool enabled;
int room_index; int room_index;
Vec2 camera_panning_target;
Vec2 camera_panning;
} EditorState; } EditorState;
typedef struct GameState { typedef struct GameState {

Loading…
Cancel
Save