Closed lcnr closed 4 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Feel free to comment if this is still relevant.
still relevant
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Feel free to comment if this is still relevant.
relevant
@lcnr I currently collect the JoinIter into a temporary Vec which does work
can you show how this solution works? I'm having difficulties with this trying to implement collisions system.
@SET001 Does the following work for you?
// by storing the join in a vec instead of using it directly we can use `Vec::iter`
// which does implement `Clone`.
let collision_entities = (&entities, &colliders, &transforms).join()
.into_iter().collect::<Vec<_>>();
let mut iter = collision_entities.iter();
while let Some(a) = iter.next() {
for b in iter.clone() // check all following entities {
if is_collision((a.1, a.2), (b.1, b.2)) {
self.collisions.push(Collision(a.0, b.0))
}
}
}
@lcnr yeah, thanx. This is much better than what I had:
let mut groupList:Vec<CompGroup> = Vec::new();
for(_collision, position, entitiy) in (&mut collisions, &positions, &entities).join() {
groupList.push(CompGroup{
entitiy,
position
})
}
Description
Implement
Clone
forJoinIter
when it is safe to do so.Motivation
I am currently trying to build a small collision system which simply checks for each entity pair if they collide,
JoinIter
implementedClone
I would be able to write it like this:I currently collect the
JoinIter
into a temporaryVec
which does work, even if it is somewhat unsatisfying. If there is a prettier solution, please tell me as I only recently started using specs/amethyst.Drawbacks
Is it a breaking change?
Can it impact performance, learnability, etc?
Unresolved questions
How can we detect that the
JoinIter
iterates over a mutable collection, in which caseClone
must not get implemented.I would gladly try to implement this if the unresolved question can be solved