feat: enhance scene graph with entity system improvements#7
Open
feat: enhance scene graph with entity system improvements#7
Conversation
…ndex, and traversal API Add four incremental enhancements to the Object+AbstractFeature scene graph: 1. O(1) feature lookup via type_index map in Object (dynamic_cast fallback for base-class queries) 2. Feature signals using palacaze/sigslot: on_feature_added/removing, on_child_added/removing on Object, and on_modified on AbstractFeature 3. Scene-level FeatureIndex that subscribes to signals and maintains a type->objects map for efficient "give me all objects with X" queries 4. Traversal API: for_each_descendant, for_each_ancestor, find_descendant with pruning support via bool return values Adds sigslot v1.2.3 as a wrap-git subproject with custom meson.build. All 8 test suites pass (23,717 assertions).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds four incremental enhancements to the visualization scene graph's Object+AbstractFeature pattern, improving query performance, enabling reactive updates, and providing convenient traversal utilities.
Changes
O(1 feature lookup —
Objectnow maintains anunordered_map<type_index, AbstractFeature*>alongside the existingvector<unique_ptr<AbstractFeature>>.find_feature<F>()checks the map first (exact type match), falling back todynamic_castscan for base-class queries (only 4 of 55 existing call sites need this).Feature signals — Adds
palacaze/sigslotv1.2.3 as a dependency. New signals:Object::on_feature_added(Object&, AbstractFeature&)Object::on_feature_removing(Object&, AbstractFeature&)Object::on_child_added(Object&, Object&)Object::on_child_removing(Object&, Object&)AbstractFeature::on_modified(AbstractFeature&)withmark_modified()helperScene-level
FeatureIndex— Subscribes to Object signals and maintains atype_index -> vector<Object*>index. Providesobjects_with<F>()(returnsspan) andcount<F>()for O(1) "give me all objects with MeshData" queries. Auto-tracks/untracks children as the scene graph changes.Traversal API — New methods on
Object:for_each_descendant(fn)— DFS pre-order; iffnreturnsbool,falseprunes subtreefor_each_ancestor(fn)— walks parent chain;falsestops earlyfind_descendant(pred)— returns first matchingObject*ornullptrTesting
test_scene_graph.cppcovering all four enhancementsDesign Notes
sigslot::signal_stis used for zero-overhead single-threaded operation.observer_stbase class provides automatic disconnect on destruction.