コード例 #1
0
void CameraProxy::_update_following(double dt) {
    if(following_actor_ && stage->has_actor(following_actor_)) {
        float t = (fabs(following_lag_) < kmEpsilon) ? 1.0 : dt * (1.0 / following_lag_);

        auto actor = stage->actor(following_actor_);

        Vec3 avatar_position = actor->absolute_position();
        Quaternion avatar_rotation = actor->absolute_rotation();
        Quaternion initial_rotation = absolute_rotation();
        Vec3 initial_position = absolute_position();

        Vec3 destination_position;
        Quaternion destination_rotation;

        if(following_mode_ == CAMERA_FOLLOW_MODE_DIRECT) {
            destination_position = avatar_position + following_offset_.rotated_by(avatar_rotation);
            destination_rotation = calc_look_at_rotation(avatar_position);
        } else if(following_mode_ == CAMERA_FOLLOW_MODE_THIRD_PERSON) {
            float yaw = kmQuaternionGetYaw(&avatar_rotation);
            kmQuaternionRotationPitchYawRoll(&destination_rotation, 0, yaw, 0);
            destination_position = following_offset_.rotated_by(destination_rotation) + avatar_position;
        } else {
            throw std::logic_error("Unknown camera follow mode");
        }

        set_absolute_position(initial_position.lerp(destination_position, t));
        set_absolute_rotation(initial_rotation.slerp(destination_rotation, t));
    } else {
        //The actor was destroyed, so reset
        following_actor_ = ActorID();
    }
}
コード例 #2
0
static void _delete_selection(void)
{
        int len = strlen(current_song->message);
        int eat;

        cursor_pos = widgets_message[0].clip_start;
        if (cursor_pos > widgets_message[0].clip_end) {
                cursor_pos = widgets_message[0].clip_end;
                eat = widgets_message[0].clip_start - cursor_pos;
        } else {
                eat = widgets_message[0].clip_end - cursor_pos;
        }
        clippy_select(NULL, NULL, 0);
        if (cursor_pos == len)
                return;
        memmove(current_song->message + cursor_pos, current_song->message + cursor_pos + eat + 1,
                ((len - cursor_pos) - eat)+1);
        current_song->message[MAX_MESSAGE] = 0;
        set_absolute_position(current_song->message, cursor_pos, &cursor_line, &cursor_char);
        message_reposition();

        status.flags |= NEED_UPDATE | SONG_NEEDS_SAVE;
}