Closed mali-tintash closed 2 years ago
What is a possible cause of this resulting in false for local_seam_leveling. validity mask is never changed after global_seam_leveling, or am I mistaken?
And why do we need an assertion here, why not just skip? What makes it such a big violation?
valid = (w0 * w2 == 0.0f || validity_mask->at(floor_x, floor_y, 0) == 255) && (w1 * w2 == 0.0f || validity_mask->at(floor_xp1, floor_y, 0) == 255) && (w0 * w3 == 0.0f || validity_mask->at(floor_x, floor_yp1, 0) == 255) && (w1 * w3 == 0.0f || validity_mask->at(floor_xp1, floor_yp1, 0) == 255);
taken from
bool TexturePatch::valid_pixel(math::Vec2f pixel) const { float x = pixel[0]; float y = pixel[1]; float const height = static_cast<float>(get_height()); float const width = static_cast<float>(get_width()); bool valid = (0.0f <= x && x < width && 0.0f <= y && y < height); if (valid && validity_mask != NULL){ /* Only pixel which can be correctly interpolated are valid. */ float cx = std::max(0.0f, std::min(width - 1.0f, x)); float cy = std::max(0.0f, std::min(height - 1.0f, y)); **int const floor_x = static_cast<int>(cx); int const floor_y = static_cast<int>(cy);** int const floor_xp1 = std::min(floor_x + 1, get_width() - 1); int const floor_yp1 = std::min(floor_y + 1, get_height() - 1); float const w1 = cx - static_cast<float>(floor_x); float const w0 = 1.0f - w1; float const w3 = cy - static_cast<float>(floor_y); float const w2 = 1.0f - w3; valid = (w0 * w2 == 0.0f || validity_mask->at(floor_x, floor_y, 0) == 255) && (w1 * w2 == 0.0f || validity_mask->at(floor_xp1, floor_y, 0) == 255) && (w0 * w3 == 0.0f || validity_mask->at(floor_x, floor_yp1, 0) == 255) && (w1 * w3 == 0.0f || validity_mask->at(floor_xp1, floor_yp1, 0) == 255); } return valid; }
The assertion failed because I had removed 0.5 subtraction from the texCoords. It works fine when I put that back.
What is a possible cause of this resulting in false for local_seam_leveling. validity mask is never changed after global_seam_leveling, or am I mistaken?
And why do we need an assertion here, why not just skip? What makes it such a big violation?
taken from