feet_radius(feet_radius),
lift_start_y(0.0F),
rotation(0.0F),
- target_rotation(0.0F) {
+ target_rotation(0.0F),
+ body_idle_move_timer(0.0F) {
const Vector3 nw = Vector3Normalize(Vector3{-1.0F, 0.0F, -1.0F});
const Vector3 ne = Vector3Normalize(Vector3{1.0F, 0.0F, -1.0F});
const Vector3 sw = Vector3Normalize(Vector3{-1.0F, 0.0F, 1.0F});
.boneCount = model.boneCount,
.bones = model.bones,
.bindPose = model.bindPose},
- body_pos, 1.0F, WHITE);
+ Vector3{body_pos.x,
+ body_pos.y + BODY_IDLE_MOVE_AMOUNT *
+ std::sin(body_idle_move_timer + PI),
+ body_pos.z},
+ 1.0F, WHITE);
// draw legs
DrawModel(Model{.transform = model.transform * rotationMatrix,
constexpr float FEET_HORIZ_MOVE_SPEED = 8.0F;
constexpr float FEET_INIT_POS_VARIANCE_DIV = 3.0F;
constexpr float BODY_ROTATION_SPEED = 1.0F;
+constexpr float BODY_IDLE_TIMER_RATE = 1.0F;
+constexpr float BODY_IDLE_MOVE_AMOUNT = 0.2F;
class Walker {
public:
float lift_start_y;
float rotation;
float target_rotation;
+ float body_idle_move_timer;
};
template <typename TBBS>
update_leg_fn(target_leg_sw, leg_sw, sw_flags,
((nw_flags & 7) == 1 ? 1 : 0) + ((ne_flags & 7) == 1 ? 1 : 0) +
((se_flags & 7) == 1 ? 1 : 0));
+
+ if ((flags & 3) == 0) {
+ body_idle_move_timer += dt * BODY_IDLE_TIMER_RATE;
+ if (body_idle_move_timer > PI * 2.0F) {
+ body_idle_move_timer -= PI * 2.0F;
+ }
+ } else if (!FloatEquals(body_idle_move_timer, 0.0F)) {
+ if (body_idle_move_timer < PI) {
+ body_idle_move_timer += dt * BODY_IDLE_TIMER_RATE;
+ if (body_idle_move_timer > PI) {
+ body_idle_move_timer = 0;
+ }
+ } else {
+ body_idle_move_timer += dt * BODY_IDLE_TIMER_RATE;
+ if (body_idle_move_timer > PI * 2.0F) {
+ body_idle_move_timer = 0.0F;
+ }
+ }
+ }
}
#endif