horse_renderer.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "horse_renderer.h"
  2. #include "../equipment/horse/i_horse_equipment_renderer.h"
  3. #include "../humanoid/rig.h"
  4. #include <utility>
  5. namespace Render::GL {
  6. HorseRenderer::HorseRenderer() = default;
  7. HorseRenderer::HorseRenderer(
  8. std::vector<std::shared_ptr<IHorseEquipmentRenderer>> attachments)
  9. : m_attachments(std::move(attachments)) {}
  10. void HorseRenderer::set_attachments(
  11. const std::vector<std::shared_ptr<IHorseEquipmentRenderer>> &attachments) {
  12. m_attachments = attachments;
  13. }
  14. void HorseRenderer::draw_attachments(
  15. const DrawContext &ctx, const AnimationInputs &anim,
  16. const HumanoidAnimationContext &, HorseProfile &profile,
  17. const MountedAttachmentFrame &, float phase, float bob, float,
  18. const HorseBodyFrames &frames, ISubmitter &out) const {
  19. if (m_attachments.empty()) {
  20. return;
  21. }
  22. HorseAnimationContext horse_anim;
  23. horse_anim.time = anim.time;
  24. horse_anim.phase = phase;
  25. horse_anim.bob = bob;
  26. horse_anim.is_moving = anim.is_moving;
  27. horse_anim.rider_intensity = 0.0F;
  28. for (const auto &attachment : m_attachments) {
  29. if (attachment) {
  30. attachment->render(ctx, frames, profile.variant, horse_anim, out);
  31. }
  32. }
  33. }
  34. } // namespace Render::GL