blob: 3b928be8864947fbad344511a2763a7917155514 (
plain)
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
|
// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "axis_p.h"
#include <Qt3DInput/qaxis.h>
#include <Qt3DInput/qabstractaxisinput.h>
#include <Qt3DInput/private/qaxis_p.h>
#include <algorithm>
QT_BEGIN_NAMESPACE
namespace Qt3DInput {
namespace Input {
Axis::Axis()
: BackendNode(ReadWrite)
, m_axisValue(0.0f)
{
}
void Axis::cleanup()
{
QBackendNode::setEnabled(false);
m_inputs.clear();
m_axisValue = 0.0f;
}
void Axis::setAxisValue(float axisValue)
{
if (isEnabled() && (!qFuzzyCompare(axisValue, m_axisValue)))
m_axisValue = axisValue;
}
void Axis::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
BackendNode::syncFromFrontEnd(frontEnd, firstTime);
const Qt3DInput::QAxis *node = qobject_cast<const Qt3DInput::QAxis *>(frontEnd);
if (!node)
return;
auto ids = Qt3DCore::qIdsForNodes(node->inputs());
m_inputs = ids;
}
} // namespace Input
} // namespace Qt3DInput
QT_END_NAMESPACE
|