From 0c97756a0caa28d75e5f512b1513a94abe6318a2 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 5 Sep 2011 21:44:02 +0100 Subject: [PATCH 1/3] GCC fixes --- library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.h | 1 + library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h | 2 +- library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl | 4 ++-- library/PolyVoxCore/include/PolyVoxCore/RawVolume.h | 2 +- library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h | 2 +- library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.h | 2 ++ library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.inl | 3 ++- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.h b/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.h index 24499451..572cb0f1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.h +++ b/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.h @@ -30,6 +30,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Array.h" #include +#include //For runtime_error namespace PolyVox { diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index dac1004e..ba6e5523 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -163,7 +163,7 @@ namespace PolyVox #if defined(_MSC_VER) class Sampler : public Volume::Sampler< LargeVolume > //This line works on VS2010 #else - class Sampler : public Volume::Sampler Nested< LargeVolume > //This line works on GCC + class Sampler : public Volume::template Sampler< LargeVolume > //This line works on GCC #endif { public: diff --git a/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl b/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl index 367c5379..211e281b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl @@ -259,9 +259,9 @@ namespace PolyVox bool MeshDecimator::collapseChangesFaceNormals(uint32_t uSrc, uint32_t uDst, float fThreshold) { bool faceFlipped = false; - vector& triangles = trianglesUsingVertex[uSrc]; + std::vector& triangles = trianglesUsingVertex[uSrc]; - for(vector::iterator triIter = triangles.begin(); triIter != triangles.end(); triIter++) + for(std::vector::iterator triIter = triangles.begin(); triIter != triangles.end(); triIter++) { uint32_t tri = *triIter; diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index de56e31e..f5106e7d 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -52,7 +52,7 @@ namespace PolyVox #if defined(_MSC_VER) class Sampler : public Volume::Sampler< RawVolume > //This line works on VS2010 #else - class Sampler : public Volume::Sampler Nested< RawVolume > //This line works on GCC + class Sampler : public Volume::template Sampler< RawVolume > //This line works on GCC #endif { public: diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 58efadc6..6ddeedb5 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -77,7 +77,7 @@ namespace PolyVox #if defined(_MSC_VER) class Sampler : public Volume::Sampler< SimpleVolume > //This line works on VS2010 #else - class Sampler : public Volume::Sampler Nested< SimpleVolume > //This line works on GCC + class Sampler : public Volume::template Sampler< SimpleVolume > //This line works on GCC #endif { public: diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.h b/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.h index 1e0fa526..f223f41b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.h +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.h @@ -24,6 +24,8 @@ freely, subject to the following restrictions: #ifndef __PolyVox_VolumeResampler_H__ #define __PolyVox_VolumeResampler_H__ +#include + namespace PolyVox { template< template class SrcVolumeType, template class DestVolumeType, typename VoxelType> diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.inl index 6842c78f..9a5ffdeb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeResampler.inl @@ -119,7 +119,8 @@ namespace PolyVox uint8_t voxel110Den = voxel110.getDensity(); uint8_t voxel111Den = voxel111.getDensity(); - float dummy; + //FIXME - should accept all float parameters, but GCC complains? + double dummy; sx = modf(sx, &dummy); sy = modf(sy, &dummy); sz = modf(sz, &dummy); From df035d523734cc392d131fa9103126dffa5caaff Mon Sep 17 00:00:00 2001 From: David Williams Date: Thu, 8 Sep 2011 21:29:23 +0100 Subject: [PATCH 2/3] Fixed memory leaks. --- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl | 1 + library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h | 1 + library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl | 2 +- .../PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl | 6 ++++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 75486746..721488e0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -103,6 +103,7 @@ namespace PolyVox LargeVolume::~LargeVolume() { flushAll(); + delete[] m_pUncompressedBorderData; } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 6ddeedb5..0a45eb0b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -49,6 +49,7 @@ namespace PolyVox { public: Block(uint16_t uSideLength = 0); + ~Block(); uint16_t getSideLength(void) const; VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const; diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index ace3929e..21f960a9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -71,7 +71,7 @@ namespace PolyVox SimpleVolume::~SimpleVolume() { delete[] m_pBlocks; - m_pBlocks = 0; + delete[] m_pUncompressedBorderData; } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl index 9b2d0c85..03e8c687 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl @@ -35,6 +35,12 @@ namespace PolyVox } } + template + SimpleVolume::Block::~Block() + { + delete[] m_tUncompressedData; + } + template uint16_t SimpleVolume::Block::getSideLength(void) const { From e4535b1255d85b4d13b8dc54e98632fb1e7d096c Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Wed, 21 Sep 2011 00:19:35 +0200 Subject: [PATCH 3/3] Add previousVoxel to raycast result. Thanks to Sceptrix for the patch http://thermite3d.org/phpBB3/viewtopic.php?t=243 --- library/PolyVoxCore/include/PolyVoxCore/Raycast.h | 1 + library/PolyVoxCore/include/PolyVoxCore/Raycast.inl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Raycast.h b/library/PolyVoxCore/include/PolyVoxCore/Raycast.h index b94cf5f8..860f4efb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Raycast.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Raycast.h @@ -41,6 +41,7 @@ namespace PolyVox bool foundIntersection; ///If an intersection was found then this field holds the intersecting voxel, otherwise it is undefined. Vector3DInt32 intersectionVoxel; + Vector3DInt32 previousVoxel; }; /// The Raycast class can be used to find the fist filled voxel along a given path. diff --git a/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl b/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl index fb0f99ef..2c051073 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl @@ -143,6 +143,7 @@ namespace PolyVox m_result.intersectionVoxel = Vector3DInt32(i,j,k); return; } + m_result.previousVoxel = Vector3DInt32(i,j,k); if(tx <= ty && tx <= tz) { @@ -174,5 +175,6 @@ namespace PolyVox //Didn't hit anything m_result.foundIntersection = false; m_result.intersectionVoxel = Vector3DInt32(0,0,0); + m_result.previousVoxel = Vector3DInt32(0,0,0); } } \ No newline at end of file