1. Volumes of Fun
  2. Main
  3. PolyVox
  4. Issues
Issue #30 resolved

Zero initialization

David Williams
created an issue

PolyVox is slightly messy with the way that classes are cleared to zero. For example, from MaterialDensityPair:

// FIXME - This is a bit odd... we need to allow the MaterialDensityPair to be initialised with a single integer
// because PolyVox often initialises voxels by calling VoxelType(0). Is there a better way we should handle this?
MaterialDensityPair(Type tValue) : m_uMaterial(tValue), m_uDensity(tValue) {}

According to p56 of 'C++ Templates' there is indeed a better way. It appears that built in types can be initialised to zero just with int() or float(), and that we should mimic this behaviour with the PolyVox classes.

Comments (2)

  1. Log in to comment