Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index intermediate classes of GameObjects, try two #3009

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

mstoeckl
Copy link
Contributor

@mstoeckl mstoeckl commented Jul 9, 2024

See #2991 for details; in short, this significantly speeds up GameObjectManager::get_objects_by_type() and GameObjectManager::get_object_count(), by no longer scanning over unrelated object types.

However, the first version had an issue with disappearing objects with paths when a level was being tested from the level editor (#3008). I believe it was caused by the PathObject base class not being recorded in GameObject::get_class_types implementations. I've updated the code to do this (and also record the other intermediate classes, TriggerBase and CollisionListener, even though those are not currently searched for.) I was able to reproduce #3008 with the old version and no longer see it with the new.

Copy link
Member

@tobbi tobbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look through the list of all classes to see if all are accounted for, but code-wise this looks good.

This allows for much more efficient implementations of GameObjectManager's
get_object_count and get_objects_by_type. Now, for example, counting all
BadGuy objects does not require scanning through all the unrelated objects.

Also, GameObjectIterator<T> can now be simplified, as it is only used on
vectors which contain only objects with T as a base class.
@mstoeckl
Copy link
Contributor Author

mstoeckl commented Jul 10, 2024

I've updated this PR to account for the new Boss and BigSnowball classes, implementing get_class_types for each and adjusting Yeti/GhostTree for their changed base class.

Copy link
Member

@weluvgoatz weluvgoatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, looks good!

Copy link
Member

@tobbi tobbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested this, but looks good, code-wise.

@tobbi
Copy link
Member

tobbi commented Jul 21, 2024

@Vankata453 Can you merge this, please?

@Vankata453 Vankata453 merged commit d6d8b22 into SuperTux:master Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants