Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Ski committed Oct 15, 2024
1 parent 4a5290d commit 23fdf67
Showing 1 changed file with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,66 @@ public Array<GameObject> getChildrenWithBoneComponent () {
boneChildren = new Array<>();
}

getChildrenByComponent(BoneComponent.class, boneChildren);
getChildrenByComponentFaster(BoneComponent.class, boneChildren);

//Remove all of those that dont have a visible child that is interesting

for (int i = boneChildren.size - 1; i >= 0; i--) {
GameObject boneChildGO = boneChildren.get(i);

int amountOfChildren = boneChildGO.getGameObjects().size;

if (amountOfChildren == 0) {
boneChildren.removeIndex(i);
continue;
}

if (amountOfChildren == 1) {
GameObject child = boneChildGO.getGameObjects().get(0);
//if it has a bone, we remove it, we do not care about single bone childs
if (child.hasComponent(BoneComponent.class)) {
boneChildren.removeIndex(i);
continue;
}
}

//otherwise iterate over all of these little fuckers and see if anyone has a child that isnt a single bone boi
Array<GameObject> potentialInterestingGameObjects = boneChildGO.getGameObjects();

boolean foundInteresting = false;
for (GameObject potentialInterestingGameObject : potentialInterestingGameObjects) {
if (!potentialInterestingGameObject.hasComponent(BoneComponent.class)) {
if (potentialInterestingGameObject.active) {
foundInteresting = true;
}
break;
}
}
if (!foundInteresting) {
boneChildren.removeIndex(i);
}

}


calculatedBoneChildren = true;
}

return boneChildren;
}

public Array<GameObject> getChildrenByComponentFaster (Class<?> clazz, Array<GameObject> list) {
for(GameObject gameObject: children) {
if(gameObject.hasComponent(clazz)) {
list.add(gameObject);
}
if(gameObject.getGameObjects() != null && gameObject.getGameObjects().size > 0) {
gameObject.getChildrenByComponentFaster(clazz, list);
}
}

return list;
}

public Array<GameObject> getChildrenByComponent (Class<?> clazz, Array<GameObject> list) {
for(GameObject gameObject: children) {
Expand Down

0 comments on commit 23fdf67

Please sign in to comment.