Skip to content

perf(map): MapTrackerMove采用快速滑动视角转向#1080

Merged
isHarryh merged 5 commits intoMaaEnd:mainfrom
isHarryh:main
Mar 7, 2026
Merged

perf(map): MapTrackerMove采用快速滑动视角转向#1080
isHarryh merged 5 commits intoMaaEnd:mainfrom
isHarryh:main

Conversation

@isHarryh
Copy link
Member

@isHarryh isHarryh commented Mar 7, 2026

概要

此 PR 从 MapTrackerMove 节点中移除了基于 RunAction Swipe 的视角滑动方法,转而使用更快速的 TouchMove 实现,极大提升了转向速度。

此外,调整了部分转向策略和默认参数,使之适配此项更改。

Summary by Sourcery

改进地图追踪器的移动旋转处理和路径工具,以实现更快速、更精确的导航。

New Features:

  • 引入一个旋转调整状态,用于根据最近的移动和朝向变化来追踪并调整相机旋转速度。
  • 添加几何路径简化启发式算法,以减少地图追踪器编辑器中多余的记录路径点。

Bug Fixes:

  • 用更快速的触控移动实现替换原有的滑动式相机旋转,从而降低旋转延迟并减少过冲。

Enhancements:

  • 重新调校移动速度/旋转参数以及疾跑/到达阈值,使其更好地匹配新的快速旋转行为。
  • 优化启用疾跑的逻辑,在开始疾跑前需要更好的朝向对齐和更长的距离,以提升操控性。
  • 调整编辑器中的线条样式和点大小,以获得更清晰的路径可视化效果。

Documentation:

  • 更新中英文开发者文档,以反映新的到达和疾跑阈值默认值。
Original summary in English

Summary by Sourcery

Improve map tracker movement rotation handling and path tooling for faster, more precise navigation.

New Features:

  • Introduce a rotation adjustment state to track and adapt camera rotation speed based on recent movement and orientation changes.
  • Add a geometric path simplification heuristic to reduce redundant recorded waypoints in the map tracker editor.

Bug Fixes:

  • Replace swipe-based camera rotation with a faster touch-move implementation to reduce rotation latency and overshoot.

Enhancements:

  • Retune movement speed/rotation parameters and sprint/arrival thresholds to better match the new fast rotation behavior.
  • Refine sprint enabling logic to require better orientation and longer distance before sprinting, improving control.
  • Adjust editor line styling and point sizes for clearer path visualization.

Documentation:

  • Update developer documentation in both English and Chinese to reflect new arrival and sprint threshold defaults.

Copilot AI review requested due to automatic review settings March 7, 2026 12:14
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了两个问题,并给出了一些整体性的反馈:

  • 新的自适应旋转更新条件 if float64(actualDeltaRot)+rotAdjState.deltaRot > param.RotationLowerThreshold 混合使用了带符号的增量;建议使用绝对值(例如 math.Abs)或更清晰的度量方式,以避免相反方向的旋转意外地抑制或放大调整效果。
  • 在移除 calcAppliedDeltaRotation 之后,ROTATION_ADJUSTMENT_LOWER_BOUND 不再被使用;建议删除这个常量,以避免对“已经失效的配置开关”产生困惑。
  • SwipeSync 现在通过两个带 sleep 的 PostTouchMove 调用来实现,但仍然保留了 durationMillis 参数,而它不再像之前那样代表一次滑动的持续时间——建议重命名这个函数或参数,或调整其行为,使其语义对调用方来说依然直观。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new adaptive rotation update condition `if float64(actualDeltaRot)+rotAdjState.deltaRot > param.RotationLowerThreshold` mixes signed deltas; consider using absolute values (e.g. `math.Abs`) or a clearer metric so that opposite‑direction rotations don't accidentally suppress or exaggerate the adjustment.
- `ROTATION_ADJUSTMENT_LOWER_BOUND` is no longer used after removing `calcAppliedDeltaRotation`; consider deleting this constant to avoid confusion about dead configuration knobs.
- `SwipeSync` now implements two `PostTouchMove` calls with sleeps but still takes a `durationMillis` parameter that no longer represents a swipe duration as before—consider renaming the function or parameter, or updating its behavior, so its semantics remain intuitive for callers.

## Individual Comments

### Comment 1
<location path="agent/go-service/map-tracker/move.go" line_range="236-239" />
<code_context>
-					if movement.Speed < MovementSprint.Speed {
-						aw.KeyTypeSync(KEY_SHIFT, 100)
-						movement = &MovementSprint
+			// Update adaptive rotation speed
+			if rotAdjState != nil {
+				// Check if last rotation adjustment is completed
+				if loopStartTime.Sub(rotAdjState.startTime) > rotAdjState.expectedElapsed {
+					// Check if player is moving and rotating sufficiently to trust rotation measurement
+					distTravel := math.Hypot(float64(curX-rotAdjState.fromPos[0]), float64(curY-rotAdjState.fromPos[1]))
</code_context>
<issue_to_address>
**issue (bug_risk):** Rotation adjustment state is never cleared after use, so the same measurement may be reused and applied repeatedly.

Because `rotAdjState` remains non-nil and unchanged after the elapsed-time check and adaptive update, the same `fromPos/fromRot/deltaRot/startTime/expectedElapsed` are re-applied on every subsequent loop. This turns a single adjustment into a repeated influence on `rotationSpeed`.

If each adjustment is meant to be one-shot, clear the state once it’s used (e.g. `rotAdjState = nil`) or update fields like `startTime`/`fromPos` so the measurement is not reused unchanged.
</issue_to_address>

### Comment 2
<location path="agent/go-service/map-tracker/move.go" line_range="243-245" />
<code_context>
+					// Check if player is moving and rotating sufficiently to trust rotation measurement
+					distTravel := math.Hypot(float64(curX-rotAdjState.fromPos[0]), float64(curY-rotAdjState.fromPos[1]))
+					if distTravel > rotAdjState.expectedElapsed.Seconds()*MovementWalk.Speed {
+						// Check if rotation difference is sufficient to consider adjusting rotation speed
+						actualDeltaRot := calcDeltaRotation(rotAdjState.fromRot, rot)
+						if float64(actualDeltaRot)+rotAdjState.deltaRot > param.RotationLowerThreshold {
+							idealRotSpeed := rotAdjState.deltaRot / (float64(actualDeltaRot) + 1e-6)
+							if idealRotSpeed >= ROTATION_MIN_SPEED && idealRotSpeed <= ROTATION_MAX_SPEED {
</code_context>
<issue_to_address>
**issue (bug_risk):** Rotation threshold check mixes signed deltas and may never trigger for certain directions.

`actualDeltaRot` and `rotAdjState.deltaRot` are signed, but their sum is compared to a positive `RotationLowerThreshold`. When one or both are negative, the sum can stay below the threshold even for large actual rotation, so the check may never pass for some directions. If the intent is to gate on rotation *magnitude*, this should use an absolute value (e.g., `math.Abs(...)`) rather than a signed sum, otherwise the adaptive update is biased to particular sign combinations.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • The new adaptive rotation update condition if float64(actualDeltaRot)+rotAdjState.deltaRot > param.RotationLowerThreshold mixes signed deltas; consider using absolute values (e.g. math.Abs) or a clearer metric so that opposite‑direction rotations don't accidentally suppress or exaggerate the adjustment.
  • ROTATION_ADJUSTMENT_LOWER_BOUND is no longer used after removing calcAppliedDeltaRotation; consider deleting this constant to avoid confusion about dead configuration knobs.
  • SwipeSync now implements two PostTouchMove calls with sleeps but still takes a durationMillis parameter that no longer represents a swipe duration as before—consider renaming the function or parameter, or updating its behavior, so its semantics remain intuitive for callers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new adaptive rotation update condition `if float64(actualDeltaRot)+rotAdjState.deltaRot > param.RotationLowerThreshold` mixes signed deltas; consider using absolute values (e.g. `math.Abs`) or a clearer metric so that opposite‑direction rotations don't accidentally suppress or exaggerate the adjustment.
- `ROTATION_ADJUSTMENT_LOWER_BOUND` is no longer used after removing `calcAppliedDeltaRotation`; consider deleting this constant to avoid confusion about dead configuration knobs.
- `SwipeSync` now implements two `PostTouchMove` calls with sleeps but still takes a `durationMillis` parameter that no longer represents a swipe duration as before—consider renaming the function or parameter, or updating its behavior, so its semantics remain intuitive for callers.

## Individual Comments

### Comment 1
<location path="agent/go-service/map-tracker/move.go" line_range="236-239" />
<code_context>
-					if movement.Speed < MovementSprint.Speed {
-						aw.KeyTypeSync(KEY_SHIFT, 100)
-						movement = &MovementSprint
+			// Update adaptive rotation speed
+			if rotAdjState != nil {
+				// Check if last rotation adjustment is completed
+				if loopStartTime.Sub(rotAdjState.startTime) > rotAdjState.expectedElapsed {
+					// Check if player is moving and rotating sufficiently to trust rotation measurement
+					distTravel := math.Hypot(float64(curX-rotAdjState.fromPos[0]), float64(curY-rotAdjState.fromPos[1]))
</code_context>
<issue_to_address>
**issue (bug_risk):** Rotation adjustment state is never cleared after use, so the same measurement may be reused and applied repeatedly.

Because `rotAdjState` remains non-nil and unchanged after the elapsed-time check and adaptive update, the same `fromPos/fromRot/deltaRot/startTime/expectedElapsed` are re-applied on every subsequent loop. This turns a single adjustment into a repeated influence on `rotationSpeed`.

If each adjustment is meant to be one-shot, clear the state once it’s used (e.g. `rotAdjState = nil`) or update fields like `startTime`/`fromPos` so the measurement is not reused unchanged.
</issue_to_address>

### Comment 2
<location path="agent/go-service/map-tracker/move.go" line_range="243-245" />
<code_context>
+					// Check if player is moving and rotating sufficiently to trust rotation measurement
+					distTravel := math.Hypot(float64(curX-rotAdjState.fromPos[0]), float64(curY-rotAdjState.fromPos[1]))
+					if distTravel > rotAdjState.expectedElapsed.Seconds()*MovementWalk.Speed {
+						// Check if rotation difference is sufficient to consider adjusting rotation speed
+						actualDeltaRot := calcDeltaRotation(rotAdjState.fromRot, rot)
+						if float64(actualDeltaRot)+rotAdjState.deltaRot > param.RotationLowerThreshold {
+							idealRotSpeed := rotAdjState.deltaRot / (float64(actualDeltaRot) + 1e-6)
+							if idealRotSpeed >= ROTATION_MIN_SPEED && idealRotSpeed <= ROTATION_MAX_SPEED {
</code_context>
<issue_to_address>
**issue (bug_risk):** Rotation threshold check mixes signed deltas and may never trigger for certain directions.

`actualDeltaRot` and `rotAdjState.deltaRot` are signed, but their sum is compared to a positive `RotationLowerThreshold`. When one or both are negative, the sum can stay below the threshold even for large actual rotation, so the check may never pass for some directions. If the intent is to gate on rotation *magnitude*, this should use an absolute value (e.g., `math.Abs(...)`) rather than a signed sum, otherwise the adaptive update is biased to particular sign combinations.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@MistEO
Copy link
Contributor

MistEO commented Mar 7, 2026

你要不试试新的相对移动?

@dongwlin 帮忙适配下 go

@isHarryh
Copy link
Member Author

isHarryh commented Mar 7, 2026

你要不试试新的相对移动?

@dongwlin 帮忙适配下 go

感觉不用了,我这个滑动就四行代码。

// In agent\go-service\map-tracker\utils.go
func (aw *ActionWrapper) SwipeSync(x, y, dx, dy int, durationMillis, delayMillis int) {
	aw.ctrl.PostTouchMove(0, int32(x), int32(y), 0).Wait()
	time.Sleep(time.Duration(durationMillis) * time.Millisecond)
	aw.ctrl.PostTouchMove(0, int32(x+dx), int32(y+dy), 0).Wait()
	time.Sleep(time.Duration(delayMillis) * time.Millisecond)
}

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

此 PR 旨在提升 MapTrackerMove 的转向效率:将原先基于 RunAction Swipe 的视角滑动替换为更直接的 TouchMove(鼠标移动/hover)方式,并配套调整转向策略与默认参数,以匹配更快的转向节奏。

Changes:

  • MapTrackerMove:重构转向/冲刺策略,并引入新的“转向调整状态”以做自适应转向速度估计
  • MapTracker:更新默认移动参数(到达阈值、冲刺阈值、转向速度相关常量)并同步中英文文档
  • Map Tracker Editor:调整绘制参数与录制路径简化逻辑

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/map_tracker/map_tracker_editor.py 调整编辑器绘制参数,并更新录制路径的简化判定逻辑
docs/zh_cn/developers/map-tracker.md 同步 MapTrackerMove 默认参数变更(arrival/sprint 阈值)
docs/en_us/developers/map-tracker.md 同步 MapTrackerMove 默认参数变更(arrival/sprint 阈值)
agent/go-service/map-tracker/utils.go SwipeSync 改为基于 PostTouchMove 的快速视角移动实现
agent/go-service/map-tracker/move.go 重构转向控制与自适应转向速度更新逻辑
agent/go-service/map-tracker/const.go 调整转向速度常量与默认移动参数

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@isHarryh isHarryh merged commit 2a17b74 into MaaEnd:main Mar 7, 2026
20 checks passed
MistEO pushed a commit that referenced this pull request Mar 9, 2026
## 概要

此 PR 从 MapTrackerMove 节点中移除了基于 RunAction Swipe 的视角滑动方法,转而使用更快速的
TouchMove 实现,极大提升了转向速度。

此外,调整了部分转向策略和默认参数,使之适配此项更改。

## Summary by Sourcery

改进地图追踪器的移动旋转处理和路径工具,以实现更快速、更精确的导航。

New Features:
- 引入一个旋转调整状态,用于根据最近的移动和朝向变化来追踪并调整相机旋转速度。
- 添加几何路径简化启发式算法,以减少地图追踪器编辑器中多余的记录路径点。

Bug Fixes:
- 用更快速的触控移动实现替换原有的滑动式相机旋转,从而降低旋转延迟并减少过冲。

Enhancements:
- 重新调校移动速度/旋转参数以及疾跑/到达阈值,使其更好地匹配新的快速旋转行为。
- 优化启用疾跑的逻辑,在开始疾跑前需要更好的朝向对齐和更长的距离,以提升操控性。
- 调整编辑器中的线条样式和点大小,以获得更清晰的路径可视化效果。

Documentation:
- 更新中英文开发者文档,以反映新的到达和疾跑阈值默认值。

<details>
<summary>Original summary in English</summary>

## Summary by Sourcery

Improve map tracker movement rotation handling and path tooling for
faster, more precise navigation.

New Features:
- Introduce a rotation adjustment state to track and adapt camera
rotation speed based on recent movement and orientation changes.
- Add a geometric path simplification heuristic to reduce redundant
recorded waypoints in the map tracker editor.

Bug Fixes:
- Replace swipe-based camera rotation with a faster touch-move
implementation to reduce rotation latency and overshoot.

Enhancements:
- Retune movement speed/rotation parameters and sprint/arrival
thresholds to better match the new fast rotation behavior.
- Refine sprint enabling logic to require better orientation and longer
distance before sprinting, improving control.
- Adjust editor line styling and point sizes for clearer path
visualization.

Documentation:
- Update developer documentation in both English and Chinese to reflect
new arrival and sprint threshold defaults.

</details>
MistEO pushed a commit that referenced this pull request Mar 9, 2026
## 概要

此 PR 从 MapTrackerMove 节点中移除了基于 RunAction Swipe 的视角滑动方法,转而使用更快速的
TouchMove 实现,极大提升了转向速度。

此外,调整了部分转向策略和默认参数,使之适配此项更改。

## Summary by Sourcery

改进地图追踪器的移动旋转处理和路径工具,以实现更快速、更精确的导航。

New Features:
- 引入一个旋转调整状态,用于根据最近的移动和朝向变化来追踪并调整相机旋转速度。
- 添加几何路径简化启发式算法,以减少地图追踪器编辑器中多余的记录路径点。

Bug Fixes:
- 用更快速的触控移动实现替换原有的滑动式相机旋转,从而降低旋转延迟并减少过冲。

Enhancements:
- 重新调校移动速度/旋转参数以及疾跑/到达阈值,使其更好地匹配新的快速旋转行为。
- 优化启用疾跑的逻辑,在开始疾跑前需要更好的朝向对齐和更长的距离,以提升操控性。
- 调整编辑器中的线条样式和点大小,以获得更清晰的路径可视化效果。

Documentation:
- 更新中英文开发者文档,以反映新的到达和疾跑阈值默认值。

<details>
<summary>Original summary in English</summary>

## Summary by Sourcery

Improve map tracker movement rotation handling and path tooling for
faster, more precise navigation.

New Features:
- Introduce a rotation adjustment state to track and adapt camera
rotation speed based on recent movement and orientation changes.
- Add a geometric path simplification heuristic to reduce redundant
recorded waypoints in the map tracker editor.

Bug Fixes:
- Replace swipe-based camera rotation with a faster touch-move
implementation to reduce rotation latency and overshoot.

Enhancements:
- Retune movement speed/rotation parameters and sprint/arrival
thresholds to better match the new fast rotation behavior.
- Refine sprint enabling logic to require better orientation and longer
distance before sprinting, improving control.
- Adjust editor line styling and point sizes for clearer path
visualization.

Documentation:
- Update developer documentation in both English and Chinese to reflect
new arrival and sprint threshold defaults.

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants