|
47 | 47 | #include "W3DDevice/GameClient/Module/W3DTankTruckDraw.h" |
48 | 48 | #include "WW3D2/matinfo.h" |
49 | 49 |
|
50 | | -//#define SHOW_TANK_DEBRIS |
| 50 | +// TheSuperHackers @info Is disabled by default and therefore compatible with the Retail INI setups. |
| 51 | +#define SHOW_DEFAULT_TANK_DEBRIS (0) |
| 52 | + |
51 | 53 | //------------------------------------------------------------------------------------------------- |
52 | | -W3DTankTruckDrawModuleData::W3DTankTruckDrawModuleData(): |
53 | | - m_treadDebrisNameLeft("TrackDebrisDirtLeft"), |
54 | | - m_treadDebrisNameRight("TrackDebrisDirtRight"), |
55 | | - m_treadAnimationRate(0.0f), |
56 | | - m_treadPivotSpeedFraction(0.6f), |
57 | | - m_treadDriveSpeedFraction(0.3f) |
| 54 | +W3DTankTruckDrawModuleData::W3DTankTruckDrawModuleData() |
| 55 | + : m_treadAnimationRate(0.0f) |
| 56 | + , m_treadPivotSpeedFraction(0.6f) |
| 57 | + , m_treadDriveSpeedFraction(0.3f) |
58 | 58 | { |
| 59 | + if constexpr (SHOW_DEFAULT_TANK_DEBRIS) |
| 60 | + { |
| 61 | + m_treadDebrisNameLeft = "TrackDebrisDirtLeft"; // TheSuperHackers @todo Remove data particle names from code |
| 62 | + m_treadDebrisNameRight = "TrackDebrisDirtRight"; |
| 63 | + } |
59 | 64 | } |
60 | 65 |
|
61 | 66 | //------------------------------------------------------------------------------------------------- |
@@ -114,40 +119,15 @@ m_prevRenderObj(nullptr) |
114 | 119 |
|
115 | 120 | m_treadCount=0; |
116 | 121 |
|
117 | | -#ifdef SHOW_TANK_DEBRIS |
118 | | - if (getW3DTankTruckDrawModuleData()) |
119 | | - { |
120 | | - const AsciiString *treadDebrisNames[2]; |
121 | | - static_assert(ARRAY_SIZE(treadDebrisNames) == ARRAY_SIZE(m_treadDebrisIDs), "Array size must match"); |
122 | | - treadDebrisNames[0] = &getW3DTankTruckDrawModuleData()->m_treadDebrisNameLeft; |
123 | | - treadDebrisNames[1] = &getW3DTankTruckDrawModuleData()->m_treadDebrisNameRight; |
124 | | - |
125 | | - for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) |
126 | | - { |
127 | | - if (m_treadDebrisIDs[i] == INVALID_PARTICLE_SYSTEM_ID) |
128 | | - { |
129 | | - if (const ParticleSystemTemplate *sysTemplate = TheParticleSystemManager->findTemplate(*treadDebrisNames[i])) |
130 | | - { |
131 | | - ParticleSystem *particleSys = TheParticleSystemManager->createParticleSystem( sysTemplate ); |
132 | | - particleSys->attachToDrawable(getDrawable()); |
133 | | - DEBUG_CRASH(("test me, may not work (srj)")); |
134 | | - // important: mark it as do-not-save, since we'll just re-create it when we reload. |
135 | | - particleSys->setSaveable(FALSE); |
136 | | - // they come into being stopped. |
137 | | - //particleSys->stop(); |
138 | | - m_treadDebrisIDs[i] = particleSys->getSystemID(); |
139 | | - } |
140 | | - } |
141 | | - } |
142 | | - } |
143 | | -#endif |
| 122 | + createTreadEmitters(); |
144 | 123 | } |
145 | 124 |
|
146 | 125 | //------------------------------------------------------------------------------------------------- |
147 | 126 | //------------------------------------------------------------------------------------------------- |
148 | 127 | W3DTankTruckDraw::~W3DTankTruckDraw() |
149 | 128 | { |
150 | 129 | tossWheelEmitters(); |
| 130 | + tossTreadEmitters(); |
151 | 131 |
|
152 | 132 | for (Int i=0; i<MAX_TREADS_PER_TANK; i++) |
153 | 133 | if (m_treads[i].m_robj) |
@@ -188,13 +168,63 @@ void W3DTankTruckDraw::setFullyObscuredByShroud(Bool fullyObscured) |
188 | 168 | if (fullyObscured != getFullyObscuredByShroud()) |
189 | 169 | { |
190 | 170 | if (fullyObscured) |
| 171 | + { |
191 | 172 | tossWheelEmitters(); |
| 173 | + stopMoveDebris(); |
| 174 | + } |
192 | 175 | else |
| 176 | + { |
193 | 177 | createWheelEmitters(); |
| 178 | + } |
194 | 179 | } |
195 | 180 | W3DModelDraw::setFullyObscuredByShroud(fullyObscured); |
196 | 181 | } |
197 | 182 |
|
| 183 | +//------------------------------------------------------------------------------------------------- |
| 184 | +//------------------------------------------------------------------------------------------------- |
| 185 | +void W3DTankTruckDraw::createTreadEmitters( void ) |
| 186 | +{ |
| 187 | + if (getW3DTankTruckDrawModuleData()) |
| 188 | + { |
| 189 | + const AsciiString *treadDebrisNames[2]; |
| 190 | + static_assert(ARRAY_SIZE(treadDebrisNames) == ARRAY_SIZE(m_treadDebrisIDs), "Array size must match"); |
| 191 | + treadDebrisNames[0] = &getW3DTankTruckDrawModuleData()->m_treadDebrisNameLeft; |
| 192 | + treadDebrisNames[1] = &getW3DTankTruckDrawModuleData()->m_treadDebrisNameRight; |
| 193 | + |
| 194 | + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) |
| 195 | + { |
| 196 | + if (m_treadDebrisIDs[i] == INVALID_PARTICLE_SYSTEM_ID) |
| 197 | + { |
| 198 | + if (const ParticleSystemTemplate *sysTemplate = TheParticleSystemManager->findTemplate(*treadDebrisNames[i])) |
| 199 | + { |
| 200 | + ParticleSystem *particleSys = TheParticleSystemManager->createParticleSystem( sysTemplate ); |
| 201 | + particleSys->attachToDrawable(getDrawable()); |
| 202 | + // important: mark it as do-not-save, since we'll just re-create it when we reload. |
| 203 | + particleSys->setSaveable(FALSE); |
| 204 | + // they come into being stopped. |
| 205 | + particleSys->stop(); |
| 206 | + m_treadDebrisIDs[i] = particleSys->getSystemID(); |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | + } |
| 211 | +} |
| 212 | + |
| 213 | +//------------------------------------------------------------------------------------------------- |
| 214 | +//------------------------------------------------------------------------------------------------- |
| 215 | +void W3DTankTruckDraw::tossTreadEmitters( void ) |
| 216 | +{ |
| 217 | + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) |
| 218 | + { |
| 219 | + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) |
| 220 | + { |
| 221 | + particleSys->attachToObject(nullptr); |
| 222 | + particleSys->destroy(); |
| 223 | + } |
| 224 | + m_treadDebrisIDs[i] = INVALID_PARTICLE_SYSTEM_ID; |
| 225 | + } |
| 226 | +} |
| 227 | + |
198 | 228 | //------------------------------------------------------------------------------------------------- |
199 | 229 | //------------------------------------------------------------------------------------------------- |
200 | 230 | void W3DTankTruckDraw::createWheelEmitters( void ) |
@@ -341,9 +371,7 @@ void W3DTankTruckDraw::setHidden(Bool h) |
341 | 371 | if (h) |
342 | 372 | { |
343 | 373 | enableWheelEmitters(false); |
344 | | -#ifdef SHOW_TANK_DEBRIS |
345 | 374 | stopMoveDebris(); |
346 | | -#endif |
347 | 375 | } |
348 | 376 | } |
349 | 377 |
|
@@ -619,7 +647,6 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) |
619 | 647 | } |
620 | 648 |
|
621 | 649 | //Tank update |
622 | | -#ifdef SHOW_TANK_DEBRIS |
623 | 650 | const Real DEBRIS_THRESHOLD = 0.00001f; |
624 | 651 |
|
625 | 652 | // if tank is moving, kick up dust and debris |
@@ -654,7 +681,7 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) |
654 | 681 | particleSys->setBurstCountMultiplier( velMult.z ); |
655 | 682 | } |
656 | 683 | } |
657 | | -#endif |
| 684 | + |
658 | 685 | //Update movement of treads |
659 | 686 | if (m_treadCount) |
660 | 687 | { |
@@ -734,4 +761,8 @@ void W3DTankTruckDraw::loadPostProcess( void ) |
734 | 761 | // toss any existing wheel emitters (no need to re-create; we'll do that on demand) |
735 | 762 | tossWheelEmitters(); |
736 | 763 |
|
| 764 | + // toss any existing tread emitters and re-create 'em (since this module expects 'em to always be around) |
| 765 | + tossTreadEmitters(); |
| 766 | + createTreadEmitters(); |
| 767 | + |
737 | 768 | } |
0 commit comments