diff options
author | german77 <juangerman-13@hotmail.com> | 2022-07-24 23:39:32 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-07-24 23:39:32 +0200 |
commit | 21b1e9c21afa5d79b9de850166a375f9b050cc1f (patch) | |
tree | 9b2aecac17ba5c38c8afb3d56234b6390890b337 /src | |
parent | service: irs: Implement clustering processor (diff) | |
download | yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.tar yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.tar.gz yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.tar.bz2 yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.tar.lz yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.tar.xz yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.tar.zst yuzu-21b1e9c21afa5d79b9de850166a375f9b050cc1f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/hid/irs_ring_lifo.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/hid/irsensor/clustering_processor.cpp | 24 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/core/hle/service/hid/irs_ring_lifo.h b/src/core/hle/service/hid/irs_ring_lifo.h index a31e61037..255d1d296 100644 --- a/src/core/hle/service/hid/irs_ring_lifo.h +++ b/src/core/hle/service/hid/irs_ring_lifo.h @@ -36,7 +36,7 @@ struct Lifo { } void WriteNextEntry(const State& new_state) { - if (buffer_count < max_buffer_size) { + if (buffer_count < static_cast<s64>(max_buffer_size)) { buffer_count++; } sampling_number++; diff --git a/src/core/hle/service/hid/irsensor/clustering_processor.cpp b/src/core/hle/service/hid/irsensor/clustering_processor.cpp index 57e1831b4..e5b999b9f 100644 --- a/src/core/hle/service/hid/irsensor/clustering_processor.cpp +++ b/src/core/hle/service/hid/irsensor/clustering_processor.cpp @@ -127,10 +127,10 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::GetClusterProperties(st }; for (const auto new_point : new_points) { - if (new_point.x < 0 || new_point.x >= width) { + if (new_point.x >= width) { continue; } - if (new_point.y < 0 || new_point.y >= height) { + if (new_point.y >= height) { continue; } if (GetPixel(data, new_point.x, new_point.y) < current_config.object_intensity_min) { @@ -169,12 +169,14 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::GetPixelProperties( ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster( const ClusteringData a, const ClusteringData b) const { - const u32 pixel_count = a.pixel_count + b.pixel_count; + const f32 a_pixel_count = static_cast<f32>(a.pixel_count); + const f32 b_pixel_count = static_cast<f32>(b.pixel_count); + const f32 pixel_count = a_pixel_count + b_pixel_count; const f32 average_intensitiy = - (a.average_intensity * a.pixel_count + b.average_intensity * b.pixel_count) / pixel_count; + (a.average_intensity * a_pixel_count + b.average_intensity * b_pixel_count) / pixel_count; const Core::IrSensor::IrsCentroid centroid = { - .x = (a.centroid.x * a.pixel_count + b.centroid.x * b.pixel_count) / pixel_count, - .y = (a.centroid.y * a.pixel_count + b.centroid.y * b.pixel_count) / pixel_count, + .x = (a.centroid.x * a_pixel_count + b.centroid.x * b_pixel_count) / pixel_count, + .y = (a.centroid.y * a_pixel_count + b.centroid.y * b_pixel_count) / pixel_count, }; s16 bound_start_x = a.bound.x < b.bound.x ? a.bound.x : b.bound.x; s16 bound_start_y = a.bound.y < b.bound.y ? a.bound.y : b.bound.y; @@ -186,16 +188,16 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster( const Core::IrSensor::IrsRect bound = { .x = bound_start_x, .y = bound_start_y, - .width = a_bound_end_x > b_bound_end_x ? a_bound_end_x - bound_start_x - : b_bound_end_x - bound_start_x, - .height = a_bound_end_y > b_bound_end_y ? a_bound_end_y - bound_start_y - : b_bound_end_y - bound_start_y, + .width = a_bound_end_x > b_bound_end_x ? static_cast<s16>(a_bound_end_x - bound_start_x) + : static_cast<s16>(b_bound_end_x - bound_start_x), + .height = a_bound_end_y > b_bound_end_y ? static_cast<s16>(a_bound_end_y - bound_start_y) + : static_cast<s16>(b_bound_end_y - bound_start_y), }; return { .average_intensity = average_intensitiy, .centroid = centroid, - .pixel_count = pixel_count, + .pixel_count = static_cast<u32>(pixel_count), .bound = bound, }; } |