X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=libs%2Fscenelib.h;h=9a5c0559f0d8d9e11a0e62f825ecc6352805b196;hb=06eb8cc3a4046af318da7f7b9fae1c04be8c0380;hp=a5be241398ba929b0ad7bfbc7d37dcff7e7b77fa;hpb=d617f066bc8f3b5a852859e7d4be3a29bca69b89;p=xonotic%2Fnetradiant.git diff --git a/libs/scenelib.h b/libs/scenelib.h index a5be2413..9a5c0559 100644 --- a/libs/scenelib.h +++ b/libs/scenelib.h @@ -365,6 +365,32 @@ inline bool Node_isEntity(scene::Node& node) return NodeTypeCast::cast(node) != 0; } +template +class EntityWalker : public scene::Graph::Walker +{ + const Functor& functor; +public: + EntityWalker(const Functor& functor) : functor(functor) + { + } + bool pre(const scene::Path& path, scene::Instance& instance) const + { + if(Node_isEntity(path.top())) + { + functor(instance); + return false; + } + return true; + } +}; + +template +inline const Functor& Scene_forEachEntity(const Functor& functor) +{ + GlobalSceneGraph().traverse(EntityWalker(functor)); + return functor; +} + class BrushUndefined { public: