| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsCorePrerequisites.h" |
| 6 | #include "Reflection/BsRTTIType.h" |
| 7 | #include "Renderer/BsReflectionProbe.h" |
| 8 | #include "Renderer/BsRenderer.h" |
| 9 | |
| 10 | namespace bs |
| 11 | { |
| 12 | /** @cond RTTI */ |
| 13 | /** @addtogroup RTTI-Impl-Engine |
| 14 | * @{ |
| 15 | */ |
| 16 | |
| 17 | class BS_CORE_EXPORT ReflectionProbeRTTI : public RTTIType <ReflectionProbe, IReflectable, ReflectionProbeRTTI> |
| 18 | { |
| 19 | private: |
| 20 | BS_BEGIN_RTTI_MEMBERS |
| 21 | BS_RTTI_MEMBER_REFL(mTransform, 0) |
| 22 | BS_RTTI_MEMBER_PLAIN(mActive, 1) |
| 23 | BS_RTTI_MEMBER_PLAIN(mMobility, 2) |
| 24 | BS_RTTI_MEMBER_PLAIN(mType, 3) |
| 25 | BS_RTTI_MEMBER_PLAIN(mRadius, 4) |
| 26 | BS_RTTI_MEMBER_PLAIN(mExtents, 5) |
| 27 | BS_RTTI_MEMBER_PLAIN(mTransitionDistance, 6) |
| 28 | BS_RTTI_MEMBER_REFL(mCustomTexture, 7) |
| 29 | BS_RTTI_MEMBER_REFLPTR(mFilteredTexture, 8) |
| 30 | BS_END_RTTI_MEMBERS |
| 31 | public: |
| 32 | void onSerializationStarted(IReflectable* obj, SerializationContext* context) override |
| 33 | { |
| 34 | ReflectionProbe* probe = static_cast<ReflectionProbe*>(obj); |
| 35 | |
| 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 | |
| 41 | void onDeserializationEnded(IReflectable* obj, SerializationContext* context) override |
| 42 | { |
| 43 | // Note: Since this is a CoreObject I should call initialize() right after deserialization, |
| 44 | // but since this specific type is used in Components we delay initialization until Component |
| 45 | // itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component |
| 46 | // purposes (you'll need to call initialize manually). |
| 47 | } |
| 48 | |
| 49 | const String& getRTTIName() override |
| 50 | { |
| 51 | static String name = "ReflectionProbe" ; |
| 52 | return name; |
| 53 | } |
| 54 | |
| 55 | UINT32 getRTTIId() override |
| 56 | { |
| 57 | return TID_ReflectionProbe; |
| 58 | } |
| 59 | |
| 60 | SPtr<IReflectable> newRTTIObject() override |
| 61 | { |
| 62 | return ReflectionProbe::createEmpty(); |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | /** @} */ |
| 67 | /** @endcond */ |
| 68 | } |
| 69 | |