1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-08-30 10:20:58 +00:00

splinegrid: allow changing point size to better acommodate very large or very small textures

This commit is contained in:
fgenesis 2023-08-22 21:28:05 +02:00
commit 6a7aa66bab
3 changed files with 25 additions and 5 deletions

View file

@ -739,11 +739,17 @@ void AnimationEditor::update(float dt)
float spd = 1.0f; float spd = 1.0f;
if (core->mouse.scrollWheelChange < 0) if (core->mouse.scrollWheelChange < 0)
{ {
ctrlSprite->scale.x /= 1.12f; if(splinegrid && core->getShiftState())
splinegrid->setPointScale(std::max(splinegrid->getPointScale() / 1.12f, 0.05f));
else
ctrlSprite->scale.x /= 1.12f;
} }
else if (core->mouse.scrollWheelChange > 0) else if (core->mouse.scrollWheelChange > 0)
{ {
ctrlSprite->scale.x *= 1.12f; if(splinegrid && core->getShiftState())
splinegrid->setPointScale(splinegrid->getPointScale() * 1.12f);
else
ctrlSprite->scale.x *= 1.12f;
} }
if (core->getKeyState(KEY_PGDN) && core->getShiftState()) if (core->getKeyState(KEY_PGDN) && core->getShiftState())
{ {

View file

@ -8,7 +8,7 @@ SplineGridCtrlPoint *SplineGridCtrlPoint::movingPoint;
SplineGridCtrlPoint::SplineGridCtrlPoint() SplineGridCtrlPoint::SplineGridCtrlPoint()
{ {
setTexture("gui/open-menu"); setTexture("gui/open-menu");
setWidthHeight(16, 16); setWidthHeight(8, 8);
} }
Vector SplineGridCtrlPoint::getSplinePosition() const Vector SplineGridCtrlPoint::getSplinePosition() const
@ -70,7 +70,7 @@ void SplineGridCtrlPoint::onUpdate(float dt)
} }
SplineGrid::SplineGrid() SplineGrid::SplineGrid()
: wasModified(false), deg(0) : wasModified(false), deg(0), pointscale(1)
{ {
setWidthHeight(128, 128); setWidthHeight(128, 128);
renderQuad = true; renderQuad = true;
@ -165,6 +165,8 @@ SplineGridCtrlPoint* SplineGrid::createControlPoint(size_t x, size_t y)
const Vector pos01(float(x) / float(cpx-1), float(y) / float(cpy-1)); const Vector pos01(float(x) / float(cpx-1), float(y) / float(cpy-1));
SplineGridCtrlPoint *cp = new SplineGridCtrlPoint(); SplineGridCtrlPoint *cp = new SplineGridCtrlPoint();
cp->position = (pos01 - Vector(0.5f, 0.5f)) * wh; cp->position = (pos01 - Vector(0.5f, 0.5f)) * wh;
cp->scale.x = pointscale;
cp->scale.y = pointscale;
this->addChild(cp, PM_POINTER); this->addChild(cp, PM_POINTER);
return cp; return cp;
} }
@ -214,4 +216,12 @@ void SplineGrid::onRender(const RenderState& rs) const
} }
} }
void SplineGrid::setPointScale(const float scale)
{
pointscale = scale;
for(size_t i = 0; i < ctrlp.size(); ++i)
{
ctrlp[i]->scale.x = scale;
ctrlp[i]->scale.y = scale;
}
}

View file

@ -39,6 +39,9 @@ public:
void importControlPoints(const Vector *controlpoints); void importControlPoints(const Vector *controlpoints);
void resetControlPoints(); void resetControlPoints();
void setPointScale(const float scale);
float getPointScale() const { return pointscale; }
virtual void onRender(const RenderState& rs) const OVERRIDE; virtual void onRender(const RenderState& rs) const OVERRIDE;
virtual void onUpdate(float dt) OVERRIDE; virtual void onUpdate(float dt) OVERRIDE;
@ -55,6 +58,7 @@ private:
std::vector<SplineGridCtrlPoint*> ctrlp; std::vector<SplineGridCtrlPoint*> ctrlp;
unsigned deg; unsigned deg;
BSpline2DWithPoints bsp; BSpline2DWithPoints bsp;
float pointscale;
}; };