mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 01:20:17 +00:00
Change double to float in some types (vec2/Transformation/PointF/etc.)
This commit is contained in:
parent
3ad60c4a6f
commit
66313e540f
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 2439471a2388c92b9256987e649d5e91df2e1711
|
||||
Subproject commit a2bc68cd98d881c00fd7a376161b85e36c02bc76
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -516,9 +516,9 @@ public:
|
||||
m_mask.unfreeze();
|
||||
|
||||
loop->setMask(&m_mask);
|
||||
double cornerThick = (loop->isTilemapMode()) ?
|
||||
CORNER_THICK_FOR_TILEMAP_MODE :
|
||||
CORNER_THICK_FOR_PIXELS_MODE;
|
||||
const float cornerThick = (loop->isTilemapMode() ?
|
||||
CORNER_THICK_FOR_TILEMAP_MODE:
|
||||
CORNER_THICK_FOR_PIXELS_MODE);
|
||||
loop->getDocument()->setTransformation(
|
||||
Transformation(RectF(m_mask.bounds()), cornerThick));
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -24,7 +24,8 @@ Transformation::Transformation()
|
||||
{
|
||||
}
|
||||
|
||||
Transformation::Transformation(const RectF& bounds, double cornerThick)
|
||||
Transformation::Transformation(const RectF& bounds,
|
||||
const float cornerThick)
|
||||
: m_bounds(bounds)
|
||||
, m_cornerThick(cornerThick)
|
||||
{
|
||||
@ -66,14 +67,14 @@ void Transformation::displacePivotTo(const PointF& newPivot)
|
||||
PointF Transformation::rotatePoint(
|
||||
const PointF& point,
|
||||
const PointF& pivot,
|
||||
const double angle,
|
||||
const double skew)
|
||||
const float angle,
|
||||
const float skew)
|
||||
{
|
||||
double cos = std::roundl(std::cos(-angle)*100000.0)/100000.0;
|
||||
double sin = std::roundl(std::sin(-angle)*100000.0)/100000.0;
|
||||
double tan = std::roundl(std::tan(skew)*100000.0)/100000.0;
|
||||
double dx = point.x - pivot.x;
|
||||
double dy = point.y - pivot.y;
|
||||
const float cos = std::roundl(std::cos(-angle)*100000.0f)/100000.0f;
|
||||
const float sin = std::roundl(std::sin(-angle)*100000.0f)/100000.0f;
|
||||
const float tan = std::roundl(std::tan(skew)*100000.0f)/100000.0f;
|
||||
float dx = point.x - pivot.x;
|
||||
float dy = point.y - pivot.y;
|
||||
dx += dy*tan;
|
||||
return PointF(pivot.x + dx*cos - dy*sin,
|
||||
pivot.y + dx*sin + dy*cos);
|
||||
@ -87,7 +88,8 @@ RectF Transformation::transformedBounds() const
|
||||
// Create a union of all corners
|
||||
RectF bounds;
|
||||
for (int i=0; i<Corners::NUM_OF_CORNERS; ++i)
|
||||
bounds = bounds.createUnion(RectF(corners[i].x, corners[i].y, m_cornerThick, m_cornerThick));
|
||||
bounds = bounds.createUnion(RectF(corners[i].x, corners[i].y,
|
||||
m_cornerThick, m_cornerThick));
|
||||
|
||||
return bounds.floor();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -13,8 +13,8 @@
|
||||
#include "gfx/rect.h"
|
||||
#include <vector>
|
||||
|
||||
#define CORNER_THICK_FOR_TILEMAP_MODE 0.001
|
||||
#define CORNER_THICK_FOR_PIXELS_MODE 1.0
|
||||
#define CORNER_THICK_FOR_TILEMAP_MODE 0.001f
|
||||
#define CORNER_THICK_FOR_PIXELS_MODE 1.0f
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
void rightBottom(const gfx::PointF& pt) { m_corners[RIGHT_BOTTOM] = pt; }
|
||||
void leftBottom(const gfx::PointF& pt) { m_corners[LEFT_BOTTOM] = pt; }
|
||||
|
||||
gfx::RectF bounds(double cornerThick) const {
|
||||
gfx::RectF bounds(const float cornerThick) const {
|
||||
gfx::RectF bounds;
|
||||
for (int i=0; i<Corners::NUM_OF_CORNERS; ++i)
|
||||
bounds |= gfx::RectF(m_corners[i].x, m_corners[i].y, cornerThick, cornerThick);
|
||||
@ -71,20 +71,21 @@ public:
|
||||
};
|
||||
|
||||
Transformation();
|
||||
Transformation(const gfx::RectF& bounds, double cornerThick);
|
||||
Transformation(const gfx::RectF& bounds,
|
||||
const float cornerThick);
|
||||
|
||||
// Simple getters and setters. The angle is in radians.
|
||||
|
||||
const gfx::RectF& bounds() const { return m_bounds; }
|
||||
const gfx::PointF& pivot() const { return m_pivot; }
|
||||
double cornerThick() const { return m_cornerThick; }
|
||||
double angle() const { return m_angle; }
|
||||
double skew() const { return m_skew; }
|
||||
float cornerThick() const { return m_cornerThick; }
|
||||
float angle() const { return m_angle; }
|
||||
float skew() const { return m_skew; }
|
||||
|
||||
void bounds(const gfx::RectF& bounds) { m_bounds = bounds; }
|
||||
void pivot(const gfx::PointF& pivot) { m_pivot = pivot; }
|
||||
void angle(double angle) { m_angle = angle; }
|
||||
void skew(double angle) { m_skew = angle; }
|
||||
void angle(float angle) { m_angle = angle; }
|
||||
void skew(float angle) { m_skew = angle; }
|
||||
|
||||
// Applies the transformation (rotation with angle/pivot) to the
|
||||
// current bounds (m_bounds).
|
||||
@ -99,15 +100,15 @@ public:
|
||||
// Static helper method to rotate points.
|
||||
static gfx::PointF rotatePoint(const gfx::PointF& point,
|
||||
const gfx::PointF& pivot,
|
||||
const double angle,
|
||||
const double skew);
|
||||
const float angle,
|
||||
const float skew);
|
||||
|
||||
private:
|
||||
gfx::RectF m_bounds = gfx::RectF(0.0, 0.0, 0.0, 0.0);
|
||||
gfx::PointF m_pivot = gfx::PointF(0.0, 0.0);
|
||||
double m_angle = 0.0;
|
||||
double m_skew = 0.0;
|
||||
double m_cornerThick = CORNER_THICK_FOR_PIXELS_MODE;
|
||||
gfx::RectF m_bounds = gfx::RectF(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
gfx::PointF m_pivot = gfx::PointF(0.0f, 0.0f);
|
||||
float m_angle = 0.0;
|
||||
float m_skew = 0.0;
|
||||
float m_cornerThick = CORNER_THICK_FOR_PIXELS_MODE;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2024 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -20,8 +20,8 @@ DelayedMouseMove::DelayedMouseMove(DelayedMouseMoveDelegate* delegate,
|
||||
: m_delegate(delegate)
|
||||
, m_editor(editor)
|
||||
, m_timer(interval)
|
||||
, m_spritePos(std::numeric_limits<double>::min(),
|
||||
std::numeric_limits<double>::min())
|
||||
, m_spritePos(std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min())
|
||||
{
|
||||
ASSERT(m_delegate);
|
||||
m_timer.Tick.connect([this] { commitMouseMove(); });
|
||||
@ -81,8 +81,8 @@ void DelayedMouseMove::commitMouseMove()
|
||||
|
||||
const gfx::PointF& DelayedMouseMove::spritePos() const
|
||||
{
|
||||
ASSERT(m_spritePos.x != std::numeric_limits<double>::min() &&
|
||||
m_spritePos.y != std::numeric_limits<double>::min());
|
||||
ASSERT(m_spritePos.x != std::numeric_limits<float>::min() &&
|
||||
m_spritePos.y != std::numeric_limits<float>::min());
|
||||
return m_spritePos;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2024 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -95,7 +95,7 @@ bool DraggingValueState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
const DragVector deltaV(delta.x, delta.y);
|
||||
const DragVector invDragVector(key->dragVector().x,
|
||||
-key->dragVector().y);
|
||||
const double threshold = invDragVector.magnitude();
|
||||
const float threshold = invDragVector.magnitude();
|
||||
|
||||
DragVector v = deltaV.projectOn(invDragVector);
|
||||
double dz = v.magnitude();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -131,9 +131,9 @@ PixelsMovement::PixelsMovement(
|
||||
, m_fastMode(false)
|
||||
, m_needsRotSpriteRedraw(false)
|
||||
{
|
||||
double cornerThick = (m_site.tilemapMode() == TilemapMode::Tiles) ?
|
||||
CORNER_THICK_FOR_TILEMAP_MODE :
|
||||
CORNER_THICK_FOR_PIXELS_MODE;
|
||||
const float cornerThick = (m_site.tilemapMode() == TilemapMode::Tiles ?
|
||||
CORNER_THICK_FOR_TILEMAP_MODE:
|
||||
CORNER_THICK_FOR_PIXELS_MODE);
|
||||
Transformation transform(mask->bounds(), cornerThick);
|
||||
set_pivot_from_preferences(transform);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2024 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
namespace app {
|
||||
|
||||
using vec2 = base::Vector2d<double>;
|
||||
using vec2 = base::Vector2d<float>;
|
||||
|
||||
template<typename T>
|
||||
inline const vec2 to_vec2(const gfx::PointT<T>& pt) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user