Renderable.cpp 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "anki/scene/Renderable.h"
  2. #include "anki/resource/Material.h"
  3. #include "anki/resource/Texture.h"
  4. #include <boost/foreach.hpp>
  5. namespace anki {
  6. struct XXXVisitor: boost::static_visitor<void>
  7. {
  8. const MaterialVariable* mvar;
  9. PropertyMap* pmap;
  10. XXXVisitor(const MaterialVariable* mvar_, PropertyMap* pmap_)
  11. : mvar(mvar_), pmap(pmap_)
  12. {}
  13. template<typename T>
  14. void operator()(const T& x) const
  15. {
  16. MaterialVariableReadCowPointerProperty<T>* prop =
  17. new MaterialVariableReadCowPointerProperty<T>(
  18. mvar->getName().c_str(), &(mvar->getValue<T>()));
  19. pmap->addNewProperty(prop);
  20. }
  21. };
  22. //==============================================================================
  23. void Renderable::init(PropertyMap& pmap) const
  24. {
  25. const Material& mtl = getMaterial();
  26. BOOST_FOREACH(const MaterialVariable& mv, mtl.getVariables())
  27. {
  28. boost::apply_visitor(XXXVisitor(&mv, &pmap), mv.getVariant());
  29. }
  30. }
  31. } // namespace anki