BsCLightProbeVolume.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Components/BsCLightProbeVolume.h"
  4. #include "Private/RTTI/BsCLightProbeVolumeRTTI.h"
  5. #include "Scene/BsSceneManager.h"
  6. namespace bs
  7. {
  8. CLightProbeVolume::CLightProbeVolume()
  9. {
  10. setFlag(ComponentFlag::AlwaysRun, true);
  11. setName("LightProbeVolume");
  12. }
  13. CLightProbeVolume::CLightProbeVolume(const HSceneObject& parent, const AABox& volume, const Vector3I& cellCount)
  14. :Component(parent), mVolume(volume), mCellCount(cellCount)
  15. {
  16. setFlag(ComponentFlag::AlwaysRun, true);
  17. setName("LightProbeVolume");
  18. }
  19. CLightProbeVolume::~CLightProbeVolume()
  20. {
  21. if(mInternal != nullptr)
  22. mInternal->destroy();
  23. }
  24. void CLightProbeVolume::renderProbe(UINT32 handle)
  25. {
  26. if (mInternal != nullptr && SO()->getActive())
  27. {
  28. mInternal->_updateState(*SO());
  29. mInternal->renderProbe(handle);
  30. }
  31. }
  32. void CLightProbeVolume::renderProbes()
  33. {
  34. if (mInternal != nullptr && SO()->getActive())
  35. {
  36. mInternal->_updateState(*SO());
  37. mInternal->renderProbes();
  38. }
  39. }
  40. Vector<LightProbeInfo> CLightProbeVolume::getProbes() const
  41. {
  42. if (mInternal != nullptr)
  43. return mInternal->getProbes();
  44. return Vector<LightProbeInfo>();
  45. }
  46. void CLightProbeVolume::onInitialized()
  47. {
  48. // If mInternal already exists this means this object was deserialized,
  49. // so all we need to do is initialize it.
  50. if (mInternal != nullptr)
  51. mInternal->initialize();
  52. else
  53. mInternal = LightProbeVolume::create(mVolume, mCellCount);
  54. gSceneManager()._bindActor(mInternal, sceneObject());
  55. }
  56. void CLightProbeVolume::onDestroyed()
  57. {
  58. gSceneManager()._unbindActor(mInternal);
  59. }
  60. RTTITypeBase* CLightProbeVolume::getRTTIStatic()
  61. {
  62. return CLightProbeVolumeRTTI::instance();
  63. }
  64. RTTITypeBase* CLightProbeVolume::getRTTI() const
  65. {
  66. return CLightProbeVolume::getRTTIStatic();
  67. }
  68. }