Merge branch 'develop' of git@gitorious.org:polyvox/polyvox.git into develop

This commit is contained in:
unknown 2012-10-27 15:49:43 +02:00
commit 313f7a11ec
12 changed files with 1103 additions and 750 deletions

View File

@ -72,22 +72,28 @@ endif()
ADD_SUBDIRECTORY(library)
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
IF(ENABLE_EXAMPLES)
IF(ENABLE_EXAMPLES AND QT_QTOPENGL_FOUND)
ADD_SUBDIRECTORY(examples/Basic)
ADD_SUBDIRECTORY(examples/Paging)
ADD_SUBDIRECTORY(examples/OpenGL)
ADD_SUBDIRECTORY(examples/SmoothLOD)
ENDIF(ENABLE_EXAMPLES)
SET(BUILD_EXAMPLES ON)
ELSE()
SET(BUILD_EXAMPLES OFF)
ENDIF()
INCLUDE(Packaging.cmake)
OPTION(ENABLE_TESTS "Should the tests be built" ON)
IF(ENABLE_TESTS)
IF(ENABLE_TESTS AND QT_QTTEST_FOUND)
INCLUDE(CTest)
MARK_AS_ADVANCED(FORCE DART_TESTING_TIMEOUT) #This is only needed to hide the variable in the GUI (CMake bug) until 2.8.5
MARK_AS_ADVANCED(FORCE BUILD_TESTING)
ADD_SUBDIRECTORY(tests)
ENDIF(ENABLE_TESTS)
SET(BUILD_TESTS ON)
ELSE()
SET(BUILD_TESTS OFF)
ENDIF()
#Check if we will building _and_ bundling the docs
IF(DOXYGEN_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
@ -98,8 +104,8 @@ ENDIF()
ADD_SUBDIRECTORY(documentation)
add_feature_info("Examples" ENABLE_EXAMPLES "Examples of PolyVox usage")
add_feature_info("Tests" ENABLE_TESTS "Unit tests")
add_feature_info("Examples" BUILD_EXAMPLES "Examples of PolyVox usage")
add_feature_info("Tests" BUILD_TESTS "Unit tests")
add_feature_info("Bindings" BUILD_BINDINGS "SWIG bindings")
add_feature_info("API docs" DOXYGEN_FOUND "HTML documentation of the API")
add_feature_info("Qt Help" BUILD_AND_BUNDLE_DOCS "API docs in Qt Help format")
@ -112,8 +118,8 @@ MESSAGE(STATUS "")
MESSAGE(STATUS "Summary")
MESSAGE(STATUS "-------")
MESSAGE(STATUS "Library type: " ${LIBRARY_TYPE})
MESSAGE(STATUS "Build examples: " ${ENABLE_EXAMPLES})
MESSAGE(STATUS "Build tests: " ${ENABLE_TESTS})
MESSAGE(STATUS "Build examples: " ${BUILD_EXAMPLES})
MESSAGE(STATUS "Build tests: " ${BUILD_TESTS})
MESSAGE(STATUS "Build bindings: " ${BUILD_BINDINGS})
MESSAGE(STATUS "API Docs available: " ${DOXYGEN_FOUND})
MESSAGE(STATUS " - Qt Help bundling: " ${BUILD_AND_BUNDLE_DOCS})

File diff suppressed because it is too large Load Diff

View File

@ -58,10 +58,6 @@ namespace PolyVox
memset(m_previousSliceVertices.getRawData(), 0xff, m_previousSliceVertices.getNoOfElements() * sizeof(IndexAndMaterial));
memset(m_currentSliceVertices.getRawData(), 0xff, m_currentSliceVertices.getNoOfElements() * sizeof(IndexAndMaterial));
uint32_t uRegionWidth = m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 1;
uint32_t uRegionHeight = m_regSizeInVoxels.getUpperCorner().getY() - m_regSizeInVoxels.getLowerCorner().getY() + 1;
uint32_t uRegionDepth = m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 1;
m_vecQuads[NegativeX].resize(m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 2);
m_vecQuads[PositiveX].resize(m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 2);
@ -96,20 +92,20 @@ namespace PolyVox
// X
if(m_funcIsQuadNeededCallback(currentVoxel, negXVoxel, material))
{
uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v2 = addVertex(regX - 0.5f, regY + 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v0 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
uint32_t v2 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
m_vecQuads[NegativeX][regX].push_back(Quad(v0, v1, v2, v3));
}
if(m_funcIsQuadNeededCallback(negXVoxel, currentVoxel, material))
{
uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v2 = addVertex(regX - 0.5f, regY + 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v0 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
uint32_t v2 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
m_vecQuads[PositiveX][regX].push_back(Quad(v0, v3, v2, v1));
}
@ -117,20 +113,20 @@ namespace PolyVox
// Y
if(m_funcIsQuadNeededCallback(currentVoxel, negYVoxel, material))
{
uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(regX + 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v0 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
m_vecQuads[NegativeY][regY].push_back(Quad(v0, v1, v2, v3));
}
if(m_funcIsQuadNeededCallback(negYVoxel, currentVoxel, material))
{
uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(regX + 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices);
uint32_t v0 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
uint32_t v3 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) + 0.5f, material, m_currentSliceVertices);
m_vecQuads[PositiveY][regY].push_back(Quad(v0, v3, v2, v1));
}
@ -138,20 +134,20 @@ namespace PolyVox
// Z
if(m_funcIsQuadNeededCallback(currentVoxel, negZVoxel, material))
{
uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(regX + 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v3 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v0 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v3 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
m_vecQuads[NegativeZ][regZ].push_back(Quad(v0, v1, v2, v3));
}
if(m_funcIsQuadNeededCallback(negZVoxel, currentVoxel, material))
{
uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(regX + 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v3 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices);
uint32_t v0 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v1 = addVertex(static_cast<float>(regX) - 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v2 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) + 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
uint32_t v3 = addVertex(static_cast<float>(regX) + 0.5f, static_cast<float>(regY) - 0.5f, static_cast<float>(regZ) - 0.5f, material, m_previousSliceVertices);
m_vecQuads[PositiveZ][regZ].push_back(Quad(v0, v3, v2, v1));
}
@ -217,7 +213,7 @@ namespace PolyVox
}
//If we have an existing vertex and the material matches then we can return it.
if(rEntry.uMaterial == uMaterialIn)
if(rEntry.uMaterial == static_cast<int32_t>(uMaterialIn))
{
return rEntry.iIndex;
}

View File

@ -107,7 +107,7 @@ namespace PolyVox
/// The default implementation of this function just returns the constant '1'. There's not much else it can do, as it needs to work with primitive
/// types and the actual value of the type is already being considered to be the density. Specialisations of this class can modify this behaviour.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MaterialType convertToMaterial(VoxelType voxel)
MaterialType convertToMaterial(VoxelType /*voxel*/)
{
return 1;
}

View File

@ -159,7 +159,7 @@ namespace PolyVox
return voxel.getDensity();
}
MaterialType convertToMaterial(Density<Type> voxel)
MaterialType convertToMaterial(Density<Type> /*voxel*/)
{
return 1;
}

View File

@ -40,6 +40,8 @@ namespace PolyVox
/// OUT OF DATE SINCE UNCLASSING
////////////////////////////////////////////////////////////////////////////////
/// \file Raycast.h
///
/// The principle behind raycasting is to fire a 'ray' through the volume and determine
/// what (if anything) that ray hits. This simple test can be used for the purpose of
/// picking, visibility checks, lighting calculations, or numerous other applications.

View File

@ -35,8 +35,8 @@ namespace PolyVox
// Thanks to Jetro Lauha of Fathammer in Helsinki, Finland for reporting this error.
//
// Jetro also points out that the computations of i, j, iend, and jend are incorrectly rounded if the line
// coordinates are allowed to go negative. While that was not really the intent of the code that is, I
// assumed grids to be numbered from (0, 0) to (m, n) I'm at fault for not making my assumption clear.
// coordinates are allowed to go negative. While that was not really the intent of the code -- that is, I
// assumed grids to be numbered from (0, 0) to (m, n) -- I'm at fault for not making my assumption clear.
// Where it is important to handle negative line coordinates the computation of these variables should be
// changed to something like this:
//
@ -52,6 +52,22 @@ namespace PolyVox
// It should simply read "if (ty <= tz)".
//
// This error was reported by Joey Hammer (PixelActive).
/**
* Cast a ray through a volume by specifying the start and end positions
*
* The ray will move from \a v3dStart to \a v3dEnd, calling \a callback for each
* voxel it passes through until \a callback returns \a false. In this case it
* returns a RaycastResults::Interupted. If it passes from start to end
* without \a callback returning \a false, it returns RaycastResults::Completed.
*
* \param volData The volume to pass the ray though
* \param v3dStart The start position in the volume
* \param v3dEnd The end position in the volume
* \param callback The callback to call for each voxel
*
* \return A RaycastResults designating whether the ray hit anything or not
*/
template<typename VolumeType, typename Callback>
RaycastResult raycastWithEndpoints(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dEnd, Callback& callback)
{
@ -129,6 +145,30 @@ namespace PolyVox
return RaycastResults::Completed;
}
/**
* Cast a ray through a volume by specifying the start and a direction
*
* The ray will move from \a v3dStart along \a v3dDirectionAndLength, calling
* \a callback for each voxel it passes through until \a callback returns
* \a false. In this case it returns a RaycastResults::Interupted. If it
* passes from start to end without \a callback returning \a false, it
* returns RaycastResults::Completed.
*
* \note These has been confusion in the past with people not realising
* that the length of the direction vector is important. Most graphics API can provide
* a camera position and view direction for picking purposes, but the view direction is
* usually normalised (i.e. of length one). If you use this view direction directly you
* will only iterate over a single voxel and won't find what you are looking for. Instead
* you must scale the direction vector so that it's length represents the maximum distance
* over which you want the ray to be cast.
*
* \param volData The volume to pass the ray though
* \param v3dStart The start position in the volume
* \param v3dDirectionAndLength The direction and length of the ray
* \param callback The callback to call for each voxel
*
* \return A RaycastResults designating whether the ray hit anything or not
*/
template<typename VolumeType, typename Callback>
RaycastResult raycastWithDirection(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirectionAndLength, Callback& callback)
{

View File

@ -602,15 +602,15 @@ namespace PolyVox
template <uint32_t Size, typename Type>
inline void Vector<Size, Type>::normalise(void) throw()
{
double length = this->length();
Type tLength = this->length();
//FIXME - throw div by zero exception?
if(length < 0.0001f)
if(tLength < 0.0001f)
{
return;
}
for(uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] /= static_cast<Type>(length);
m_tElements[ct] /= tLength;
}
}
}//namespace PolyVox

View File

@ -141,8 +141,8 @@ namespace PolyVox
uint32_t v2 = m_vecTriangles[ct].v2;
bool allMatch =
(m_pOutputMesh->m_vecVertices[v0].material == m_pOutputMesh->m_vecVertices[v1].material) &&
(m_pOutputMesh->m_vecVertices[v1].material == m_pOutputMesh->m_vecVertices[v2].material);
(m_pOutputMesh->m_vecVertices[v0].material - m_pOutputMesh->m_vecVertices[v1].material < 0.001f) &&
(m_pOutputMesh->m_vecVertices[v1].material - m_pOutputMesh->m_vecVertices[v2].material < 0.001f);
if(!allMatch)
{

View File

@ -39,10 +39,6 @@ MACRO(CREATE_TEST headerfile sourcefile executablename)
SET_PROPERTY(TARGET ${executablename} PROPERTY FOLDER "Tests")
ENDMACRO(CREATE_TEST)
IF(NOT QT_QTTEST_FOUND)
MESSAGE(STATUS "QtTest not found. Either install it or disable tests by setting ENABLE_TESTS to OFF")
ENDIF()
INCLUDE_DIRECTORIES(${PolyVox_SOURCE_DIR}/PolyVoxCore/include ${CMAKE_CURRENT_BINARY_DIR})
REMOVE_DEFINITIONS(-DQT_GUI_LIB) #Make sure the tests don't link to the QtGui

View File

@ -104,7 +104,6 @@ void TestCubicSurfaceExtractor::testExecute()
const static uint32_t uExpectedIndices = 9936;
const static uint32_t uMaterialToCheck = 3000;
const static float fExpectedMaterial = 42.0f;
const static float fNoMaterial = 1.0f;
const static uint32_t uIndexToCheck = 2000;
const static uint32_t uExpectedIndex = 1334;

View File

@ -50,7 +50,7 @@ public:
return voxel;
}
float convertToMaterial(float voxel)
float convertToMaterial(float /*voxel*/)
{
return 1;
}
@ -83,7 +83,7 @@ void writeDensityValueToVoxel(int valueToWrite, MaterialDensityPair88& voxel)
}
template<typename VoxelType>
void writeMaterialValueToVoxel(int valueToWrite, VoxelType& voxel)
void writeMaterialValueToVoxel(int /*valueToWrite*/, VoxelType& /*voxel*/)
{
//Most types don't have a material
return;