Fixed issue with handedness and rotation and move tool
This commit is contained in:
@@ -18,6 +18,7 @@ namespace anm2ed
|
|||||||
LAYERS,
|
LAYERS,
|
||||||
NULLS,
|
NULLS,
|
||||||
SPRITESHEETS,
|
SPRITESHEETS,
|
||||||
|
TEXTURES,
|
||||||
EVENTS,
|
EVENTS,
|
||||||
ANIMATIONS,
|
ANIMATIONS,
|
||||||
ITEMS,
|
ITEMS,
|
||||||
|
|||||||
@@ -648,20 +648,32 @@ namespace anm2ed::imgui
|
|||||||
: ImGuiMouseCursor_NotAllowed;
|
: ImGuiMouseCursor_NotAllowed;
|
||||||
ImGui::SetMouseCursor(cursor);
|
ImGui::SetMouseCursor(cursor);
|
||||||
ImGui::SetKeyboardFocusHere();
|
ImGui::SetKeyboardFocusHere();
|
||||||
|
if (useTool != tool::MOVE) isMoveDragging = false;
|
||||||
switch (useTool)
|
switch (useTool)
|
||||||
{
|
{
|
||||||
case tool::PAN:
|
case tool::PAN:
|
||||||
if (isMouseDown || isMouseMiddleDown) pan += mouseDelta;
|
if (isMouseDown || isMouseMiddleDown) pan += vec2(mouseDelta.x, mouseDelta.y);
|
||||||
break;
|
break;
|
||||||
case tool::MOVE:
|
case tool::MOVE:
|
||||||
if (!frame) break;
|
if (!frame) break;
|
||||||
if (isBegin) document.snapshot("Frame Position");
|
if (isBegin)
|
||||||
if (isMouseDown) frame->position = mousePos;
|
{
|
||||||
|
document.snapshot("Frame Position");
|
||||||
|
if (isMouseClicked)
|
||||||
|
{
|
||||||
|
moveOffset = mousePos - frame->position;
|
||||||
|
isMoveDragging = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMouseDown && isMoveDragging)
|
||||||
|
{
|
||||||
|
frame->position = ivec2(mousePos - moveOffset);
|
||||||
|
}
|
||||||
if (isLeftPressed) frame->position.x -= step;
|
if (isLeftPressed) frame->position.x -= step;
|
||||||
if (isRightPressed) frame->position.x += step;
|
if (isRightPressed) frame->position.x += step;
|
||||||
if (isUpPressed) frame->position.y -= step;
|
if (isUpPressed) frame->position.y -= step;
|
||||||
if (isDownPressed) frame->position.y += step;
|
if (isDownPressed) frame->position.y += step;
|
||||||
|
if (isMouseReleased) isMoveDragging = false;
|
||||||
if (isEnd) document.change(Document::FRAMES);
|
if (isEnd) document.change(Document::FRAMES);
|
||||||
if (isDuring)
|
if (isDuring)
|
||||||
{
|
{
|
||||||
@@ -679,7 +691,7 @@ namespace anm2ed::imgui
|
|||||||
if (isBegin) document.snapshot("Frame Scale");
|
if (isBegin) document.snapshot("Frame Scale");
|
||||||
if (isMouseDown)
|
if (isMouseDown)
|
||||||
{
|
{
|
||||||
frame->scale += mouseDelta;
|
frame->scale += vec2(mouseDelta.x, mouseDelta.y);
|
||||||
if (isMod) frame->scale = {frame->scale.x, frame->scale.x};
|
if (isMod) frame->scale = {frame->scale.x, frame->scale.x};
|
||||||
}
|
}
|
||||||
if (isLeftPressed) frame->scale.x -= step;
|
if (isLeftPressed) frame->scale.x -= step;
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ namespace anm2ed::imgui
|
|||||||
float savedZoom{};
|
float savedZoom{};
|
||||||
glm::vec2 savedPan{};
|
glm::vec2 savedPan{};
|
||||||
int savedOverlayIndex{};
|
int savedOverlayIndex{};
|
||||||
glm::ivec2 mousePos{};
|
glm::vec2 mousePos{};
|
||||||
glm::vec2 checkerPan{};
|
glm::vec2 checkerPan{};
|
||||||
glm::vec2 checkerSyncPan{};
|
glm::vec2 checkerSyncPan{};
|
||||||
float checkerSyncZoom{};
|
float checkerSyncZoom{};
|
||||||
bool isCheckerPanInitialized{};
|
bool isCheckerPanInitialized{};
|
||||||
bool hasPendingZoomPanAdjust{};
|
bool hasPendingZoomPanAdjust{};
|
||||||
|
bool isMoveDragging{};
|
||||||
|
glm::vec2 moveOffset{};
|
||||||
std::vector<resource::Texture> renderFrames{};
|
std::vector<resource::Texture> renderFrames{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ namespace anm2ed::util::math
|
|||||||
constexpr auto FLOAT_FORMAT_EPSILON = 1e-7f;
|
constexpr auto FLOAT_FORMAT_EPSILON = 1e-7f;
|
||||||
constexpr float FLOAT_FORMAT_POW10[] = {1.f, 10.f, 100.f, 1000.f, 10000.f, 100000.f, 1000000.f, 10000000.f};
|
constexpr float FLOAT_FORMAT_POW10[] = {1.f, 10.f, 100.f, 1000.f, 10000.f, 100000.f, 1000000.f, 10000000.f};
|
||||||
|
|
||||||
float round_nearest_multiple(float value, float multiple)
|
float round_nearest_multiple(float value, float multiple) { return (roundf((value) / (multiple)) * (multiple)); }
|
||||||
{
|
|
||||||
return (roundf((value) / (multiple)) * (multiple));
|
|
||||||
}
|
|
||||||
|
|
||||||
int float_decimals_needed(float value)
|
int float_decimals_needed(float value)
|
||||||
{
|
{
|
||||||
@@ -51,12 +48,13 @@ namespace anm2ed::util::math
|
|||||||
vec2 scaleSign = glm::sign(scale);
|
vec2 scaleSign = glm::sign(scale);
|
||||||
vec2 pivotScaled = pivot * scaleAbsolute;
|
vec2 pivotScaled = pivot * scaleAbsolute;
|
||||||
vec2 sizeScaled = size * scaleAbsolute;
|
vec2 sizeScaled = size * scaleAbsolute;
|
||||||
|
float handedness = (scaleSign.x * scaleSign.y) < 0.0f ? -1.0f : 1.0f;
|
||||||
|
|
||||||
mat4 model(1.0f);
|
mat4 model(1.0f);
|
||||||
model = glm::translate(model, vec3(position - pivotScaled, 0.0f));
|
model = glm::translate(model, vec3(position - pivotScaled, 0.0f));
|
||||||
model = glm::translate(model, vec3(pivotScaled, 0.0f));
|
model = glm::translate(model, vec3(pivotScaled, 0.0f));
|
||||||
model = glm::scale(model, vec3(scaleSign, 1.0f));
|
model = glm::scale(model, vec3(scaleSign, 1.0f));
|
||||||
model = glm::rotate(model, glm::radians(rotation), vec3(0, 0, 1));
|
model = glm::rotate(model, glm::radians(rotation) * handedness, vec3(0, 0, 1));
|
||||||
model = glm::translate(model, vec3(-pivotScaled, 0.0f));
|
model = glm::translate(model, vec3(-pivotScaled, 0.0f));
|
||||||
model = glm::scale(model, vec3(sizeScaled, 1.0f));
|
model = glm::scale(model, vec3(sizeScaled, 1.0f));
|
||||||
return model;
|
return model;
|
||||||
|
|||||||
Reference in New Issue
Block a user