Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noggit: add object transform sensitivity modifiers #111

Open
wants to merge 1 commit into
base: default
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions src/noggit/MapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
static const float XSENS = 15.0f;
static const float YSENS = 15.0f;

static const float OBJ_TRANSFORM_SENSITIVITY_MIN = 0.05f;
static const float OBJ_TRANSFORM_SENSITIVITY_MAX = 1.0f;
static const float OBJ_TRANSFORM_SENSITIVITY_STEP = 0.2f;

void MapView::set_editing_mode (editing_mode mode)
{
makeCurrent();
Expand Down Expand Up @@ -1000,6 +1004,32 @@ void MapView::createGUI()
, [this] { return terrainMode == editing_mode::object; }
);

addHotkey( Qt::Key_L
, MOD_none
, [this]
{
obj_transform_sens = std::min
(
obj_transform_sens + OBJ_TRANSFORM_SENSITIVITY_STEP
, OBJ_TRANSFORM_SENSITIVITY_MAX
);
}
, [this] { return terrainMode == editing_mode::object; }
);

addHotkey( Qt::Key_K
, MOD_none
, [this]
{
obj_transform_sens = std::max
(
obj_transform_sens - OBJ_TRANSFORM_SENSITIVITY_STEP
, OBJ_TRANSFORM_SENSITIVITY_MIN
);
}
, [this] { return terrainMode == editing_mode::object; }
);

ADD_ACTION (view_menu, "Invert mouse", "I", [this] { mousedir *= -1.f; });

ADD_ACTION (view_menu, "Decrease camera speed", Qt::Key_O, [this] { _camera.move_speed *= 0.5f; });
Expand Down Expand Up @@ -1714,11 +1744,15 @@ void MapView::tick (float dt)
{
if (_mod_alt_down)
{
_world->scale_selected_models(std::pow(2.f, mv*4.f), World::m2_scaling_type::mult);
_world->scale_selected_models
(
std::pow(2.f, mv*4.f*obj_transform_sens)
, World::m2_scaling_type::mult
);
}
else if (_mod_shift_down)
{
_world->move_selected_models(0.f, mv*80.f, 0.f);
_world->move_selected_models(0.f, mv*80.f*obj_transform_sens, 0.f);
}
else
{
Expand All @@ -1737,7 +1771,10 @@ void MapView::tick (float dt)
{
if (!_move_model_to_cursor_position.get())
{
_world->move_selected_models((mv * dirUp - mh * dirRight)*80.f);
_world->move_selected_models
(
(mv * dirUp - mh * dirRight)*80.f*obj_transform_sens
);
}
else
{
Expand Down Expand Up @@ -1793,7 +1830,7 @@ void MapView::tick (float dt)
{
if (_mod_ctrl_down) // X
{
_world->rotate_selected_models( math::degrees(rh + rv)
_world->rotate_selected_models( math::degrees((rh + rv)*obj_transform_sens)
, math::degrees(0.f)
, math::degrees(0.f)
, _use_median_pivot_point.get()
Expand All @@ -1802,7 +1839,7 @@ void MapView::tick (float dt)
if (_mod_shift_down) // Y
{
_world->rotate_selected_models( math::degrees(0.f)
, math::degrees(rh + rv)
, math::degrees((rh + rv)*obj_transform_sens)
, math::degrees(0.f)
, _use_median_pivot_point.get()
);
Expand All @@ -1811,7 +1848,7 @@ void MapView::tick (float dt)
{
_world->rotate_selected_models( math::degrees(0.f)
, math::degrees(0.f)
, math::degrees(rh + rv)
, math::degrees((rh + rv)*obj_transform_sens)
, _use_median_pivot_point.get()
);
}
Expand Down
1 change: 1 addition & 0 deletions src/noggit/MapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class MapView : public QOpenGLWidget

bool MoveObj;
float numpad_moveratio = 0.001f;
float obj_transform_sens = 1.0f;

math::vector_3d objMove;

Expand Down
3 changes: 3 additions & 0 deletions src/noggit/ui/Help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ namespace noggit
generate_hotkey_row({ font_noggit::shift }, "Holding \a 1 / 3 - Double speed", object_layout);
generate_hotkey_row({ font_noggit::ctrl }, "Holding \a 1 / 3 - Triple speed", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::ctrl }, "Holding \a and \a together - half speed", object_layout);
generate_hotkey_row({ font_noggit::k }, "\a Decrease object transform sensitivity", object_layout);
generate_hotkey_row({ font_noggit::l }, "\a Increase object transform sensitivity", object_layout);


auto shader_widget (new QWidget (this));
auto shader_layout (new QFormLayout (shader_widget));
Expand Down