Skip to content

Commit

Permalink
Rename Mask.set(Mask/long[]) to copyFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Gustafsson committed Jul 13, 2016
1 parent c874a66 commit 02cf8a7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Introduced `BooleanBag`
- Introduced `CharBag`
- Removed `Mapper.add(int, Component)`, `create` should be used instead
- `Mask.set(Mask/long[])` renamed to `copyFrom`
- Fix: `ByteBag` implements `ensureCapacity(int)`
- Fix: `Bag.ensureCapacity(int)` throws `NegativeArraySizeException` if `capacity` is negative.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ private void flush() {
while (dirty) {
dirty = false;

entityManager.remove.set(entityManager.removeQueue);
entityManager.remove.copyFrom(entityManager.removeQueue);
entityManager.removeQueue.clear();

for (Mapper<?> mapper : componentManager.array) {
mapper.removeMask.set(mapper.removeQueueMask);
mapper.removeMask.copyFrom(mapper.removeQueueMask);
mapper.removeMask.or(entityManager.remove);
mapper.removeQueueMask.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Family getFamily(FamilyConfig config) {

// Find matching entities, and add them to the new family set.
Mapper<?>[] mappers = engine.componentManager.array;
Mask matchedEntities = new Mask().set(engine.entityManager.entities);
Mask matchedEntities = new Mask().copyFrom(engine.entityManager.entities);

for (int component : components) {
matchedEntities.and(mappers[component].componentsMask);
Expand Down Expand Up @@ -130,30 +130,30 @@ void updateFamilyMembership() {
Family family = families.get(i);
EntitySet entities = family.entities;

Mask matchedEntities = tmpMatchedEntities.set(engine.entityManager.entities);
Mask matchedEntities = tmpMatchedEntities.copyFrom(engine.entityManager.entities);
matchedEntities.andNot(engine.entityManager.remove);

int[] components = family.components;
for (int component : components) {
Mapper<?> mapper = mappers[component];
tmpMask.set(mapper.componentsMask);
tmpMask.copyFrom(mapper.componentsMask);
tmpMask.andNot(mapper.removeMask);
matchedEntities.and(tmpMask);
}

int[] excludedComponents = family.excludedComponents;
for (int excludedComponent : excludedComponents) {
Mapper<?> mapper = mappers[excludedComponent];
tmpMask.set(mapper.componentsMask);
tmpMask.copyFrom(mapper.componentsMask);
tmpMask.andNot(mapper.removeMask);
matchedEntities.andNot(tmpMask);
}

family.insertEntities.set(matchedEntities);
family.insertEntities.copyFrom(matchedEntities);
family.insertEntities.andNot(entities.getMask());
entities.edit().addEntities(family.insertEntities);

family.removeEntities.set(entities.getMask());
family.removeEntities.copyFrom(entities.getMask());
family.removeEntities.andNot(matchedEntities);
entities.edit().removeEntities(family.removeEntities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public Mask() {
* @param other The value to set.
* @return {@code this} mask instance
*/
public Mask set(Mask other) {
return set(other.words);
public Mask copyFrom(Mask other) {
return copyFrom(other.words);
}

public Mask set(long[] otherWords) {
public Mask copyFrom(long[] otherWords) {
if (words.length < otherWords.length) {
words = new long[otherWords.length];
}
Expand Down

0 comments on commit 02cf8a7

Please sign in to comment.