fix: scale not applying to NPCs properly and applying post-rotation
This commit is contained in:
parent
f7b7a2d4d5
commit
27e0f6bd71
@ -299,6 +299,7 @@ Humanoid::Humanoid(Json const& config) {
|
|||||||
m_altHand.angle = 0;
|
m_altHand.angle = 0;
|
||||||
m_facingDirection = Direction::Left;
|
m_facingDirection = Direction::Left;
|
||||||
m_rotation = 0;
|
m_rotation = 0;
|
||||||
|
m_scale = Vec2F::filled(1.f);
|
||||||
m_drawVaporTrail = false;
|
m_drawVaporTrail = false;
|
||||||
m_state = State::Idle;
|
m_state = State::Idle;
|
||||||
m_emoteState = HumanoidEmote::Idle;
|
m_emoteState = HumanoidEmote::Idle;
|
||||||
@ -409,6 +410,10 @@ void Humanoid::setRotation(float rotation) {
|
|||||||
m_rotation = rotation;
|
m_rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Humanoid::setScale(Vec2F scale) {
|
||||||
|
m_scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
void Humanoid::setVaporTrail(bool enabled) {
|
void Humanoid::setVaporTrail(bool enabled) {
|
||||||
m_drawVaporTrail = enabled;
|
m_drawVaporTrail = enabled;
|
||||||
}
|
}
|
||||||
@ -499,7 +504,7 @@ void Humanoid::resetAnimation() {
|
|||||||
m_danceTimer = 0.0f;
|
m_danceTimer = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Drawable> Humanoid::render(bool withItems, bool withRotation) {
|
List<Drawable> Humanoid::render(bool withItems, bool withRotationAndScale) {
|
||||||
List<Drawable> drawables;
|
List<Drawable> drawables;
|
||||||
|
|
||||||
int armStateSeq = getArmStateSequence();
|
int armStateSeq = getArmStateSequence();
|
||||||
@ -794,8 +799,12 @@ List<Drawable> Humanoid::render(bool withItems, bool withRotation) {
|
|||||||
|
|
||||||
for (auto& drawable : drawables) {
|
for (auto& drawable : drawables) {
|
||||||
drawable.translate(m_globalOffset);
|
drawable.translate(m_globalOffset);
|
||||||
if (withRotation && m_rotation != 0)
|
if (withRotationAndScale) {
|
||||||
|
if (m_scale.x() != 1.f || m_scale.y() != 1.f)
|
||||||
|
drawable.scale(m_scale);
|
||||||
|
if (m_rotation != 0.f)
|
||||||
drawable.rotate(m_rotation);
|
drawable.rotate(m_rotation);
|
||||||
|
}
|
||||||
drawable.rebase();
|
drawable.rebase();
|
||||||
}
|
}
|
||||||
return drawables;
|
return drawables;
|
||||||
|
@ -162,6 +162,7 @@ public:
|
|||||||
void setFacingDirection(Direction facingDirection);
|
void setFacingDirection(Direction facingDirection);
|
||||||
void setMovingBackwards(bool movingBackwards);
|
void setMovingBackwards(bool movingBackwards);
|
||||||
void setRotation(float rotation);
|
void setRotation(float rotation);
|
||||||
|
void setScale(Vec2F scale);
|
||||||
|
|
||||||
void setVaporTrail(bool enabled);
|
void setVaporTrail(bool enabled);
|
||||||
|
|
||||||
@ -197,7 +198,7 @@ public:
|
|||||||
|
|
||||||
// Renders to centered drawables (centered on the normal image center for the
|
// Renders to centered drawables (centered on the normal image center for the
|
||||||
// player graphics), (in world space, not pixels)
|
// player graphics), (in world space, not pixels)
|
||||||
List<Drawable> render(bool withItems = true, bool withRotation = true);
|
List<Drawable> render(bool withItems = true, bool withRotationAndScale = true);
|
||||||
|
|
||||||
// Renders to centered drawables (centered on the normal image center for the
|
// Renders to centered drawables (centered on the normal image center for the
|
||||||
// player graphics), (in pixels, not world space)
|
// player graphics), (in pixels, not world space)
|
||||||
@ -353,6 +354,7 @@ private:
|
|||||||
Direction m_facingDirection;
|
Direction m_facingDirection;
|
||||||
bool m_movingBackwards;
|
bool m_movingBackwards;
|
||||||
float m_rotation;
|
float m_rotation;
|
||||||
|
Vec2F m_scale;
|
||||||
bool m_drawVaporTrail;
|
bool m_drawVaporTrail;
|
||||||
|
|
||||||
HandDrawingInfo m_primaryHand;
|
HandDrawingInfo m_primaryHand;
|
||||||
|
@ -483,6 +483,7 @@ void Npc::render(RenderCallback* renderCallback) {
|
|||||||
scale = scale.piecewiseMultiply(result.first);
|
scale = scale.piecewiseMultiply(result.first);
|
||||||
humanoidDirectives.append(result.second);
|
humanoidDirectives.append(result.second);
|
||||||
}
|
}
|
||||||
|
m_humanoid.setScale(scale);
|
||||||
|
|
||||||
for (auto& drawable : m_humanoid.render()) {
|
for (auto& drawable : m_humanoid.render()) {
|
||||||
drawable.translate(position());
|
drawable.translate(position());
|
||||||
|
@ -386,9 +386,9 @@ List<Drawable> Player::drawables() const {
|
|||||||
};
|
};
|
||||||
extractScale(m_techController->parentDirectives().list());
|
extractScale(m_techController->parentDirectives().list());
|
||||||
extractScale(m_statusController->parentDirectives().list());
|
extractScale(m_statusController->parentDirectives().list());
|
||||||
|
m_humanoid->setScale(scale);
|
||||||
|
|
||||||
for (auto& drawable : m_humanoid->render()) {
|
for (auto& drawable : m_humanoid->render()) {
|
||||||
drawable.scale(scale);
|
|
||||||
drawable.translate(position() + m_techController->parentOffset());
|
drawable.translate(position() + m_techController->parentOffset());
|
||||||
if (drawable.isImage()) {
|
if (drawable.isImage()) {
|
||||||
drawable.imagePart().addDirectivesGroup(humanoidDirectives, true);
|
drawable.imagePart().addDirectivesGroup(humanoidDirectives, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user