BsReflectionProbeRTTI.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsRTTIType.h"
  6. #include "BsReflectionProbe.h"
  7. #include "BsRenderer.h"
  8. namespace bs
  9. {
  10. /** @cond RTTI */
  11. /** @addtogroup RTTI-Impl-Engine
  12. * @{
  13. */
  14. class BS_CORE_EXPORT ReflectionProbeRTTI : public RTTIType <ReflectionProbe, IReflectable, ReflectionProbeRTTI>
  15. {
  16. private:
  17. BS_BEGIN_RTTI_MEMBERS
  18. BS_RTTI_MEMBER_PLAIN(mPosition, 0)
  19. BS_RTTI_MEMBER_PLAIN(mRotation, 1)
  20. BS_RTTI_MEMBER_PLAIN(mScale, 2)
  21. BS_RTTI_MEMBER_PLAIN(mType, 3)
  22. BS_RTTI_MEMBER_PLAIN(mRadius, 4)
  23. BS_RTTI_MEMBER_PLAIN(mExtents, 5)
  24. BS_RTTI_MEMBER_PLAIN(mTransitionDistance, 6)
  25. BS_RTTI_MEMBER_REFL(mCustomTexture, 7)
  26. BS_RTTI_MEMBER_PLAIN(mUUID, 8)
  27. BS_RTTI_MEMBER_REFLPTR(mFilteredTexture, 9)
  28. BS_END_RTTI_MEMBERS
  29. public:
  30. ReflectionProbeRTTI()
  31. :mInitMembers(this)
  32. { }
  33. void onSerializationStarted(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override
  34. {
  35. ReflectionProbe* probe = static_cast<ReflectionProbe*>(obj);
  36. // Force the renderer task to complete, so the filtered texture is up to date
  37. if (probe->mRendererTask != nullptr)
  38. probe->mRendererTask->wait();
  39. }
  40. void onDeserializationEnded(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override
  41. {
  42. // Note: Since this is a CoreObject I should call initialize() right after deserialization,
  43. // but since this specific type is used in Components we delay initialization until Component
  44. // itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component
  45. // purposes (you'll need to call initialize manually).
  46. }
  47. const String& getRTTIName() override
  48. {
  49. static String name = "ReflectionProbe";
  50. return name;
  51. }
  52. UINT32 getRTTIId() override
  53. {
  54. return TID_ReflectionProbe;
  55. }
  56. SPtr<IReflectable> newRTTIObject() override
  57. {
  58. return ReflectionProbe::createEmpty();
  59. }
  60. };
  61. /** @} */
  62. /** @endcond */
  63. }