mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-03 18:14:01 +00:00
splinegrid: allow changing point size to better acommodate very large or very small textures
This commit is contained in:
parent
dacfde0416
commit
6a7aa66bab
3 changed files with 25 additions and 5 deletions
|
@ -739,11 +739,17 @@ void AnimationEditor::update(float dt)
|
|||
float spd = 1.0f;
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ SplineGridCtrlPoint *SplineGridCtrlPoint::movingPoint;
|
|||
SplineGridCtrlPoint::SplineGridCtrlPoint()
|
||||
{
|
||||
setTexture("gui/open-menu");
|
||||
setWidthHeight(16, 16);
|
||||
setWidthHeight(8, 8);
|
||||
}
|
||||
|
||||
Vector SplineGridCtrlPoint::getSplinePosition() const
|
||||
|
@ -70,7 +70,7 @@ void SplineGridCtrlPoint::onUpdate(float dt)
|
|||
}
|
||||
|
||||
SplineGrid::SplineGrid()
|
||||
: wasModified(false), deg(0)
|
||||
: wasModified(false), deg(0), pointscale(1)
|
||||
{
|
||||
setWidthHeight(128, 128);
|
||||
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));
|
||||
SplineGridCtrlPoint *cp = new SplineGridCtrlPoint();
|
||||
cp->position = (pos01 - Vector(0.5f, 0.5f)) * wh;
|
||||
cp->scale.x = pointscale;
|
||||
cp->scale.y = pointscale;
|
||||
this->addChild(cp, PM_POINTER);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ public:
|
|||
void importControlPoints(const Vector *controlpoints);
|
||||
void resetControlPoints();
|
||||
|
||||
void setPointScale(const float scale);
|
||||
float getPointScale() const { return pointscale; }
|
||||
|
||||
|
||||
virtual void onRender(const RenderState& rs) const OVERRIDE;
|
||||
virtual void onUpdate(float dt) OVERRIDE;
|
||||
|
@ -55,6 +58,7 @@ private:
|
|||
std::vector<SplineGridCtrlPoint*> ctrlp;
|
||||
unsigned deg;
|
||||
BSpline2DWithPoints bsp;
|
||||
float pointscale;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue