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
|
| // In retail, volume particle depth was not setup through ini and was hard coded to a particle depth of 6 | ||
| if (m_particleType == ParticleType::VOLUME_PARTICLE && m_volumeParticleDepth == DEFAULT_VOLUME_PARTICLE_DEPTH) | ||
| { | ||
| m_volumeParticleDepth = OPTIMUM_VOLUME_PARTICLE_DEPTH; |
There was a problem hiding this comment.
Looks strange. I would expect it defaults to OPTIMUM_VOLUME_PARTICLE_DEPTH in the template, not every particle system.
There was a problem hiding this comment.
Not all particle systems are volume particles so the default is zero / DEFAULT_VOLUME_PARTICLE_DEPTH.
It also act's as a guard in the rendering pathway as only volume particles with a depth greater than 1 get rendered.
There was a problem hiding this comment.
But arent the particle templates stored in advance? Why not move it in there?
There was a problem hiding this comment.
I managed to find where they are initialised and moved the PRESERVE_RETAIL_PATICLES block there for this and smudges.
| @@ -1197,6 +1197,12 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, | |||
There was a problem hiding this comment.
This one maybe also needs moving into the template. Because it will always be the same.
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.
|
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
This PR is a simple refactor to cleanup the handling of volume depth for volume type 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 the retail particles and set their particle depth to the original hard coded value. Otherwise the configured by ini value will be used.