1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "updateshaderdatatransformjob_p.h" |
5 | #include <Qt3DRender/private/nodemanagers_p.h> |
6 | #include <Qt3DRender/private/entity_p.h> |
7 | #include <Qt3DRender/private/shaderdata_p.h> |
8 | #include <Qt3DRender/private/light_p.h> |
9 | #include <Qt3DRender/private/sphere_p.h> |
10 | #include <Qt3DRender/private/attribute_p.h> |
11 | #include <Qt3DRender/private/geometryrenderer_p.h> |
12 | #include <Qt3DRender/private/geometry_p.h> |
13 | #include <Qt3DRender/private/attribute_p.h> |
14 | #include <Qt3DRender/private/buffer_p.h> |
15 | #include <Qt3DRender/private/managers_p.h> |
16 | #include <Qt3DRender/private/buffermanager_p.h> |
17 | #include <Qt3DRender/private/geometryrenderermanager_p.h> |
18 | #include <Qt3DRender/private/job_common_p.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | namespace Qt3DRender { |
23 | namespace Render { |
24 | |
25 | UpdateShaderDataTransformJob::UpdateShaderDataTransformJob() |
26 | : m_manager(nullptr) |
27 | { |
28 | SET_JOB_RUN_STAT_TYPE(this, JobTypes::UpdateShaderDataTransform, 0) |
29 | } |
30 | |
31 | UpdateShaderDataTransformJob::~UpdateShaderDataTransformJob() |
32 | { |
33 | } |
34 | |
35 | void UpdateShaderDataTransformJob::setManagers(NodeManagers *manager) |
36 | { |
37 | m_manager = manager; |
38 | } |
39 | |
40 | NodeManagers *UpdateShaderDataTransformJob::managers() const |
41 | { |
42 | return m_manager; |
43 | } |
44 | |
45 | void UpdateShaderDataTransformJob::run() |
46 | { |
47 | EntityManager *manager = m_manager->renderNodesManager(); |
48 | const std::vector<HEntity> &handles = manager->activeHandles(); |
49 | |
50 | for (const HEntity &handle : handles) { |
51 | Entity *node = manager->data(handle); |
52 | // Update transform properties in ShaderDatas and Lights |
53 | const std::vector<ShaderData *> &shaderDatas = node->renderComponents<ShaderData>(); |
54 | for (ShaderData *r : shaderDatas) |
55 | r->updateWorldTransform(worldMatrix: *node->worldTransform()); |
56 | } |
57 | } |
58 | |
59 | } // namespace Render |
60 | } // namespace Qt3DRender |
61 | |
62 | QT_END_NAMESPACE |
63 |