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 CORE_ECS_LOCALMATRIXSYSTEM_H
17 #define CORE_ECS_LOCALMATRIXSYSTEM_H
18 
19 #include <ComponentTools/component_query.h>
20 
21 #include <3d/namespace.h>
22 #include <core/ecs/intf_system.h>
23 #include <core/namespace.h>
24 
25 CORE_BEGIN_NAMESPACE()
26 class IEcs;
27 CORE_END_NAMESPACE()
28 
29 CORE3D_BEGIN_NAMESPACE()
30 class ILocalMatrixComponentManager;
31 class ITransformComponentManager;
32 
33 class LocalMatrixSystem final : public CORE_NS::ISystem {
34 public:
35     static constexpr BASE_NS::Uid UID { "4de00235-c9cd-44d0-94ef-2ef9bbffa088" };
36 
37     explicit LocalMatrixSystem(CORE_NS::IEcs& ecs);
38     ~LocalMatrixSystem() override = default;
39 
40     BASE_NS::string_view GetName() const override;
41     BASE_NS::Uid GetUid() const override;
42 
43     CORE_NS::IPropertyHandle* GetProperties() override;
44     const CORE_NS::IPropertyHandle* GetProperties() const override;
45     void SetProperties(const CORE_NS::IPropertyHandle&) override;
46 
47     bool IsActive() const override;
48     void SetActive(bool state) override;
49 
50     void Initialize() override;
51     bool Update(bool frameRenderingQueued, uint64_t time, uint64_t delta) override;
52     void Uninitialize() override;
53 
54     const CORE_NS::IEcs& GetECS() const override;
55 
56 private:
57     bool active_;
58     CORE_NS::IEcs& ecs_;
59 
60     ILocalMatrixComponentManager* localMatrixManager_ { nullptr };
61     ITransformComponentManager* transformManager_ { nullptr };
62 
63     uint32_t transformGeneration_ = 0;
64     BASE_NS::vector<uint32_t> transformComponentGenerations_;
65 
66     CORE_NS::ComponentQuery componentQuery_;
67 };
68 
GetName(const LocalMatrixSystem *)69 inline constexpr BASE_NS::string_view GetName(const LocalMatrixSystem*)
70 {
71     return "LocalMatrixSystem";
72 }
73 CORE3D_END_NAMESPACE()
74 
75 #endif // CORE_ECS_LOCALMATRIXSYSTEM_H
76