Skip to content

Commit

Permalink
fix: 修复 target_offset 计算错误
Browse files Browse the repository at this point in the history
fix #523
  • Loading branch information
MistEO committed Jan 27, 2025
1 parent 1be98b8 commit 32dc3ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/MaaFramework/Task/Component/Actuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ cv::Rect Actuator::get_target_rect(const MAA_RES_NS::Action::Target target, cons
}

auto image = controller()->cached_image();
int x = std::clamp(raw.x, 0, image.cols);
int y = std::clamp(raw.y, 0, image.rows);
int width = std::clamp(raw.width, 0, image.cols - x);
int height = std::clamp(raw.height, 0, image.rows - y);

int x = std::clamp(raw.x + target.offset.x, 0, image.cols);
int y = std::clamp(raw.y + target.offset.y, 0, image.rows);
int width = std::clamp(raw.width + target.offset.width, 0, image.cols - x);
int height = std::clamp(raw.height + target.offset.height, 0, image.rows - y);

return cv::Rect(x, y, width, height);
}
Expand Down

0 comments on commit 32dc3ae

Please sign in to comment.