refactor(particlesys): Cleanup retail volume particle depth handling - #3188
refactor(particlesys): Cleanup retail volume particle depth handling#3188Mauller wants to merge 1 commit into
Conversation
PR Summary by QodoParticleSys: Make volume particle depth configurable while preserving retail defaults
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Vol depth 0 ignored
|
bbbc607 to
a596261
Compare
| } | ||
|
|
||
| // In retail, volume particle depth was not setup through ini and was hard coded to a particle depth of 6 | ||
| if (sysTemplate->m_particleType == ParticleSystemInfo::VOLUME_PARTICLE && sysTemplate->m_volumeParticleDepth == DEFAULT_VOLUME_PARTICLE_DEPTH) |
There was a problem hiding this comment.
This means if someone now sets VolParticleDepth to 0 in the INI explicitly, then it overwrites it here. That does not seem right. Perhaps it should only set it if the INI field was not set. Or is 0 an invalid setting for Volume particles?
There was a problem hiding this comment.
Zero and One are invalid settings anyway.
There are tests in the render code for the volume depth being greater than One.
The value is also initialised to zero in the template.
There was a problem hiding this comment.
If the particle depth is set to zero or one, then the volume particle just gets rendered as a standard particle in this instance.
void PointGroupClass::RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int depth )
{
if ( depth <= 1 ) //oops,wrong number
{
Render( rinfo );
return;
}Which kind of voids the point of it being a volume particle. But seems more like a safety net.
There was a problem hiding this comment.
When looking further into the RenderVolumeParticle code the reciprocal of the depth is take which would cause a divide by zero error if 0 was a valid depth. Not sure why One is not considered though from the quick glance i took.
There was a problem hiding this comment.
How about do
#define INVALID_VOLUME_PARTICLE_DEPTH ( 0 )
#define DEFAULT_VOLUME_PARTICLE_DEPTH ( 1 ) // The Default is not to do the volume thing!
#define OPTIMUM_VOLUME_PARTICLE_DEPTH ( 6 )
Then initialize particle template depth with invalid, and then depending on the particle type parsed from ini, choose 1 or 6, regardless of retail.
There was a problem hiding this comment.
Well the problem is that we only consider getting as far as the rendering if the volume is 2 or higher anyway.
That's where i added the MIN_VOLUME_PARTICLE_DEPTH ( 2 ) in the particle batching PR since that is what the retail code tests in doParticles to determine if it handles a volume particle.
So even set to 1 the volume particle is never rendered. Even if it the rendering code has a failsafe to render as a regular particle.
The workaround was always more about catching the non configured particles from retail.
For non retail and mod's the particle editor should always put a minimum of 2 as the particle depth if a volume particle is selected. Otherwise it should be considered misconfigured and not render etc.
This is more just a hack to keep retail particles working that lack the configuration essentially while opening up the particle depth option for mods and future etc.
There was a problem hiding this comment.
I dont quite follow.
The proposed flow is to initialize with invalid, and then set 1 or 6 depending on the type wehn invalid. This way it always works the same way reliably and needs to retail guarding.
|
The overall direction looks good, but I think two issues should be addressed before merging:
Other than these configuration and round-trip concerns, the change looks clean and the CI results are good. |
a596261 to
291a2e3
Compare
| } | ||
|
|
||
| // In retail, volume particle depth was not setup through ini and was hard coded to a particle depth of 6 | ||
| if (sysTemplate->m_particleType == ParticleSystemInfo::VOLUME_PARTICLE && sysTemplate->m_volumeParticleDepth == DEFAULT_VOLUME_PARTICLE_DEPTH) |
There was a problem hiding this comment.
How about do
#define INVALID_VOLUME_PARTICLE_DEPTH ( 0 )
#define DEFAULT_VOLUME_PARTICLE_DEPTH ( 1 ) // The Default is not to do the volume thing!
#define OPTIMUM_VOLUME_PARTICLE_DEPTH ( 6 )
Then initialize particle template depth with invalid, and then depending on the particle type parsed from ini, choose 1 or 6, regardless of retail.
291a2e3 to
53eef90
Compare
53eef90 to
c32d92c
Compare
|
Fixed based on feedback and did a little more cleanup around it as well. |
| Bool isUsingStreak() { return (m_particleType == STREAK) ? true : false; } | ||
| Bool isUsingSmudge() { return (m_particleType == SMUDGE) ? true : false; } | ||
| UnsignedInt getVolumeParticleDepth() { return ( m_particleType == VOLUME_PARTICLE ) ? OPTIMUM_VOLUME_PARTICLE_DEPTH : 0; } | ||
| UnsignedInt getVolumeParticleDepth() { return ( m_particleType == VOLUME_PARTICLE ) ? m_volumeParticleDepth : DEFAULT_VOLUME_PARTICLE_DEPTH; } |
There was a problem hiding this comment.
Assuming the template now holds a validated depth value, the condition here should no longer be needed?
There was a problem hiding this comment.
I was considering that, maybe i split it into two functions, one like the others that checks for the particle type of VOLUME_PARTICLE then have the original return m_volumeParticleDepth.
|
|
||
| // TheSuperHackers @info Initialise all volume particles that lack ini configuration to the optimum depth of 6 | ||
| // In retail, volume particle depth was not configurable through ini and was hard coded to a particle depth of 6 | ||
| if (sysTemplate->m_particleType == ParticleSystemInfo::VOLUME_PARTICLE && sysTemplate->m_volumeParticleDepth == INVALID_VOLUME_PARTICLE_DEPTH) |
There was a problem hiding this comment.
How about move these validation steps int a new function inside the template class? I have seen the same approach with LocomotorTemplate::validate.
There was a problem hiding this comment.
I can do, then call validate after the load.
c32d92c to
ffa3dc6
Compare
|
Updated with recent suggestions along with a little extra cleanup around the same area. |
| Bool isUsingDrawables() { return m_particleType == DRAWABLE; } | ||
| Bool isUsingStreak() { return m_particleType == STREAK; } | ||
| Bool isUsingSmudge() { return m_particleType == SMUDGE; } | ||
| BOOL isUsingVolumeParticles() { return m_particleType == VOLUME_PARTICLE; } |
There was a problem hiding this comment.
Only just noticed that i used BOOL instead of bool but i will fix this after the next review so the diff can be seen.












This PR is a refactor to cleanup the handling of volume depth for volume type and normal particles.
The particle system class originally returned a hard coded value from
getVolumeParticleDepth()instead of returning the variablem_volumeParticleDepth.This value is now retrieved from the particle template and exposed to configuration through the ini field of
VolParticleDepth.To preserve the retail particle behaviour, we identify uninitialised volume particles and set their particle depth to the original hard coded value. Otherwise the configured by ini value will be used.
EDIT - For normal particles we now also initialise their depth to 1.