Merge branch 'main/rendor-staging' into fixes
[ryzomcore.git] / nel / src / 3d / particle_system_process.cpp
blob9317f6a6b56ac481dfd8d6b5901ef38f2d7589e1
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std3d.h"
19 #include "nel/3d/particle_system_process.h"
20 #include "nel/3d/particle_system.h"
22 #ifdef DEBUG_NEW
23 #define new DEBUG_NEW
24 #endif
26 uint PSEnterLeaveDepth = 0;
27 uint PSEnterLeaveMaxDepth = 1;
28 std::string PSCurrName;
30 // ***********************************************************************************************************
31 CPSEnterLeave::CPSEnterLeave(const char *name)
33 ++ PSEnterLeaveDepth;
34 Name = name;
35 if (PSEnterLeaveDepth <= PSEnterLeaveMaxDepth)
37 std::string indent(PSEnterLeaveDepth, ' ');
38 nlinfo("Entering %s in %s", (indent + Name).c_str(), PSCurrName.c_str());
42 // ***********************************************************************************************************
43 CPSEnterLeave::~CPSEnterLeave()
45 if (PSEnterLeaveDepth <= PSEnterLeaveMaxDepth)
47 std::string indent(PSEnterLeaveDepth, ' ');
48 nlinfo("Leaving %s in %s", Name.c_str(), PSCurrName.c_str());
50 -- PSEnterLeaveDepth;
54 namespace NL3D {
57 /////////////////////////////////////////////
58 // CParticleSystemProcess implementation //
59 /////////////////////////////////////////////
61 // ***********************************************************************************************************
62 void CParticleSystemProcess::setOwner(CParticleSystem *ps)
64 NL_PS_FUNC(CParticleSystemProcess_setOwner)
65 if (ps == _Owner) return;
66 if (ps == NULL)
68 releaseAllRef();
70 if (_Owner) _Owner->releaseRefForUserSysCoordInfo(getUserMatrixUsageCount());
71 _Owner = ps;
72 if (_Owner) _Owner->addRefForUserSysCoordInfo(getUserMatrixUsageCount());
76 // ***********************************************************************************************************
77 uint CParticleSystemProcess::getUserMatrixUsageCount() const
79 NL_PS_FUNC(CParticleSystemProcess_getUserMatrixUsageCount)
80 return _MatrixMode == PSUserMatrix;
83 // ***********************************************************************************************************
84 void CParticleSystemProcess::setMatrixMode(TPSMatrixMode matrixMode)
86 NL_PS_FUNC(CParticleSystemProcess_setMatrixMode)
87 nlassert((uint) matrixMode <= PSMatrixModeCount);
88 if (matrixMode == _MatrixMode) return;
89 if (_Owner) // notify the system that matrix mode has changed for that object
91 _Owner->matrixModeChanged(this, _MatrixMode, matrixMode);
93 _MatrixMode = matrixMode;
97 // ***********************************************************************************************************
98 CFontGenerator *CParticleSystemProcess::getFontGenerator(void)
100 NL_PS_FUNC(CParticleSystemProcess_getFontGenerator)
101 nlassert(_Owner);
102 return _Owner->getFontGenerator();
105 // ***********************************************************************************************************
106 const CFontGenerator *CParticleSystemProcess::getFontGenerator(void) const
108 NL_PS_FUNC(CParticleSystemProcess_getFontGenerator)
109 nlassert(_Owner);
110 return _Owner->getFontGenerator();
113 // ***********************************************************************************************************
114 CFontManager *CParticleSystemProcess::getFontManager(void)
116 NL_PS_FUNC(CParticleSystemProcess_getFontManager)
117 nlassert(_Owner);
118 return _Owner->getFontManager();
121 // ***********************************************************************************************************
122 const CFontManager *CParticleSystemProcess::getFontManager(void) const
124 NL_PS_FUNC(CParticleSystemProcess_getFontManager)
125 nlassert(_Owner);
126 return _Owner->getFontManager();
131 // ***********************************************************************************************************
132 void CParticleSystemProcess::serial(NLMISC::IStream &f)
134 NL_PS_FUNC(CParticleSystemProcess_serial)
135 // version 2 : added matrix mode (just not fx world matrix or identity)
136 // version 1 : base version
137 sint ver = f.serialVersion(2);
138 f.serialPtr(_Owner);
139 if (ver == 1)
141 nlassert(f.isReading());
142 bool usesFXWorldMatrix;
143 f.serial(usesFXWorldMatrix);
144 _MatrixMode = usesFXWorldMatrix ? PSFXWorldMatrix : PSIdentityMatrix;
146 if (ver >= 2)
148 f.serialEnum(_MatrixMode);
152 } // NL3D