Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Assuming m_sMaterial is our material string keyfield
- const size_t uMaterialLen = strlen( m_sMaterial );
- size_t uDigitLen = 0;
- size_t uNextDigit = 1;
- for (size_t i = 0; i < NUM_MATERIAL_HANDLES; ++i)
- {
- if (i % uNextDigit == 0)
- {
- ++uDigitLen;
- uNextDigit *= 10;
- }
- // Allocate length of material string + length of numeral suffix + null terminator
- // This is non-standard but is used around the engine already so I assume it's compiled with a dynamic stack allocation addon
- const size_t uLength = uMaterialLen + uDigitLen + 1;
- char str[uLength];
- // Copy the base material string
- for (size_t j = 0; j < uMaterialLen; ++j)
- str[j] = m_sMaterial[j];
- // Copy each digit
- size_t uNum = i;
- for (size_t j = uLength - 2; j >= uMaterialLen; --j)
- {
- str[j] = '0' + uNum % 10;
- uNum /= 10;
- }
- str[uLength - 1] = 0;
- m_MaterialHandles[i] = m_ParticleEffect.FindOrAddMaterial(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement