rust-bevy-collision-broadphase

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rust Bevy Collision Broadphase

Rust Bevy 碰撞 Broadphase

Use this skill to make Bevy collision detection scale without mixing detection, response, rendering, and gameplay rules into one system.
使用此 skill 让 Bevy 碰撞检测具备可扩展性,同时避免将检测、响应、渲染和 gameplay 规则混入同一个系统。

Core Workflow

核心工作流

  1. Identify the collision shapes, movement model, entity counts, and layers.
  2. Keep collider data small and independent from sprites, textures, and game rules.
  3. Choose the cheapest broadphase that fits the scene: brute force for tiny counts, spatial hash for uniform worlds, quad tree for clustered worlds.
  4. Emit candidate or collision events; let separate systems decide response.
  5. Test edge contacts, fast movement, layer filters, despawn cases, and deterministic ordering.
  6. Benchmark before and after changing the broadphase.
  1. 确定碰撞形状、运动模型、实体数量和层级。
  2. 保持 collider 数据精简,并与 sprites、textures 和游戏规则解耦。
  3. 选择适合场景且成本最低的 broadphase:实体数量极少时使用 brute force,均匀场景使用 spatial hash,聚集场景使用 quad tree。
  4. 发出候选事件或碰撞事件;由独立系统决定响应。
  5. 测试边缘接触、高速运动、层级过滤、实体 despawn 情况以及确定性排序。
  6. 更改 broadphase 前后进行基准测试。

Read Next

接下来阅读

TaskLoad
Pick or review a broadphase
guidelines.md
,
references/broadphase-patterns.md
Optimize an existing collision system
workflows/optimize-collision.md
Route a specific symptom
guidelines.md
任务加载
选择或审查 broadphase
guidelines.md
,
references/broadphase-patterns.md
优化现有碰撞系统
workflows/optimize-collision.md
处理特定症状
guidelines.md

Source Notes

来源说明

Guidance is transformed and paraphrased from Herbert Wolverson, Advanced Hands-On Rust, especially Chapter 8 on obstacles and collision detection and Chapter 12 on optimization. The examples are original skeletons intended to preserve the transferable technique, not the book's project code.
相关指导经转述和改写,源自 Herbert Wolverson 的 Advanced Hands-On Rust,尤其是第 8 章关于障碍物与碰撞检测的内容,以及第 12 章关于优化的内容。示例是原创骨架,旨在保留可迁移的技术方法,而非书中的项目代码。