#pragma once

#include "demo/scene.hpp"
#include "physics/particle.hpp"
#include "physics/particle_link.hpp"

namespace demo {

  struct bridge : scene {
    struct cable_interpolator {
      float interp;
      int cable_ix;

      void interp_add(float n);
    };

    cable_interpolator interpolator;

    mat4x4 init() override;

    void _update();
    void update() override;

    void draw_hud(ta_parameter_writer& writer);
    void draw_weight(ta_parameter_writer& writer, const mat4x4& trans);
    void draw(ta_parameter_writer& writer, const mat4x4& trans) override;
    void a() override;
    void analog(float dl, float dr, float dx, float dy) override;

    static const inline int particles_length = 12;
    physics::particle particles[particles_length];

    static const inline int cables_length = 10;
    physics::particle_cable cables[cables_length];

    static const inline int anchors_length = 12;
    physics::particle_cable_constraint anchors[anchors_length];

    static const inline int rods_length = 6;
    physics::particle_rod rods[anchors_length];
  };
}
