INNER CODE UNIT · C++

new_index

symphony-of-empires/symphony-of-empires · eng3d/eng3d/borders.cpp:84

        int new_index = new_x + new_y * width;
        const auto color_ul = pixels[new_index];
        const auto color_dl = pixels[new_index + width];
        const auto color_ur = pixels[new_index + 1];
        const auto color_dr = pixels[new_index + width + 1];
        // Different neighbor, ie its a border
        if(color_ul != color_ur || color_ur != color_dr || color_dr != color_dl || color_dl != color_ul)
            return true;
        return false;
    }

    void add_neighbor(int prev_x, int prev_y, int new_x, int new_y, int& connections) {
        if(check_neighbor(new_x, new_y)) {
            int old_index = prev_x + prev_y * width;
            int new_index = new_x + new_y * width;
            int index = 2 * glm::min<int>(old_index, new_index) + std::abs(prev_x - new_x);
            if(walked_paths.count(index)) return;
            walked_positions.insert(new_index);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…