7#include <QtQuick3D/private/qquick3dobject_p.h>
9#include <QtQuick3DUtils/private/qssgutils_p.h>
42 for (
const auto &
connection : std::as_const(m_connections))
47 qmlClearLights(&lightList);
53 value.particleUpdateNode->m_particle =
nullptr;
54 delete value.particleUpdateNode;
149 return m_particleScale;
181 QQuick3DParticleSpriteParticle::qmlAppendLight,
182 QQuick3DParticleSpriteParticle::qmlLightsCount,
183 QQuick3DParticleSpriteParticle::qmlLightAt,
184 QQuick3DParticleSpriteParticle::qmlClearLights);
218 return m_castsReflections;
248 updateFeatureLevel();
266 m_particleScale =
scale;
279 updateFeatureLevel();
290 emit offsetXChanged();
299 emit offsetYChanged();
302void QQuick3DParticleSpriteParticle::setCastsReflections(
bool castsReflections)
307 emit castsReflectionsChanged();
311 const QQuick3DObject::ItemChangeData &
value)
313 if (change == QQuick3DObject::ItemSceneChange)
314 updateSceneManager(
value.sceneManager);
360 m_particle->updateAnimatedParticleBuffer(
this, particles);
362 m_particle->updateParticleBuffer(
this, particles);
372 if (perEmitter.particleUpdateNode == updateNode)
375 return n_noPerEmitterData;
381 if (perEmitter.emitterIndex == emitterIndex)
384 return n_noPerEmitterData;
401 if (perEmitter.particleCount == 0)
407 particles->m_sprite =
nullptr;
413 particles->m_spriteImageCount = 1;
414 particles->m_blendImages =
true;
422 particles->m_colorTable =
nullptr;
424 if (!m_lights.isEmpty()) {
427 for (
auto light : std::as_const(m_lights)) {
429 auto lightNode =
static_cast<QSSGRenderLight *
>(lightPrivate->spatialNode);
430 lightNodes.
append(lightNode);
432 particles->m_lights = lightNodes;
436 particles->m_billboard = m_billboard;
440 particles->m_castsReflections = m_castsReflections;
458 delete value.particleUpdateNode;
460 value.particleUpdateNode->m_particle =
this;
467 value.particleUpdateNode->update();
473 value.particleUpdateNode->m_nodeDirty =
true;
476void QQuick3DParticleSpriteParticle::updateFeatureLevel()
479 if (m_lights.isEmpty()) {
497 if (!
system() && qobject_cast<QQuick3DParticleSystem *>(parentItem()))
498 setSystem(qobject_cast<QQuick3DParticleSystem *>(parentItem()));
524 perEmitter.emitter = emitter;
525 perEmitter.particleUpdateNode->m_particle =
this;
533 perEmitter.particleCount++;
543 float size,
float age,
544 float animationFrame)
554 dst = {{}, {}, {}, 0.0f, 0.0f, -1.0f,
dst.emitterIndex};
557void QQuick3DParticleSpriteParticle::updateParticleBuffer(ParticleUpdateNode *updateNode,
QSSGRenderGraphObject *spatialNode)
564 const int particleCount = perEmitter.particleCount;
568 m_useAnimatedParticle =
false;
570 const SpriteParticleData *
src = particles.data();
574 const int emitterIndex = perEmitter.emitterIndex;
582 const auto sourceIndex = [&](
int linearIndex,
int offset,
int wrap) ->
int {
585 for (
int s = 0;
s < slices;
s++) {
587 for (
int p = 0;
p < pps &&
i < particleCount; ) {
589 if (
data->emitterIndex == emitterIndex) {
590 if (
data->size > 0.0f)
595 dp->
size =
data->size * m_particleScale;
606 for (
int s = 0;
s < slices;
s++) {
608 for (
int p = 0;
p < pps &&
i < particleCount; ) {
609 if (
src->emitterIndex == emitterIndex) {
610 if (
src->size > 0.0f)
615 dp->
size =
src->size * m_particleScale;
629void QQuick3DParticleSpriteParticle::updateAnimatedParticleBuffer(ParticleUpdateNode *updateNode,
QSSGRenderGraphObject *spatialNode)
636 const int particleCount = perEmitter.particleCount;
640 m_useAnimatedParticle =
true;
642 const SpriteParticleData *
src = particles.data();
646 const int emitterIndex = perEmitter.emitterIndex;
654 const auto sourceIndex = [&](
int linearIndex,
int offset,
int wrap) ->
int {
657 for (
int s = 0;
s < slices;
s++) {
659 for (
int p = 0;
p < pps &&
i < particleCount; ) {
661 if (
data->emitterIndex == emitterIndex) {
662 if (
data->size > 0.0f)
667 dp->
size =
data->size * m_particleScale;
679 for (
int s = 0;
s < slices;
s++) {
681 for (
int p = 0;
p < pps &&
i < particleCount; ) {
682 if (
src->emitterIndex == emitterIndex) {
683 if (
src->size > 0.0f)
688 dp->
size =
src->size * m_particleScale;
716void QQuick3DParticleSpriteParticle::onLightDestroyed(
QObject *
object)
719 for (
int i = 0;
i < m_lights.size(); ++
i) {
720 if (m_lights[
i] ==
object) {
721 m_lights.removeAt(
i--);
726 updateFeatureLevel();
737 if (light->parentItem()) {
740 self->updateFeatureLevel();
741 self->markNodesDirty();
751 qWarning(
"The index exceeds the range of valid light targets.");
766 for (
const auto &light :
std::as_const(
self->m_lights)) {
767 if (light->parentItem() ==
nullptr)
772 self->updateFeatureLevel();
773 self->markNodesDirty();
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype size() const noexcept
void resize(qsizetype size)
iterator insert(const Key &key, const T &value)
bool contains(const Key &key) const
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *node) override
void refSceneManager(QQuick3DSceneManager &)
static QQuick3DObjectPrivate * get(QQuick3DObject *item)
static void attachWatcher(Context *context, Setter setter, Object3D *newO, Object3D *oldO)
Attach a object-destroyed-watcher to an object that's not owned.
virtual void markAllDirty()
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *node) override
QQuick3DParticleSpriteParticle * m_particle
virtual void setParticleData(int particleIndex, const QVector3D &position, const QVector3D &rotation, const QVector4D &color, float size, float age, float animationFrame)
~QQuick3DParticleSpriteParticle() override
QQuick3DParticleSpriteParticle(QQuick3DNode *parent=nullptr)
\qmltype SpriteParticle3D \inherits Particle3D \inqmlmodule QtQuick3D.Particles3D
virtual void commitParticles(float)
virtual void handleSystemChanged(QQuick3DParticleSystem *system)
int nextCurrentIndex(const QQuick3DParticleEmitter *emitter) override
QQmlListProperty< QQuick3DAbstractLight > lights
\qmlproperty list<Light> SpriteParticle3D::lights
void spriteSequenceChanged()
void setBillboard(bool billboard)
virtual void resetParticleData(int particleIndex)
void setOffsetY(float value)
void setBlendMode(QQuick3DParticleSpriteParticle::BlendMode blendMode)
QVector< SpriteParticleData > m_spriteParticleData
QMap< const QQuick3DParticleEmitter *, PerEmitterData > m_perEmitterData
PerEmitterData & perEmitterData(const QQuick3DNode *updateNode)
void setOffsetX(float value)
QQuick3DTexture * colorTable
void particleScaleChanged()
void setSpriteSequence(QQuick3DParticleSpriteSequence *spriteSequence)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void setColorTable(QQuick3DTexture *colorTable)
bool castsReflections
\qmlproperty bool SpriteParticle3D::castsReflections
void setParticleScale(float scale)
QSSGRenderGraphObject * updateParticleNode(const ParticleUpdateNode *updateNode, QSSGRenderGraphObject *node)
virtual void handleMaxAmountChanged(int amount)
QQuick3DParticleSpriteSequence * spriteSequence
FeatureLevel m_featureLevel
void itemChange(ItemChange, const ItemChangeData &) override
void setSprite(QQuick3DTexture *sprite)
QList< QQuick3DParticleData > m_particleData
QQuick3DParticleSpriteSequence * m_spriteSequence
virtual int nextCurrentIndex(const QQuick3DParticleEmitter *emitter)
void setSystem(QQuick3DParticleSystem *system)
QQuick3DParticleSystem * system() const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QSSGRenderImage * getRenderImage()
Class representing 3D range or axis aligned bounding box.
void include(const QVector3D &v)
expands the volume to include v
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
void push_back(QChar c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
The QVector3D class represents a vector or vertex in 3D space.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
The QVector4D class represents a vector or vertex in 4D space.
Combined button and popup list for selecting options.
DBusConnection * connection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
GLenum GLuint GLint level
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLenum GLenum GLenum GLenum GLenum scale
static QSSGRenderParticles::BlendMode mapBlendMode(QQuick3DParticleSpriteParticle::BlendMode mode)
#define Q_QUICK3D_PROFILE_ASSIGN_ID_SG(obj, bgnode)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
int particleCount() const
int particlesPerSlice() const
void resize(int particleCount, int particleSize=sizeof(QSSGParticleSimple))
void setBounds(const QSSGBounds3 &bounds)
static float signedSquared(float val)
QSSGParticleBuffer m_particleBuffer
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent