• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PLUGIN_API_RENDER_DATA_STORE_DEFAULT_DOTFIELD_H
17 #define PLUGIN_API_RENDER_DATA_STORE_DEFAULT_DOTFIELD_H
18 
19 #include <cstdint>
20 
21 #include <base/containers/array_view.h>
22 #include <base/containers/vector.h>
23 #include <base/math/matrix.h>
24 #include <base/math/vector.h>
25 #include <core/ecs/entity.h>
26 #include <render/datastore/intf_render_data_store.h>
27 #include <render/namespace.h>
28 #include <render/render_data_structures.h>
29 
30 namespace RENDER_NS {
31 class IGpuResourceManager;
32 class IShaderManager;
33 } // namespace RENDER_NS
34 
35 namespace Dotfield {
36 struct RenderDataDefaultDotfield {
37     /* Buffering count, for easier management. */
38     static constexpr uint32_t DOTFIELD_BUFFERING_COUNT { 2u };
39 
40     /** Dotfield
41      */
42     struct DotfieldPrimitive {
43         CORE_NS::Entity entity {};
44 
45         BASE_NS::Math::Mat4X4 matrix { 1.f };
46         BASE_NS::Math::UVec2 size { 64u, 64u };
47         BASE_NS::Math::Vec2 touch { 0.0f, 0.0f };
48         BASE_NS::Math::Vec3 touchDirection { 0.0f, 0.0f, 0.0f };
49         BASE_NS::Math::UVec4 colors { 0u, 0u, 0u, 0u };
50         float pointScale { 60.f };
51         float touchRadius { 0.f };
52     };
53 
54     struct BufferData {
55         uint32_t currFrameIndex { 0u }; // 0 or 1 for double buffering
56 
57         struct Buffer {
58             // double buffering
59             RENDER_NS::RenderHandleReference dataBuffer[DOTFIELD_BUFFERING_COUNT]; // (packed) data
60         };
61         BASE_NS::vector<Buffer> buffers;
62     };
63 };
64 
65 /**
66 RenderDataStoreDefaultDotfield
67 
68 - Handles per frame particle primitives.
69 - Handles/Managers particle buffers and effects.
70 */
71 class IRenderDataStoreDefaultDotfield : public RENDER_NS::IRenderDataStore {
72 public:
73     static constexpr BASE_NS::Uid UID { "f01a1d5f-2bfa-4f46-892f-33eb0397a654" };
74 
75     virtual void AddDotfieldPrimitive(const RenderDataDefaultDotfield::DotfieldPrimitive& dotfieldPrimitive) = 0;
76     virtual void RemoveDotfieldPrimitive(const CORE_NS::Entity& entity) = 0;
77     virtual BASE_NS::array_view<RenderDataDefaultDotfield::DotfieldPrimitive> GetDotfieldPrimitives() = 0;
78     virtual BASE_NS::array_view<const RenderDataDefaultDotfield::DotfieldPrimitive> GetDotfieldPrimitives() const = 0;
79     virtual const RenderDataDefaultDotfield::BufferData& GetBufferData() const = 0;
80 
81     virtual float GetTimeStep() const noexcept = 0;
82     virtual void SetTimeStep(float time) noexcept = 0;
83     virtual float GetTime() const noexcept = 0;
84     virtual void SetTime(float time) noexcept = 0;
85 };
86 } // namespace Dotfield
87 
88 #endif // PLUGIN_API_RENDER_DATA_STORE_DEFAULT_DOTFIELD_H
89