Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquick3dparticlerepeller.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
7
23
31{
32 return m_radius;
33}
34
43{
44 return m_outerRadius;
45}
46
53{
54 return m_strength;
55}
56
58{
59 radius = qMax(0.0f, radius);
60 if (qFuzzyCompare(radius, m_radius)) return;
61
62 m_radius = radius;
64}
65
67{
68 radius = qMax(0.0f, radius);
69 if (qFuzzyCompare(radius, m_outerRadius)) return;
70
71 m_outerRadius = radius;
73}
74
76{
77 strength = qMax(0.0f, strength);
78 if (qFuzzyCompare(strength, m_strength)) return;
79
80 m_strength = strength;
82}
83
88
89static float qt_smoothstep(float edge0, float edge1, float x)
90{
91 float t;
92 t = qBound(0.0f, (x - edge0) / (edge1 - edge0), 1.0f);
93 return t * t * (3.0f - 2.0f * t);
94}
95
97{
99 QVector3D dir = d->position - pos;
100 float radius = dir.length();
101 float outerRadius = qMax(m_outerRadius, m_radius);
103 return;
104
105 if (radius < m_radius)
106 d->position += dir * m_strength / radius;
107 else
108 d->position += dir * m_strength * (1.0f - qt_smoothstep(m_radius, outerRadius, radius)) / radius;
109}
110
QVector3D position
QQuick3DParticleRepeller(QQuick3DNode *parent=nullptr)
\qmltype Repeller3D \inherits Affector3D \inqmlmodule QtQuick3D.Particles3D
void affectParticle(const QQuick3DParticleData &sd, QQuick3DParticleDataCurrent *d, float time) override
qsizetype length() const noexcept
Returns the number of characters in this string.
Definition qstring.h:191
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLint GLint GLint GLint x
[0]
GLdouble GLdouble t
Definition qopenglext.h:243
static float qt_smoothstep(float edge0, float edge1, float x)
#define Q_EMIT
QString dir
[11]