David Williams wrote:
However, we should be careful about making PolyVox in some way dependant on CMake as not everybody uses it. For example, for the gameplay integration I've just copied the PolyVox source code into the appropriate folder and added the files directly to Visual Studio and to Ant (the build system use by Android). We should avoid a situation where only uses of CMake can access certain PolyVox functions, or where any prebuilt binaries we eventually provide can only be used by CMake users. I'm not exactly sure of the implications or if there's even a problem but just keep it in mind.
It may be possible to introduce a file 'Config.h' with our own #defines. These could be set by CMake if it's being used or could otherwise default to sensible values which the user can change.
Ok. If I integrate this into PolyVox I'll be sure to take this into account. It should be able to work as follows:
We have this feature detection in the CMake build system only. During the build process, it creates a config.h header file (or adds settings to TypeDef.h) with the appropriate values. When you run 'make install' it will copy the binaries and header files to a specific location (C:\PolyVox\{bin,include} or something). It is the contents of this install directory which we will distribute as the SDK and which people will use to build against.
On Windows we will have created this SDK with a specific compiler (e.g. VC++ 10.0) and so the SDK will have all the features available that that compiler supports. Therefore, anyone using PolyVox in their VC++ 10.0 project will be compatible.
Then, there is the case of if the user only have VC++ 8.0. In this case we have two options: either we make available a VC++ 8.0 SDK (this might have to be the option due to binary incompatibility) or they simply manually edit the config.h to disable any features their compiler doesn't understand.
In your case with gameplay3d (and anyone else doing the same) you can follow a similar workflow. Set the PolyVox install directory to be something sensible (either c:\PolyVox or even into a subdir of your project like C:\Mygameplayproject\polyvox), run 'make install' for PolyVox, point the solution file and Ant file to the right location (headers and (static) libraries) and it will just work.
This will work in an almost identical way on Linux and Mac and allows people to use wither the SDK or self-built binaries without having to change things around. We put some effort in recently to make the installed layout of PolyVox sensible so we should make use of that.
Does this make sense? Is there any thing I'm missing?
David Williams wrote:
I had a quick look at move constructors and I think they could be useful. Actually I think they will be most useful for the small classes (Vector, Region, etc) because these are frequently passed around as parameters, copied, assigned to, returned, etc. Although you would expect it to benefit something like the Volumes I think it might not help beause we always pass them by pointer anyway (and avoid operations which would create a temporaries).
One of the big things people talk about with C++11 is that it should be possible to almost always just pass things as values. The reason this is avoided traditionally is because of all the unnecessary copies this entails but with move semantics and perfect forwarding this is obviated. I agree that passing round pointer to volumes works perfectly fine but it might be worth considering allowing people to be able to pass them by value without having to worry about them being copied (which would obviously be a very heavy operation). Either way, I'll look first into implementing them for the simpler classes.
It's worth noting that compilers are supposed to be able to generate implicit move constructors (like they do for copy constructors, destructors and copy assignment operators) under certain conditions. The conditions are listed at
cppreference.com and are quite hard to understand
. The main thing to take away from that is that what used to be
the rule of three (if you declare any one of copy constructor, destructor or copy operator= you should think about all three) is now the rule of five (same as before but also including move constructor and move operator=). See also
this post. However, I think that only very recent versions of GCC (and perhaps no versions of VC++) are actually generating these methods.