File: rhirenderingextensions.h

package info (click to toggle)
qt6-quick3d 6.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 140,860 kB
  • sloc: cpp: 380,464; ansic: 36,078; xml: 252; sh: 241; makefile: 29
file content (96 lines) | stat: -rw-r--r-- 2,306 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef RHIRENDERINGEXTENSIONS_H
#define RHIRENDERINGEXTENSIONS_H

#include <QtQuick3D/qquick3drenderextensions.h>
#include <QtQmlIntegration>
#include <rhi/qrhi.h>

class ConsumerRenderer;
class ProducerExtension;

class MyExtension : public QQuick3DRenderExtension
{
    Q_OBJECT
    QML_ELEMENT

    Q_PROPERTY(float x READ x WRITE setX NOTIFY xChanged)
    Q_PROPERTY(float y READ y WRITE setY NOTIFY yChanged)
    Q_PROPERTY(float z READ z WRITE setZ NOTIFY zChanged)

    Q_PROPERTY(float subSceneRotation READ subSceneRotation WRITE setSubSceneRotation NOTIFY subSceneRotationChanged)

public:
    MyExtension(QQuick3DObject *parent = nullptr);

    float x() const { return m_x; }
    void setX(float value)
    {
        if (m_x != value) {
            m_x = value;
            emit xChanged();
            markDirty(PositionDirty);
        }
    }

    float y() const { return m_y; }
    void setY(float value)
    {
        if (m_y != value) {
            m_y = value;
            emit yChanged();
            markDirty(PositionDirty);
        }
    }

    float z() const { return m_z; }
    void setZ(float value)
    {
        if (m_z != value) {
            m_z = value;
            emit zChanged();
            markDirty(PositionDirty);
        }
    }

    float subSceneRotation() const { return m_subSceneRotation; }
    void setSubSceneRotation(float value)
    {
        if (m_subSceneRotation != value) {
            m_subSceneRotation = value;
            emit subSceneRotationChanged();
            markDirty(SubSceneRotationDirty);
        }
    }

signals:
    void xChanged();
    void yChanged();
    void zChanged();
    void subSceneRotationChanged();

protected:
    QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;

private:
    enum Dirty : quint8
    {
        PositionDirty = 1 << 0,
        SubSceneRotationDirty = 1 << 1
    };
    using DirtyT = std::underlying_type_t<Dirty>;
    void markDirty(Dirty v);
    DirtyT m_dirtyFlag = 0;

    float m_x = 0.0f;
    float m_y = 0.0f;
    float m_z = 0.0f;

    float m_subSceneRotation = 0.0f;

    ProducerExtension *m_producer = nullptr;
};

#endif // RHIRENDERINGEXTENSIONS_H