diff --git a/source/game/StarHumanoid.cpp b/source/game/StarHumanoid.cpp index 84c64bf..9f6f8a3 100644 --- a/source/game/StarHumanoid.cpp +++ b/source/game/StarHumanoid.cpp @@ -463,7 +463,7 @@ void Humanoid::resetAnimation() { m_danceTimer = 0.0f; } -List Humanoid::render() { +List Humanoid::render(bool withItems, bool withRotation) { List drawables; int armStateSeq = getArmStateSequence(); @@ -521,9 +521,9 @@ List Humanoid::render() { addDrawable(move(drawable)); } - if (backHand.holdingItem && !dance.isValid()) { + if (backHand.holdingItem && !dance.isValid() && withItems) { auto drawItem = [&]() { - for (auto backHandItem : backHand.itemDrawables) { + for (auto& backHandItem : backHand.itemDrawables) { backHandItem.translate(m_frontHandPosition + backArmFrameOffset + m_backArmOffset); backHandItem.rotate(backHand.itemAngle, backArmFrameOffset + m_backArmRotationCenter + m_backArmOffset); addDrawable(move(backHandItem)); @@ -688,10 +688,9 @@ List Humanoid::render() { return frontArm; }; - if (frontHand.holdingItem && !dance.isValid()) { + if (frontHand.holdingItem && !dance.isValid() && withItems) { auto drawItem = [&]() { - for (size_t i = 0; i < frontHand.itemDrawables.size(); i++) { - Drawable frontHandItem = frontHand.itemDrawables[i]; + for (auto& frontHandItem : frontHand.itemDrawables) { frontHandItem.translate(m_frontHandPosition + frontArmFrameOffset); frontHandItem.rotate(frontHand.itemAngle, frontArmFrameOffset + m_frontArmRotationCenter); addDrawable(frontHandItem); @@ -755,7 +754,9 @@ List Humanoid::render() { if (m_altHand.nonRotatedDrawables.size()) drawables.insertAllAt(0, m_altHand.nonRotatedDrawables); - Drawable::rotateAll(drawables, m_rotation); + if (withRotation) + Drawable::rotateAll(drawables, m_rotation); + Drawable::translateAll(drawables, m_globalOffset); Drawable::rebaseAll(drawables); @@ -1296,7 +1297,7 @@ List Humanoid::particles(String const& name) const { auto particleDatabase = Root::singleton().particleDatabase(); List res; Json particles = m_particleEmitters.get(name).get("particles", {}); - for (auto particle : particles.toArray()) { + for (auto& particle : particles.toArray()) { auto particleSpec = particle.get("particle", {}); res.push_back(particleDatabase->particle(particleSpec)); } diff --git a/source/game/StarHumanoid.hpp b/source/game/StarHumanoid.hpp index 0b4ef70..17cdbda 100644 --- a/source/game/StarHumanoid.hpp +++ b/source/game/StarHumanoid.hpp @@ -192,7 +192,7 @@ public: // Renders to centered drawables (centered on the normal image center for the // player graphics), (in world space, not pixels) - List render(); + List render(bool withItems = true, bool withRotation = true); // Renders to centered drawables (centered on the normal image center for the // player graphics), (in pixels, not world space) diff --git a/source/windowing/StarPortraitWidget.cpp b/source/windowing/StarPortraitWidget.cpp index 6af27ba..67a4d92 100644 --- a/source/windowing/StarPortraitWidget.cpp +++ b/source/windowing/StarPortraitWidget.cpp @@ -8,6 +8,7 @@ namespace Star { PortraitWidget::PortraitWidget(PortraitEntityPtr entity, PortraitMode mode) : m_entity(entity), m_portraitMode(mode) { m_scale = 1; + m_renderHumanoid = false; m_iconMode = false; init(); @@ -44,7 +45,7 @@ void PortraitWidget::renderImpl() { humanoid = player->humanoid(); } - List portrait = humanoid ? humanoid->render() : m_entity->portrait(m_portraitMode); + List portrait = humanoid ? humanoid->render(false, false) : m_entity->portrait(m_portraitMode); for (auto& i : portrait) { i.scale(humanoid ? m_scale * 8.0f : m_scale); context()->drawInterfaceDrawable(i, Vec2F(screenPosition() + offset));