Skip to content

Commit 3cfe550

Browse files
committed
unify(particlesys): Merge addition of ParticleSystem::setSkipParentXfrm from Zero Hour (TheSuperHackers#2153)
1 parent 49f0e5f commit 3cfe550

4 files changed

Lines changed: 58 additions & 49 deletions

File tree

Generals/Code/GameEngine/Include/GameClient/ParticleSys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ class ParticleSystem : public MemoryPoolObject,
557557
void rotateLocalTransformX( Real x ); ///< rotate local transform matrix
558558
void rotateLocalTransformY( Real y ); ///< rotate local transform matrix
559559
void rotateLocalTransformZ( Real z ); ///< rotate local transform matrix
560+
void setSkipParentXfrm(Bool enable) { m_skipParentXfrm = enable; } ///<disable transforming particle system with parent matrix.
560561

561562
const Coord3D *getDriftVelocity( void ) { return &m_driftVelocity; } ///< get the drift velocity of the system
562563

@@ -709,6 +710,7 @@ class ParticleSystem : public MemoryPoolObject,
709710
Bool m_isDestroyed; ///< are we destroyed and waiting for particles to die
710711
Bool m_isFirstPos; ///< true if this system hasn't been drawn before.
711712
Bool m_isSaveable; ///< true if this system should be saved/loaded
713+
Bool m_skipParentXfrm; ///< true if this system is already in world space.
712714

713715

714716
// the actual particle system data is inherited from ParticleSystemInfo

Generals/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate,
10831083

10841084
m_isIdentity = true;
10851085
m_transform.Make_Identity();
1086+
m_skipParentXfrm = false;
10861087

10871088
m_isStopped = false;
10881089
m_isDestroyed = false;
@@ -1935,19 +1936,23 @@ Bool ParticleSystem::update( Int localPlayerIndex )
19351936
destroy();
19361937
}
19371938
}
1938-
1939-
if (m_attachedToObjectID)
1939+
else if (m_attachedToObjectID)
19401940
{
1941-
Object *attachedTo = TheGameLogic->findObjectByID( m_attachedToObjectID );
1941+
Object *objectAttachedTo = TheGameLogic->findObjectByID( m_attachedToObjectID );
19421942

1943-
if (attachedTo)
1943+
if (objectAttachedTo)
19441944
{
19451945
if (!isShrouded)
1946-
isShrouded = (attachedTo->getShroudedStatus(localPlayerIndex) >= OBJECTSHROUD_FOGGED);
1946+
isShrouded = (objectAttachedTo->getShroudedStatus(localPlayerIndex) >= OBJECTSHROUD_FOGGED);
1947+
1948+
const Drawable * draw = objectAttachedTo->getDrawable();
1949+
if ( draw )
1950+
parentXfrm = draw->getTransformMatrix();
1951+
else
1952+
parentXfrm = objectAttachedTo->getTransformMatrix();
19471953

1948-
parentXfrm = attachedTo->getTransformMatrix();
19491954
m_lastPos = m_pos;
1950-
m_pos = *attachedTo->getPosition();
1955+
m_pos = *objectAttachedTo->getPosition();
19511956
}
19521957
else
19531958
{
@@ -1961,15 +1966,23 @@ Bool ParticleSystem::update( Int localPlayerIndex )
19611966

19621967
if (parentXfrm)
19631968
{
1964-
// if system has its own local transform, concatenate them
1965-
if (m_isLocalIdentity == false)
1966-
#ifdef ALLOW_TEMPORARIES
1967-
m_transform = (*parentXfrm) * m_localTransform;
1968-
#else
1969-
m_transform.mul(*parentXfrm, m_localTransform);
1970-
#endif
1969+
if (m_skipParentXfrm)
1970+
{
1971+
//this particle system is already in world space so no need to apply parent xform.
1972+
m_transform = m_localTransform;
1973+
}
19711974
else
1972-
m_transform = *parentXfrm;
1975+
{
1976+
// if system has its own local transform, concatenate them
1977+
if (m_isLocalIdentity == false)
1978+
#ifdef ALLOW_TEMPORARIES
1979+
m_transform = (*parentXfrm) * m_localTransform;
1980+
#else
1981+
m_transform.mul(*parentXfrm, m_localTransform);
1982+
#endif
1983+
else
1984+
m_transform = *parentXfrm;
1985+
}
19731986

19741987
m_isIdentity = false;
19751988
transformSet = true;

GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ class ParticleSystem : public MemoryPoolObject,
549549
void rotateLocalTransformX( Real x ); ///< rotate local transform matrix
550550
void rotateLocalTransformY( Real y ); ///< rotate local transform matrix
551551
void rotateLocalTransformZ( Real z ); ///< rotate local transform matrix
552-
void setSkipParentXfrm(Bool enable) { m_skipParentXfrm = enable; } ///<disable transforming particle system with parent matrix.
552+
void setSkipParentXfrm(Bool enable) { m_skipParentXfrm = enable; } ///<disable transforming particle system with parent matrix.
553553

554554
const Coord3D *getDriftVelocity( void ) { return &m_driftVelocity; } ///< get the drift velocity of the system
555555

@@ -703,7 +703,7 @@ class ParticleSystem : public MemoryPoolObject,
703703
Bool m_isDestroyed; ///< are we destroyed and waiting for particles to die
704704
Bool m_isFirstPos; ///< true if this system hasn't been drawn before.
705705
Bool m_isSaveable; ///< true if this system should be saved/loaded
706-
Bool m_skipParentXfrm; ///< true if this system is already in world space.
706+
Bool m_skipParentXfrm; ///< true if this system is already in world space.
707707

708708

709709
// the actual particle system data is inherited from ParticleSystemInfo

GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate,
10411041

10421042
m_isIdentity = true;
10431043
m_transform.Make_Identity();
1044-
m_skipParentXfrm = false;
1044+
m_skipParentXfrm = false;
10451045

10461046
m_isStopped = false;
10471047
m_isDestroyed = false;
@@ -1870,7 +1870,6 @@ Bool ParticleSystem::update( Int localPlayerIndex )
18701870
isShrouded = true;
18711871

18721872
parentXfrm = attachedTo->getTransformMatrix();
1873-
18741873
m_lastPos = m_pos;
18751874
m_pos = *attachedTo->getPosition();
18761875
}
@@ -1892,14 +1891,11 @@ Bool ParticleSystem::update( Int localPlayerIndex )
18921891
if (!isShrouded)
18931892
isShrouded = (objectAttachedTo->getShroudedStatus(localPlayerIndex) >= OBJECTSHROUD_FOGGED);
18941893

1895-
const Drawable * draw = objectAttachedTo->getDrawable();
1896-
if ( draw )
1897-
parentXfrm = draw->getTransformMatrix();
1898-
else
1899-
parentXfrm = objectAttachedTo->getTransformMatrix();
1900-
1901-
1902-
1894+
const Drawable * draw = objectAttachedTo->getDrawable();
1895+
if ( draw )
1896+
parentXfrm = draw->getTransformMatrix();
1897+
else
1898+
parentXfrm = objectAttachedTo->getTransformMatrix();
19031899

19041900
m_lastPos = m_pos;
19051901
m_pos = *objectAttachedTo->getPosition();
@@ -1914,30 +1910,28 @@ Bool ParticleSystem::update( Int localPlayerIndex )
19141910
}
19151911
}
19161912

1917-
1918-
19191913
if (parentXfrm)
19201914
{
1921-
if (m_skipParentXfrm)
1922-
{
1923-
//this particle system is already in world space so no need to apply parent xform.
1924-
m_transform = m_localTransform;
1925-
}
1926-
else
1927-
{
1928-
// if system has its own local transform, concatenate them
1929-
if (m_isLocalIdentity == false)
1930-
#ifdef ALLOW_TEMPORARIES
1931-
m_transform = (*parentXfrm) * m_localTransform;
1932-
#else
1933-
m_transform.mul(*parentXfrm, m_localTransform);
1934-
#endif
1935-
else
1936-
m_transform = *parentXfrm;
1937-
}
1938-
1939-
m_isIdentity = false;
1940-
transformSet = true;
1915+
if (m_skipParentXfrm)
1916+
{
1917+
//this particle system is already in world space so no need to apply parent xform.
1918+
m_transform = m_localTransform;
1919+
}
1920+
else
1921+
{
1922+
// if system has its own local transform, concatenate them
1923+
if (m_isLocalIdentity == false)
1924+
#ifdef ALLOW_TEMPORARIES
1925+
m_transform = (*parentXfrm) * m_localTransform;
1926+
#else
1927+
m_transform.mul(*parentXfrm, m_localTransform);
1928+
#endif
1929+
else
1930+
m_transform = *parentXfrm;
1931+
}
1932+
1933+
m_isIdentity = false;
1934+
transformSet = true;
19411935
}
19421936

19431937

0 commit comments

Comments
 (0)