amethyst / amethyst/legion

Multiple views for disjoint components in a System

未关闭
#67 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
1.7k
派生
140
PR 合并指标
30 天内没有已合并 PR

描述

Hi, I'm trying to integrate legion with nphysics. Right now what I have involves writing wrappers around legion's Query/SubWorld so nphysics can query for a specific Body, or run a function on every Body in the world.

let physics_system = SystemBuilder::new("physics")
.with_query(nphysics_legion::create_legion_body_set_write_query())
.with_query(nphysics_legion::create_legion_body_set_read_query())
.with_query(nphysics_legion::create_legion_collider_set_write_query())
.with_query(nphysics_legion::create_legion_collider_set_read_query())
.write_resource::()
.build(move |_, world, resource, queries| {
let mut bodies = nphysics_legion::SpecsBodySet::new(world, &queries.0, &queries.1);
let mut colliders =
nphysics_legion::SpecsColliderSet::new(world, &queries.2, &queries.3);
resource.step(&mut bodies, &mut colliders);
});

The problem with this is that nphysics expects the bodies and colliders (and other components) to be separate. The reason for this is given in https://github.com/rustsim/nphysics/issues/233#issuecomment-536926297, which I think is reasonable. But this causes lifetime issues since I have two wrappers both wanting the same `&mut SubWorld`.

Does it make sense for legion to have some sort of way to express disjoint "SubWorlds" in a query? Maybe somehow make it possible for `.build()` to have multiple SubWorlds?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。