Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Removing template template parameters in PolyVox http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=392 |
Page 1 of 2 |
Author: | David Williams [ Fri May 18, 2012 1:54 pm ] |
Post subject: | Removing template template parameters in PolyVox |
I'm making some changes to PolyVox to remove the use of template template (not a typo!) parameters. Many algorithms access to the type of the voxels in the volume on which they are operating. Currently the CubicSurfacExtractor is defined like this: Code: template< template<typename> class VolumeType, typename VoxelType>class CubicSurfaceExtractor and the voxel type is used internally like this: Code: ... VoxelType currentVoxel = volumeSampler.getVoxel(); ... User code to create the CubicSurfaceExtractor looks like this: Code: CubicSurfaceExtractor<LargeVolume, Material8> cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result); In the new version of the code the CubicSurfaceExtractor is only templatised on the VolumeType: Code: template<typename VolumeType>class CubicSurfaceExtractor Because algorithms still need access to the VoxelType it is now provided as a member of the volume, and used as follows: Code: ... VolumeType::VoxelType currentVoxel = volumeSampler.getVoxel(); ... This is similar to how value_type can be used to determine the type of elements in an STL container. From a user code point of view, it means the creation of a CubicSurfaceExtractor should now be as follows Code: CubicSurfaceExtractor< LargeVolume<Material8> > cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result); It's very similar to before, so you'll have to look carefully to spot the difference ![]() The main motivation for this change is that template template parameters get complex and result in hard to read/write code inside PolyVox. Frankly, it was done using template template parameters I the first place because I didn't realise there was a another way. Another advantage (untested) is that you should be able to use typedefs of volume more easily: Code: typedef LargeVolume<Material8> MyVolume; CubicSurfaceExtractor< MyVolume > cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result); I'll probably change all of PolyVox's algorithms in this way, unless I come across some specific cases where it doesn't work. |
Author: | realazthat [ Fri May 18, 2012 6:45 pm ] |
Post subject: | Re: Removing template template parameters in PolyVox |
David Williams wrote: Code: typedef LargeVolume<Material8> MyVolume; CubicSurfaceExtractor< MyVolume > cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result); I'll probably change all of PolyVox's algorithms in this way, unless I come across some specific cases where it doesn't work. *thumbs up* |
Author: | milliams [ Tue May 22, 2012 1:20 pm ] |
Post subject: | Re: Removing template template parameters in PolyVox |
This is good news. As far as I can remember, template template parameters were one of the main things preventing me from getting SWIG working properly with newer versions of PolyVox. Once this has all settled down, I'll take another look at getting the SWIG bindings working. |
Author: | David Williams [ Thu Jun 14, 2012 8:18 pm ] |
Post subject: | Re: Removing template template parameters in PolyVox |
Ok, I think I've now changed all instances of this. It's nice getting back into PolyVox after so long focusing on the game side of things ![]() milliams wrote: As far as I can remember, template template parameters were one of the main things preventing me from getting SWIG working properly with newer versions of PolyVox. Yeah, they certainly complicated it. If you don't get around to it I might take a look at them myself in the future, as I think you can imagine how they could be useful for a certain top secret project... ![]() |
Author: | milliams [ Thu Jun 14, 2012 9:59 pm ] |
Post subject: | Re: Removing template template parameters in PolyVox |
David Williams wrote: Ok, I think I've now changed all instances of this. It's nice getting back into PolyVox after so long focusing on the game side of things ![]() It's looking good. I've just made a commit to fix the compilation on GCC. It's much pickier about including 'typename' before scoped template parameters when there's a chance that they might be a member variable rather than a nested type. I had to add about a million of them but it's compiling now. Quote: Yeah, they certainly complicated it. If you don't get around to it I might take a look at them myself in the future, as I think you can imagine how they could be useful for a certain top secret project... ![]() Yeah, they could certainly be useful. I'll try to have a look at at least getting build system for SWIG working again and at least PolyVox::Vector building so that we can take it from there. [edit] I've just re-enabled the SWIG system and it seems to work for me. I've commented out everything except PolyVox::Vector for now but I expect a number of other systems will work well straight off. The interface isn't at all Pythonic but that's something we can add as we go along. [/edit] |
Author: | David Williams [ Fri Jun 15, 2012 8:50 am ] |
Post subject: | Re: Removing template template parameters in PolyVox |
milliams wrote: I've just made a commit to fix the compilation on GCC... Yeah, sorry about that ![]() |
Author: | David Williams [ Fri Jun 15, 2012 3:33 pm ] |
Post subject: | Re: Removing template template parameters in PolyVox |
David Williams wrote: Also I realise I committed my changes but didn't push them (still being caught out by Git!) so I'll do that later and check how it is working on Linux. Ok, I've pushed them. I've also compiled on Linux and made some more fixes. I'll be curious whether the CDash machine works tonight. It's been a long time since we had a sucessful build on that but on my own Linux box everything is fine. |
Author: | David Williams [ Sat Jun 16, 2012 6:01 am ] |
Post subject: | Re: Removing template template parameters in PolyVox |
Ok, build machine is running again ![]() |
Author: | milliams [ Mon Jun 18, 2012 10:21 am ] |
Post subject: | Re: Removing template template parameters in PolyVox |
David Williams wrote: Ok, build machine is running again ![]() Unfortunately, it's still inconsistent. It's just inconsistent in a different way now ![]() In good news, the removal of the template template parameters has enabled PolyVox to be build on GCC 4.3 again. I had to switch the CDash build machine to build using 4.4 previously. When I get the chance I'll re-enable 4.3 so we can get build tests for both. |
Author: | milliams [ Mon Jun 18, 2012 9:44 pm ] |
Post subject: | Re: Removing template template parameters in PolyVox |
milliams wrote: When I get the chance I'll re-enable 4.3 so we can get build tests for both. I've now done this and PolyVox is building for GCC version 4.3 through 4.5 and can be seen at my.cdash.org. My next task with the build server is to look into clang but that depends on them providing it.
|
Page 1 of 2 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |