Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct occlusion distance calc for non-isometric tilesets #74445

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,9 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG
} else if( prevent_occlusion == 1 ) {
retract = 100;
} else {
const float distance = o.distance( pos.xy() );
const float distance = is_isometric() ? o.distance( pos.xy() ) :
point( static_cast<int>( o.x + ( screentile_width / 2.0f ) ),
static_cast<int>( o.y - 1 + ( screentile_height / 2.0f ) ) ).distance( pos.xy() );
const float d_min = prevent_occlusion_min_dist > 0.0 ? prevent_occlusion_min_dist :
tileset_ptr->get_prevent_occlusion_min_dist();
const float d_max = prevent_occlusion_max_dist > 0.0 ? prevent_occlusion_max_dist :
Expand All @@ -2494,7 +2496,8 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG
const float d_range = d_max - d_min;
const float d_slope = d_range <= 0.0f ? 100.0 : 1.0 / d_range;

retract = static_cast<int>( 100.0 * ( 1.0 - clamp( ( distance - d_min ) * d_slope, 0.0f, 1.0f ) ) );
retract = static_cast<int>( 100.0 * ( 1.0 - std::clamp( ( distance - d_min ) * d_slope, 0.0f,
1.0f ) ) );
}

if( prevent_occlusion_transp && retract > 0 ) {
Expand Down
Loading