Skip to content

Commit

Permalink
Extend supported classes in vkb::scene_graph::HPPScene::get_component…
Browse files Browse the repository at this point in the history
…s and vkb::scene_graph::HPPScene::has_components (#1203)
  • Loading branch information
asuessenbach authored Nov 13, 2024
1 parent 5b2bc1e commit 76c3144
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions framework/scene_graph/hpp_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

#pragma once

#include "components/hpp_mesh.h"
#include "scene.h"
#include "scene_graph/components/camera.h"
#include "scene_graph/components/hpp_mesh.h"
#include "scene_graph/script.h"
#include "scene_graph/scripts/animation.h"

Expand All @@ -37,7 +38,8 @@ class HPPScene : private vkb::sg::Scene
template <class T>
std::vector<T *> get_components() const
{
if constexpr (std::is_same<T, vkb::sg::Script>::value)
if constexpr (std::is_same<T, vkb::sg::Animation>::value || std::is_same<T, vkb::sg::Camera>::value || std::is_same<T, vkb::sg::Script>::value ||
std::is_same<T, vkb::sg::SubMesh>::value || std::is_same<T, vkb::sg::Texture>::value)
{
return vkb::sg::Scene::get_components<T>();
}
Expand All @@ -56,10 +58,15 @@ class HPPScene : private vkb::sg::Scene
template <class T>
bool has_component() const
{
if constexpr (std::is_same<T, vkb::sg::Animation>::value || std::is_same<T, vkb::sg::Script>::value)
if constexpr (std::is_same<T, vkb::sg::Animation>::value || std::is_same<T, vkb::sg::Camera>::value || std::is_same<T, vkb::sg::Script>::value ||
std::is_same<T, vkb::sg::SubMesh>::value || std::is_same<T, vkb::sg::Texture>::value)
{
return vkb::sg::Scene::has_component(typeid(T));
}
else if constexpr (std::is_same<T, vkb::scene_graph::components::HPPMesh>::value)
{
return vkb::sg::Scene::has_component<vkb::sg::Mesh>();
}
else
{
assert(false); // path never passed -> Please add a type-check here!
Expand Down

0 comments on commit 76c3144

Please sign in to comment.