Refactoring of basic voxel types.
This commit is contained in:
@ -60,7 +60,7 @@ Note that this function is part of the BasicExample (rather than being part of t
|
||||
if(fDistToCenter <= fRadius)
|
||||
{
|
||||
//Our new density value
|
||||
uint8_t uDensity = MaterialDensityPair44::getMaxDensity();
|
||||
uint8_t uDensity = VoxelTypeTraits<MaterialDensityPair44>::MaxDensity;
|
||||
|
||||
//Get the old voxel
|
||||
MaterialDensityPair44 voxel = volData.getVoxelAt(x,y,z);
|
||||
@ -80,7 +80,7 @@ This function takes as input the :polyvox:`SimpleVolume` in which we want to cre
|
||||
|
||||
Because this is a simple example function it always places the sphere at the centre of the volume. It computes this centre by halving the dimensions of the volume as given by the functions :polyvox:`SimpleVolume::getWidth`, :polyvox:`SimpleVolume::getHeight` and :polyvox:`SimpleVolume::getDepth`. The resulting position is stored using a :polyvox:`Vector3DFloat`. This is simply a typedef from our templatised :polyvox:`Vector` class, meaning that other sizes and storage types are available if you need them.
|
||||
|
||||
Next, the function uses a three-level 'for' loop to iterate over each voxel in the volume. For each voxel it computes the distance from the voxel to the centre of the volume. If this distance is less than or equal to the specified radius then the voxel form part of the sphere and is made solid. During surface extraction, the voxel will be considered solid if it's density is set to any value greater than its threshold, which can be obtained by calling :polyvox:`MaterialDensityPair44::getThreshold <MaterialDensityPair::getThreshold>`. In our case we simply set it to the largest possible value by calling :polyvox:`MaterialDensityPair44::getMaxDensity <MaterialDensityPair::getMaxDensity>`.
|
||||
Next, the function uses a three-level 'for' loop to iterate over each voxel in the volume. For each voxel it computes the distance from the voxel to the centre of the volume. If this distance is less than or equal to the specified radius then the voxel form part of the sphere and is made solid. During surface extraction, the voxel will be considered solid if it's density is set to any value greater than its threshold, which can be obtained by calling :polyvox:`MaterialDensityPair44::getThreshold <MaterialDensityPair::getThreshold>`. In our case we simply set it to the largest possible value by calling :polyvox:`VoxelTypeTraits<MaterialDensityPair44>::MaxDensity <VoxelTypeTraits<MaterialDensityPair44>::MaxDensity>`.
|
||||
|
||||
Extracting the surface
|
||||
======================
|
||||
|
Reference in New Issue
Block a user