Skip to content

Commit

Permalink
feat: use cv::warpPerspective in use_skill
Browse files Browse the repository at this point in the history
  • Loading branch information
horror-proton committed Aug 19, 2024
1 parent 17ef91e commit b7ae83e
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 117 deletions.
16 changes: 6 additions & 10 deletions 3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,21 @@ inline matrix4x4 camera_matrix_from_trans(
0, -sin_x, -cos_x, 0, //
0, 0, 0, 1,
};
const matrix4x4 proj = {
const double elem1 = -(far + near) / (far - near); // unable to inline, MSVC bug?
const double elem2 = -(far * near * 2) / (far - near);
const matrix4x4 proj = matrix4x4 {
// clang-format off
ratio / tan_f, 0, 0, 0,
0, 1 / tan_f, 0, 0,
0, 0, -(far + near) / (far - near), -(far * near * 2) / (far - near),
0, 0, elem1, elem2,
0, 0, -1, 0,
// clang-format on
};

return proj * matrixX * matrixY * translate;
}

inline cv::Point
world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {})
inline cv::Point world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {})
{
static constexpr double width = 1280;
static constexpr double height = 720;
Expand Down Expand Up @@ -107,12 +108,7 @@ inline vec3d get_tile_world_pos(const Level& level, int tile_y, int tile_x)
};
}

inline auto get_tile_screen_pos(
const Level& level,
int tile_y,
int tile_x,
bool side = false,
const vec3d& offset = {})
inline auto get_tile_screen_pos(const Level& level, int tile_y, int tile_x, bool side = false, const vec3d& offset = {})
{
return world_to_screen(level, get_tile_world_pos(level, tile_y, tile_x), side, offset);
}
Expand Down
29 changes: 6 additions & 23 deletions resource/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4627,29 +4627,12 @@
"BattleSkillReady": {
"rectMove": [-28, -140, 64, 64]
},
"BattleSkillReadyOnClick": {
"roi": [748, 414, 210, 118],
"templThreshold": 0.7,
"action": "ClickSelf",
"rectMove": [0, -110, 90, 90],
"postDelay": 300,
"next": ["#self", "Stop"]
},
"BattleSkillReadyOnClick-SquareMap": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillReadyOnClick-SquareMap.png"
},
"BattleSkillStopOnClick": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillStopOnClick.png"
},
"BattleSkillStopOnClick-MiddleMap": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillStopOnClick-MiddleMap.png"
},
"BattleSkillStopOnClick-SquareMap": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillStopOnClick-SquareMap.png"
"BattleSkillReadyOnClick-TopView": {
"template": [
"BattleSkillReadyOnClick-TopView.png",
"BattleSkillStopOnClick-TopView.png"
],
"templThreshold": [ 0.8, 0.8 ]
},
"BattleUseOper": {
"algorithm": "JustReturn",
Expand Down
Binary file removed resource/template/BattleSkillReady.png
Binary file not shown.
Binary file removed resource/template/BattleSkillReadyOnClick-SquareMap.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resource/template/BattleSkillReadyOnClick.png
Binary file not shown.
Binary file removed resource/template/BattleSkillStopOnClick-MiddleMap.png
Binary file not shown.
Binary file removed resource/template/BattleSkillStopOnClick-SquareMap.png
Binary file not shown.
Binary file added resource/template/BattleSkillStopOnClick-TopView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resource/template/BattleSkillStopOnClick.png
Binary file not shown.
Loading

0 comments on commit b7ae83e

Please sign in to comment.