From 624a192be4796f7bc94031f6a25b468416f6a848 Mon Sep 17 00:00:00 2001 From: David Williams Date: Thu, 10 Mar 2011 20:55:11 +0000 Subject: [PATCH] Compile fixes for non-boost systems, mostly related to function and bind. --- examples/Basic/main.cpp | 13 +++++++++---- library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h | 8 ++++++++ library/PolyVoxCore/include/Volume.h | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 65990405..a73dccbe 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -551,8 +551,6 @@ void unload(const Volume& vol, PolyVox::Region reg) std::cout << "warning unloading region: " << reg.getLowerCorner() << " -> " << reg.getUpperCorner() << std::endl; } -#include - int main(int argc, char *argv[]) { //Create and show the Qt OpenGL window @@ -562,8 +560,15 @@ int main(int argc, char *argv[]) //Create an empty volume and then place a sphere in it Volume volData(128); - volData.m_LoadCallback = std::bind(&load, std::placeholders::_1, std::placeholders::_2); - volData.m_UnloadCallback = boost::bind(&unload, _1, _2); + + //If these two lines don't compile, please try commenting them out and using the two lines after + //(you will need Boost for this). If you have to do this then please let us know in the forums as + //we rely on community feedback to keep the Boost version running. + volData.m_LoadCallback = &load; + volData.m_UnloadCallback = &unload; + //volData.m_LoadCallback = polyvox_bind(&load, polyvox_placeholder_1, polyvox_placeholder_2); + //volData.m_UnloadCallback = polyvox_bind(&unload, polyvox_placeholder_1, polyvox_placeholder_2); + volData.setBlockCacheSize(4096); //createSphereInVolume(volData, 30); //createPerlinTerrain(volData); diff --git a/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h index 642ca4da..5861e124 100644 --- a/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h @@ -51,6 +51,11 @@ freely, subject to the following restrictions: #include #define polyvox_hash boost::hash + #include + #define polyvox_bind boost::bind + #define polyvox_placeholder_1 _1 + #define polyvox_placeholder_2 _2 + //As long as we're requiring boost, we'll use it to compensate //for the missing cstdint header too. @@ -68,6 +73,9 @@ freely, subject to the following restrictions: #include #define polyvox_shared_ptr std::shared_ptr #define polyvox_function std::function + #define polyvox_bind std::bind + #define polyvox_placeholder_1 std::placeholders::_1 + #define polyvox_placeholder_2 std::placeholders::_2 #define polyvox_hash std::hash #endif diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index 9e705091..e5ef8fff 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -151,14 +151,14 @@ namespace PolyVox /// gets called when a new region is allocated and needs to be filled /// NOTE: accessing ANY voxels outside this region during the process of this function /// is absolutely unsafe - std::function&, Region)> m_LoadCallback; + polyvox_function&, Region)> m_LoadCallback; /// this function can be called by m_LoadCallback without causing any weird effects bool load_setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const; /// gets called when a Region needs to be stored by the user, because Volume will erase it right after /// this function returns /// NOTE: accessing ANY voxels outside this region during the process of this function /// is absolutely unsafe - std::function&, Region)> m_UnloadCallback; + polyvox_function&, Region)> m_UnloadCallback; private: Block* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; void eraseBlock(typename std::map >::iterator itBlock) const;