Merge branch 'develop' into feature/cubiquity-version
Conflicts: library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl library/PolyVoxCore/include/PolyVoxCore/Vector.inl library/PolyVoxCore/source/Impl/Utility.cpp
This commit is contained in:
commit
d9dcf8a33c
@ -2,6 +2,10 @@ Changes for PolyVox version 0.3
|
|||||||
===============================
|
===============================
|
||||||
This release has focused on... (some introduction here).
|
This release has focused on... (some introduction here).
|
||||||
|
|
||||||
|
Error Handling
|
||||||
|
--------------
|
||||||
|
PolyVox now has it's own POLYVOX_ASSERT() macro rather than using the standard assert(). This has some advantages such as allowing a message to be printed and providing file/line information, and it is also possible to enable/disable it independantly of whether you are making a debug or release build
|
||||||
|
|
||||||
Volume wrap modes
|
Volume wrap modes
|
||||||
-----------------
|
-----------------
|
||||||
This release has seen a overhaul of the way PolyVox handles voxel positions which are outside of the volume. It used to be the case that you could specify a border value which would be returned whenever an out-of-volume access was performed, but this was not flexible enough for all use cases. You can now choose between different wrapping modes (border, clamp, etc) and apply them to both the volume itself or to samplers. If you have multiple samplers pointing at the same volume then you can choose to have different wrap modes for each of them.
|
This release has seen a overhaul of the way PolyVox handles voxel positions which are outside of the volume. It used to be the case that you could specify a border value which would be returned whenever an out-of-volume access was performed, but this was not flexible enough for all use cases. You can now choose between different wrapping modes (border, clamp, etc) and apply them to both the volume itself or to samplers. If you have multiple samplers pointing at the same volume then you can choose to have different wrap modes for each of them.
|
||||||
|
@ -26,7 +26,7 @@ PROJECT(PolyVox)
|
|||||||
|
|
||||||
SET(POLYVOX_VERSION_MAJOR "0")
|
SET(POLYVOX_VERSION_MAJOR "0")
|
||||||
SET(POLYVOX_VERSION_MINOR "2")
|
SET(POLYVOX_VERSION_MINOR "2")
|
||||||
SET(POLYVOX_VERSION_PATCH "0")
|
SET(POLYVOX_VERSION_PATCH "1")
|
||||||
SET(POLYVOX_VERSION "${POLYVOX_VERSION_MAJOR}.${POLYVOX_VERSION_MINOR}.${POLYVOX_VERSION_PATCH}" CACHE STRING "PolyVox version")
|
SET(POLYVOX_VERSION "${POLYVOX_VERSION_MAJOR}.${POLYVOX_VERSION_MINOR}.${POLYVOX_VERSION_PATCH}" CACHE STRING "PolyVox version")
|
||||||
MARK_AS_ADVANCED(FORCE POLYVOX_VERSION)
|
MARK_AS_ADVANCED(FORCE POLYVOX_VERSION)
|
||||||
|
|
||||||
@ -69,6 +69,10 @@ if(CMAKE_CXX_COMPILER MATCHES "clang")
|
|||||||
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT MSVC) #This is causing problems in Visual Studio so disable it for now
|
||||||
|
INCLUDE(cmake/Modules/CheckCXX11Features.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(library)
|
ADD_SUBDIRECTORY(library)
|
||||||
|
|
||||||
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
||||||
|
133
cmake/Modules/CheckCXX11Features.cmake
Normal file
133
cmake/Modules/CheckCXX11Features.cmake
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
# - Check which parts of the C++11 standard the compiler supports
|
||||||
|
#
|
||||||
|
# When found it will set the following variables
|
||||||
|
#
|
||||||
|
# CXX11_COMPILER_FLAGS - the compiler flags needed to get C++11 features
|
||||||
|
#
|
||||||
|
# HAS_CXX11_AUTO - auto keyword
|
||||||
|
# HAS_CXX11_AUTO_RET_TYPE - function declaration with deduced return types
|
||||||
|
# HAS_CXX11_CLASS_OVERRIDE - override and final keywords for classes and methods
|
||||||
|
# HAS_CXX11_CONSTEXPR - constexpr keyword
|
||||||
|
# HAS_CXX11_CSTDINT_H - cstdint header
|
||||||
|
# HAS_CXX11_DECLTYPE - decltype keyword
|
||||||
|
# HAS_CXX11_FUNC - __func__ preprocessor constant
|
||||||
|
# HAS_CXX11_INITIALIZER_LIST - initializer list
|
||||||
|
# HAS_CXX11_LAMBDA - lambdas
|
||||||
|
# HAS_CXX11_LIB_REGEX - regex library
|
||||||
|
# HAS_CXX11_LONG_LONG - long long signed & unsigned types
|
||||||
|
# HAS_CXX11_NULLPTR - nullptr
|
||||||
|
# HAS_CXX11_RVALUE_REFERENCES - rvalue references
|
||||||
|
# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members
|
||||||
|
# HAS_CXX11_STATIC_ASSERT - static_assert()
|
||||||
|
# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2011,2012 Rolf Eike Beer <eike@sf-mail.de>
|
||||||
|
# Copyright 2012 Andreas Weis
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
if (NOT CMAKE_CXX_COMPILER_LOADED)
|
||||||
|
message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.8.3)
|
||||||
|
|
||||||
|
#
|
||||||
|
### Check for needed compiler flags
|
||||||
|
#
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG)
|
||||||
|
if (NOT _HAS_CXX11_FLAG)
|
||||||
|
check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (_HAS_CXX11_FLAG)
|
||||||
|
set(CXX11_COMPILER_FLAGS "-std=c++11")
|
||||||
|
elseif (_HAS_CXX0X_FLAG)
|
||||||
|
set(CXX11_COMPILER_FLAGS "-std=c++0x")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
function(cxx11_check_feature FEATURE_NAME RESULT_VAR)
|
||||||
|
if (NOT DEFINED ${RESULT_VAR})
|
||||||
|
set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11_${FEATURE_NAME}")
|
||||||
|
|
||||||
|
set(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features/cxx11-test-${FEATURE_NAME})
|
||||||
|
set(_LOG_NAME "\"${FEATURE_NAME}\"")
|
||||||
|
message(STATUS "Checking C++11 support for ${_LOG_NAME}")
|
||||||
|
|
||||||
|
set(_SRCFILE "${_SRCFILE_BASE}.cpp")
|
||||||
|
set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
|
||||||
|
set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
|
||||||
|
|
||||||
|
if (CROSS_COMPILING)
|
||||||
|
try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}"
|
||||||
|
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||||
|
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||||
|
try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}"
|
||||||
|
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||||
|
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||||
|
else (CROSS_COMPILING)
|
||||||
|
try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
|
||||||
|
"${_bindir}" "${_SRCFILE}"
|
||||||
|
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||||
|
if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
|
||||||
|
set(${RESULT_VAR} TRUE)
|
||||||
|
else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
|
||||||
|
set(${RESULT_VAR} FALSE)
|
||||||
|
endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
|
||||||
|
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||||
|
try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
|
||||||
|
"${_bindir}_fail" "${_SRCFILE_FAIL}"
|
||||||
|
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||||
|
if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
|
||||||
|
set(${RESULT_VAR} TRUE)
|
||||||
|
else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
|
||||||
|
set(${RESULT_VAR} FALSE)
|
||||||
|
endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
|
||||||
|
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||||
|
endif (CROSS_COMPILING)
|
||||||
|
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
|
||||||
|
try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}"
|
||||||
|
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||||
|
if (_TMP_RESULT)
|
||||||
|
set(${RESULT_VAR} FALSE)
|
||||||
|
else (_TMP_RESULT)
|
||||||
|
set(${RESULT_VAR} TRUE)
|
||||||
|
endif (_TMP_RESULT)
|
||||||
|
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
|
||||||
|
|
||||||
|
if (${RESULT_VAR})
|
||||||
|
message(STATUS "Checking C++11 support for ${_LOG_NAME}: works")
|
||||||
|
else (${RESULT_VAR})
|
||||||
|
message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported")
|
||||||
|
endif (${RESULT_VAR})
|
||||||
|
set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
|
||||||
|
endif (NOT DEFINED ${RESULT_VAR})
|
||||||
|
endfunction(cxx11_check_feature)
|
||||||
|
|
||||||
|
#cxx11_check_feature("__func__" HAS_CXX11_FUNC)
|
||||||
|
#cxx11_check_feature("auto" HAS_CXX11_AUTO)
|
||||||
|
#cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE)
|
||||||
|
#cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE)
|
||||||
|
cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR)
|
||||||
|
cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H)
|
||||||
|
#cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE)
|
||||||
|
#cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST)
|
||||||
|
#cxx11_check_feature("lambda" HAS_CXX11_LAMBDA)
|
||||||
|
#cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG)
|
||||||
|
#cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR)
|
||||||
|
#cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX)
|
||||||
|
#cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES)
|
||||||
|
#cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER)
|
||||||
|
cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT)
|
||||||
|
#cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
cxx11_check_feature("shared_ptr" HAS_CXX11_SHARED_PTR)
|
8
cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp
Normal file
8
cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
if (!__func__)
|
||||||
|
return 1;
|
||||||
|
if (!(*__func__))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
12
cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp
Normal file
12
cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
auto i = 5;
|
||||||
|
auto f = 3.14159f;
|
||||||
|
auto d = 3.14159;
|
||||||
|
bool ret = (
|
||||||
|
(sizeof(f) < sizeof(d)) &&
|
||||||
|
(sizeof(i) == sizeof(int))
|
||||||
|
);
|
||||||
|
return ret ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// must fail because there is no initializer
|
||||||
|
auto i;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
auto foo(int i) -> int {
|
||||||
|
return i - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return foo(1);
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
class base {
|
||||||
|
public:
|
||||||
|
virtual int foo(int a)
|
||||||
|
{ return 4 + a; }
|
||||||
|
int bar(int a) final
|
||||||
|
{ return a - 2; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class sub final : public base {
|
||||||
|
public:
|
||||||
|
virtual int foo(int a) override
|
||||||
|
{ return 8 + 2 * a; };
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
base b;
|
||||||
|
sub s;
|
||||||
|
|
||||||
|
return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
class base {
|
||||||
|
public:
|
||||||
|
virtual int foo(int a)
|
||||||
|
{ return 4 + a; }
|
||||||
|
virtual int bar(int a) final
|
||||||
|
{ return a - 2; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class sub final : public base {
|
||||||
|
public:
|
||||||
|
virtual int foo(int a) override
|
||||||
|
{ return 8 + 2 * a; };
|
||||||
|
virtual int bar(int a)
|
||||||
|
{ return a; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class impossible : public sub { };
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
base b;
|
||||||
|
sub s;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
19
cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp
Normal file
19
cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
constexpr int square(int x)
|
||||||
|
{
|
||||||
|
return x*x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr int the_answer()
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int test_arr[square(3)];
|
||||||
|
bool ret = (
|
||||||
|
(square(the_answer()) == 1764) &&
|
||||||
|
(sizeof(test_arr)/sizeof(test_arr[0]) == 9)
|
||||||
|
);
|
||||||
|
return ret ? 0 : 1;
|
||||||
|
}
|
11
cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp
Normal file
11
cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
bool test =
|
||||||
|
(sizeof(int8_t) == 1) &&
|
||||||
|
(sizeof(int16_t) == 2) &&
|
||||||
|
(sizeof(int32_t) == 4) &&
|
||||||
|
(sizeof(int64_t) == 8);
|
||||||
|
return test ? 0 : 1;
|
||||||
|
}
|
10
cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp
Normal file
10
cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
bool check_size(int i)
|
||||||
|
{
|
||||||
|
return sizeof(int) == sizeof(decltype(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
bool ret = check_size(42);
|
||||||
|
return ret ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class seq {
|
||||||
|
public:
|
||||||
|
seq(std::initializer_list<int> list);
|
||||||
|
|
||||||
|
int length() const;
|
||||||
|
private:
|
||||||
|
std::vector<int> m_v;
|
||||||
|
};
|
||||||
|
|
||||||
|
seq::seq(std::initializer_list<int> list)
|
||||||
|
: m_v(list)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int seq::length() const
|
||||||
|
{
|
||||||
|
return m_v.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
seq a = {18, 20, 2, 0, 4, 7};
|
||||||
|
|
||||||
|
return (a.length() == 6) ? 0 : 1;
|
||||||
|
}
|
5
cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp
Normal file
5
cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
return ([&ret]() -> int { return ret; })();
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
long long l;
|
||||||
|
unsigned long long ul;
|
||||||
|
|
||||||
|
return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
|
||||||
|
}
|
6
cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp
Normal file
6
cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
void *v = nullptr;
|
||||||
|
|
||||||
|
return v ? 1 : 0;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int i = nullptr;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
26
cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp
Normal file
26
cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
int parse_line(std::string const& line)
|
||||||
|
{
|
||||||
|
std::string tmp;
|
||||||
|
if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
|
||||||
|
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
|
||||||
|
} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
|
||||||
|
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
|
||||||
|
} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
|
||||||
|
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
|
||||||
|
} else {
|
||||||
|
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
|
||||||
|
}
|
||||||
|
return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
|
||||||
|
(parse_line("f 7//7 3//-3 -2//2") == 3) &&
|
||||||
|
(parse_line("f 7/7 3/-3 -2/2") == 3) &&
|
||||||
|
(parse_line("f 7 3 -2") == 3);
|
||||||
|
return test ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
class rvmove {
|
||||||
|
public:
|
||||||
|
void *ptr;
|
||||||
|
char *array;
|
||||||
|
|
||||||
|
rvmove()
|
||||||
|
: ptr(0),
|
||||||
|
array(new char[10])
|
||||||
|
{
|
||||||
|
ptr = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
rvmove(rvmove &&other)
|
||||||
|
: ptr(other.ptr),
|
||||||
|
array(other.array)
|
||||||
|
{
|
||||||
|
other.array = 0;
|
||||||
|
other.ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
~rvmove()
|
||||||
|
{
|
||||||
|
assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0)));
|
||||||
|
delete[] array;
|
||||||
|
}
|
||||||
|
|
||||||
|
rvmove &operator=(rvmove &&other)
|
||||||
|
{
|
||||||
|
delete[] array;
|
||||||
|
ptr = other.ptr;
|
||||||
|
array = other.array;
|
||||||
|
other.array = 0;
|
||||||
|
other.ptr = 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rvmove create()
|
||||||
|
{
|
||||||
|
return rvmove();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
rvmove(const rvmove &);
|
||||||
|
rvmove &operator=(const rvmove &);
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
rvmove mine;
|
||||||
|
if (mine.ptr != &mine)
|
||||||
|
return 1;
|
||||||
|
mine = rvmove::create();
|
||||||
|
if (mine.ptr == &mine)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
#include <memory>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::shared_ptr<int> test;
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
struct foo {
|
||||||
|
char bar;
|
||||||
|
int baz;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
bool ret = (
|
||||||
|
(sizeof(foo::bar) == 1) &&
|
||||||
|
(sizeof(foo::baz) >= sizeof(foo::bar)) &&
|
||||||
|
(sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz))
|
||||||
|
);
|
||||||
|
return ret ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
struct foo {
|
||||||
|
int baz;
|
||||||
|
double bar;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return (sizeof(foo::bar) == 4) ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
static_assert(0 < 1, "your ordering of integers is screwed");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
static_assert(1 < 0, "your ordering of integers is screwed");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
int Accumulate()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Ts>
|
||||||
|
int Accumulate(T v, Ts... vs)
|
||||||
|
{
|
||||||
|
return v + Accumulate(vs...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int... Is>
|
||||||
|
int CountElements()
|
||||||
|
{
|
||||||
|
return sizeof...(Is);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int acc = Accumulate(1, 2, 3, 4, -5);
|
||||||
|
int count = CountElements<1,2,3,4,5>();
|
||||||
|
return ((acc == 5) && (count == 5)) ? 0 : 1;
|
||||||
|
}
|
@ -44,7 +44,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -52,7 +52,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -46,7 +46,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -44,7 +44,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -20,10 +20,13 @@
|
|||||||
# 3. This notice may not be removed or altered from any source
|
# 3. This notice may not be removed or altered from any source
|
||||||
# distribution.
|
# distribution.
|
||||||
|
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
|
||||||
|
|
||||||
PROJECT(PolyVoxCore)
|
PROJECT(PolyVoxCore)
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
#Set up the C++11 feature header file based on the CheckCXX11Features script
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/PolyVoxCore/Impl/CompilerCapabilities.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/PolyVoxCore/Impl/CompilerCapabilities.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
#Projects source files
|
#Projects source files
|
||||||
SET(CORE_SRC_FILES
|
SET(CORE_SRC_FILES
|
||||||
source/ArraySizes.cpp
|
source/ArraySizes.cpp
|
||||||
@ -91,6 +94,7 @@ SET(CORE_INC_FILES
|
|||||||
)
|
)
|
||||||
|
|
||||||
SET(IMPL_SRC_FILES
|
SET(IMPL_SRC_FILES
|
||||||
|
source/Impl/ErrorHandling.cpp
|
||||||
source/Impl/MarchingCubesTables.cpp
|
source/Impl/MarchingCubesTables.cpp
|
||||||
source/Impl/RandomUnitVectors.cpp
|
source/Impl/RandomUnitVectors.cpp
|
||||||
source/Impl/RandomVectors.cpp
|
source/Impl/RandomVectors.cpp
|
||||||
@ -103,6 +107,7 @@ SET(IMPL_INC_FILES
|
|||||||
include/PolyVoxCore/Impl/AStarPathfinderImpl.h
|
include/PolyVoxCore/Impl/AStarPathfinderImpl.h
|
||||||
include/PolyVoxCore/Impl/Block.h
|
include/PolyVoxCore/Impl/Block.h
|
||||||
include/PolyVoxCore/Impl/Block.inl
|
include/PolyVoxCore/Impl/Block.inl
|
||||||
|
include/PolyVoxCore/Impl/ErrorHandling.h
|
||||||
include/PolyVoxCore/Impl/MarchingCubesTables.h
|
include/PolyVoxCore/Impl/MarchingCubesTables.h
|
||||||
include/PolyVoxCore/Impl/RandomUnitVectors.h
|
include/PolyVoxCore/Impl/RandomUnitVectors.h
|
||||||
include/PolyVoxCore/Impl/RandomVectors.h
|
include/PolyVoxCore/Impl/RandomVectors.h
|
||||||
@ -123,7 +128,7 @@ SOURCE_GROUP("Sources\\Impl" FILES ${IMPL_SRC_FILES})
|
|||||||
SOURCE_GROUP("Headers\\Impl" FILES ${IMPL_INC_FILES})
|
SOURCE_GROUP("Headers\\Impl" FILES ${IMPL_INC_FILES})
|
||||||
|
|
||||||
#Tell CMake the paths
|
#Tell CMake the paths
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
#Core
|
#Core
|
||||||
#Build
|
#Build
|
||||||
|
@ -29,6 +29,7 @@ freely, subject to the following restrictions:
|
|||||||
#include "PolyVoxForwardDeclarations.h"
|
#include "PolyVoxForwardDeclarations.h"
|
||||||
|
|
||||||
#include "PolyVoxCore/Array.h"
|
#include "PolyVoxCore/Array.h"
|
||||||
|
#include "PolyVoxCore/BaseVolume.h" //For wrap modes... should move these?
|
||||||
#include "PolyVoxCore/DefaultIsQuadNeeded.h"
|
#include "PolyVoxCore/DefaultIsQuadNeeded.h"
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVoxCore/SurfaceMesh.h"
|
||||||
|
|
||||||
@ -109,7 +110,13 @@ namespace PolyVox
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial<typename VolumeType::VoxelType> >* result, bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded());
|
// This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template
|
||||||
|
// Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC?
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(0), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded());
|
||||||
|
#else
|
||||||
|
CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(0), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded());
|
||||||
|
#endif
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
@ -144,6 +151,10 @@ namespace PolyVox
|
|||||||
//This constant defines the maximum number of quads which can share a
|
//This constant defines the maximum number of quads which can share a
|
||||||
//vertex in a cubic style mesh. See the initialisation for more details.
|
//vertex in a cubic style mesh. See the initialisation for more details.
|
||||||
static const uint32_t MaxVerticesPerPosition;
|
static const uint32_t MaxVerticesPerPosition;
|
||||||
|
|
||||||
|
//The wrap mode
|
||||||
|
WrapMode m_eWrapMode;
|
||||||
|
typename VolumeType::VoxelType m_tBorderValue;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +35,13 @@ namespace PolyVox
|
|||||||
const uint32_t CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::MaxVerticesPerPosition = 6;
|
const uint32_t CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::MaxVerticesPerPosition = 6;
|
||||||
|
|
||||||
template<typename VolumeType, typename IsQuadNeeded>
|
template<typename VolumeType, typename IsQuadNeeded>
|
||||||
CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial<typename VolumeType::VoxelType> >* result, bool bMergeQuads, IsQuadNeeded isQuadNeeded)
|
CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded)
|
||||||
:m_volData(volData)
|
:m_volData(volData)
|
||||||
,m_regSizeInVoxels(region)
|
,m_regSizeInVoxels(region)
|
||||||
,m_meshCurrent(result)
|
,m_meshCurrent(result)
|
||||||
,m_bMergeQuads(bMergeQuads)
|
,m_bMergeQuads(bMergeQuads)
|
||||||
|
,m_eWrapMode(eWrapMode)
|
||||||
|
,m_tBorderValue(tBorderValue)
|
||||||
{
|
{
|
||||||
m_funcIsQuadNeededCallback = isQuadNeeded;
|
m_funcIsQuadNeededCallback = isQuadNeeded;
|
||||||
}
|
}
|
||||||
@ -72,6 +74,7 @@ namespace PolyVox
|
|||||||
m_vecQuads[PositiveZ].resize(m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 2);
|
m_vecQuads[PositiveZ].resize(m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 2);
|
||||||
|
|
||||||
typename VolumeType::Sampler volumeSampler(m_volData);
|
typename VolumeType::Sampler volumeSampler(m_volData);
|
||||||
|
volumeSampler.setWrapMode(m_eWrapMode, m_tBorderValue);
|
||||||
|
|
||||||
for(int32_t z = m_regSizeInVoxels.getLowerCorner().getZ(); z <= m_regSizeInVoxels.getUpperCorner().getZ(); z++)
|
for(int32_t z = m_regSizeInVoxels.getLowerCorner().getZ(); z <= m_regSizeInVoxels.getUpperCorner().getZ(); z++)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@ freely, subject to the following restrictions:
|
|||||||
#include "PolyVoxCore/DefaultIsQuadNeeded.h"
|
#include "PolyVoxCore/DefaultIsQuadNeeded.h"
|
||||||
|
|
||||||
#include "PolyVoxCore/Array.h"
|
#include "PolyVoxCore/Array.h"
|
||||||
|
#include "PolyVoxCore/BaseVolume.h" //For wrap modes... should move these?
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVoxCore/SurfaceMesh.h"
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
@ -35,7 +36,13 @@ namespace PolyVox
|
|||||||
class CubicSurfaceExtractorWithNormals
|
class CubicSurfaceExtractorWithNormals
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded());
|
// This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template
|
||||||
|
// Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC?
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(0), IsQuadNeeded isQuadNeeded = IsQuadNeeded());
|
||||||
|
#else
|
||||||
|
CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(0), IsQuadNeeded isQuadNeeded = IsQuadNeeded());
|
||||||
|
#endif
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
@ -51,6 +58,10 @@ namespace PolyVox
|
|||||||
|
|
||||||
//Information about the region we are currently processing
|
//Information about the region we are currently processing
|
||||||
Region m_regSizeInVoxels;
|
Region m_regSizeInVoxels;
|
||||||
|
|
||||||
|
//The wrap mode
|
||||||
|
WrapMode m_eWrapMode;
|
||||||
|
typename VolumeType::VoxelType m_tBorderValue;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,13 @@ freely, subject to the following restrictions:
|
|||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template<typename VolumeType, typename IsQuadNeeded>
|
template<typename VolumeType, typename IsQuadNeeded>
|
||||||
CubicSurfaceExtractorWithNormals<VolumeType, IsQuadNeeded>::CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, IsQuadNeeded isQuadNeeded)
|
CubicSurfaceExtractorWithNormals<VolumeType, IsQuadNeeded>::CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, IsQuadNeeded isQuadNeeded)
|
||||||
:m_volData(volData)
|
:m_volData(volData)
|
||||||
,m_sampVolume(volData)
|
,m_sampVolume(volData)
|
||||||
,m_meshCurrent(result)
|
,m_meshCurrent(result)
|
||||||
,m_regSizeInVoxels(region)
|
,m_regSizeInVoxels(region)
|
||||||
|
,m_eWrapMode(eWrapMode)
|
||||||
|
,m_tBorderValue(tBorderValue)
|
||||||
{
|
{
|
||||||
m_funcIsQuadNeededCallback = isQuadNeeded;
|
m_funcIsQuadNeededCallback = isQuadNeeded;
|
||||||
}
|
}
|
||||||
@ -51,7 +53,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
uint32_t material = 0;
|
uint32_t material = 0;
|
||||||
|
|
||||||
if(m_funcIsQuadNeededCallback(m_volData->getVoxelAt(x,y,z), m_volData->getVoxelAt(x+1,y,z), material))
|
if(m_funcIsQuadNeededCallback(m_volData->getVoxelWithWrapping(x,y,z,m_eWrapMode,m_tBorderValue), m_volData->getVoxelWithWrapping(x+1,y,z,m_eWrapMode,m_tBorderValue), material))
|
||||||
{
|
{
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
||||||
@ -61,7 +63,7 @@ namespace PolyVox
|
|||||||
m_meshCurrent->addTriangleCubic(v0,v2,v1);
|
m_meshCurrent->addTriangleCubic(v0,v2,v1);
|
||||||
m_meshCurrent->addTriangleCubic(v1,v2,v3);
|
m_meshCurrent->addTriangleCubic(v1,v2,v3);
|
||||||
}
|
}
|
||||||
if(m_funcIsQuadNeededCallback(m_volData->getVoxelAt(x+1,y,z), m_volData->getVoxelAt(x,y,z), material))
|
if(m_funcIsQuadNeededCallback(m_volData->getVoxelWithWrapping(x+1,y,z,m_eWrapMode,m_tBorderValue), m_volData->getVoxelWithWrapping(x,y,z,m_eWrapMode,m_tBorderValue), material))
|
||||||
{
|
{
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), static_cast<float>(material)));
|
||||||
@ -72,7 +74,7 @@ namespace PolyVox
|
|||||||
m_meshCurrent->addTriangleCubic(v1,v3,v2);
|
m_meshCurrent->addTriangleCubic(v1,v3,v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_funcIsQuadNeededCallback(m_volData->getVoxelAt(x,y,z), m_volData->getVoxelAt(x,y+1,z), material))
|
if(m_funcIsQuadNeededCallback(m_volData->getVoxelWithWrapping(x,y,z,m_eWrapMode,m_tBorderValue), m_volData->getVoxelWithWrapping(x,y+1,z,m_eWrapMode,m_tBorderValue), material))
|
||||||
{
|
{
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), static_cast<float>(material)));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), static_cast<float>(material)));
|
||||||
@ -82,7 +84,7 @@ namespace PolyVox
|
|||||||
m_meshCurrent->addTriangleCubic(v0,v1,v2);
|
m_meshCurrent->addTriangleCubic(v0,v1,v2);
|
||||||
m_meshCurrent->addTriangleCubic(v1,v3,v2);
|
m_meshCurrent->addTriangleCubic(v1,v3,v2);
|
||||||
}
|
}
|
||||||
if(m_funcIsQuadNeededCallback(m_volData->getVoxelAt(x,y+1,z), m_volData->getVoxelAt(x,y,z), material))
|
if(m_funcIsQuadNeededCallback(m_volData->getVoxelWithWrapping(x,y+1,z,m_eWrapMode,m_tBorderValue), m_volData->getVoxelWithWrapping(x,y,z,m_eWrapMode,m_tBorderValue), material))
|
||||||
{
|
{
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), static_cast<float>(material)));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), static_cast<float>(material)));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), static_cast<float>(material)));
|
||||||
@ -93,7 +95,7 @@ namespace PolyVox
|
|||||||
m_meshCurrent->addTriangleCubic(v1,v2,v3);
|
m_meshCurrent->addTriangleCubic(v1,v2,v3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_funcIsQuadNeededCallback(m_volData->getVoxelAt(x,y,z), m_volData->getVoxelAt(x,y,z+1), material))
|
if(m_funcIsQuadNeededCallback(m_volData->getVoxelWithWrapping(x,y,z,m_eWrapMode,m_tBorderValue), m_volData->getVoxelWithWrapping(x,y,z+1,m_eWrapMode,m_tBorderValue), material))
|
||||||
{
|
{
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), static_cast<float>(material)));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), static_cast<float>(material)));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), static_cast<float>(material)));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), static_cast<float>(material)));
|
||||||
@ -103,7 +105,7 @@ namespace PolyVox
|
|||||||
m_meshCurrent->addTriangleCubic(v0,v2,v1);
|
m_meshCurrent->addTriangleCubic(v0,v2,v1);
|
||||||
m_meshCurrent->addTriangleCubic(v1,v2,v3);
|
m_meshCurrent->addTriangleCubic(v1,v2,v3);
|
||||||
}
|
}
|
||||||
if(m_funcIsQuadNeededCallback(m_volData->getVoxelAt(x,y,z+1), m_volData->getVoxelAt(x,y,z), material))
|
if(m_funcIsQuadNeededCallback(m_volData->getVoxelWithWrapping(x,y,z+1,m_eWrapMode,m_tBorderValue), m_volData->getVoxelWithWrapping(x,y,z,m_eWrapMode,m_tBorderValue), material))
|
||||||
{
|
{
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), static_cast<float>(material)));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), static_cast<float>(material)));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), static_cast<float>(material)));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), static_cast<float>(material)));
|
||||||
|
@ -1,148 +1,128 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
3. This notice may not be removed or altered from any source
|
||||||
distribution.
|
distribution.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef __PolyVox_MarchingCubesController_H__
|
#ifndef __PolyVox_MarchingCubesController_H__
|
||||||
#define __PolyVox_MarchingCubesController_H__
|
#define __PolyVox_MarchingCubesController_H__
|
||||||
|
|
||||||
#include "PolyVoxCore/BaseVolume.h"
|
#include "PolyVoxCore/BaseVolume.h"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This class provides a default implementation of a controller for the MarchingCubesSurfaceExtractor. It controls the behaviour of the
|
* This class provides a default implementation of a controller for the MarchingCubesSurfaceExtractor. It controls the behaviour of the
|
||||||
* MarchingCubesSurfaceExtractor and provides the required properties from the underlying voxel type.
|
* MarchingCubesSurfaceExtractor and provides the required properties from the underlying voxel type.
|
||||||
*
|
*
|
||||||
* PolyVox does not enforce any requirements regarding what data must be present in a voxel, and instead allows any primitive or user-defined
|
* PolyVox does not enforce any requirements regarding what data must be present in a voxel, and instead allows any primitive or user-defined
|
||||||
* type to be used. However, the Marching Cubes algorithm does have some requirents about the underlying data in that conceptually it operates
|
* type to be used. However, the Marching Cubes algorithm does have some requirents about the underlying data in that conceptually it operates
|
||||||
* on a <i>density field</i>. In addition, the PolyVox implementation of the Marching Cubes algorithm also understands the idea of each voxel
|
* on a <i>density field</i>. In addition, the PolyVox implementation of the Marching Cubes algorithm also understands the idea of each voxel
|
||||||
* having a material which is copied into the vertex data.
|
* having a material which is copied into the vertex data.
|
||||||
*
|
*
|
||||||
* Because we want the MarchingCubesSurfaceExtractor to work on <i>any</i> voxel type, we use a <i>Marching Cubes controller</i> (passed as
|
* Because we want the MarchingCubesSurfaceExtractor to work on <i>any</i> voxel type, we use a <i>Marching Cubes controller</i> (passed as
|
||||||
* a parameter of the MarchingCubesSurfaceExtractor) to expose the required properties. This parameter defaults to the DefaultMarchingCubesController.
|
* a parameter of the MarchingCubesSurfaceExtractor) to expose the required properties. This parameter defaults to the DefaultMarchingCubesController.
|
||||||
* The main implementation of this class is designed to work with primitives data types, and the class is also specialised for the Material,
|
* The main implementation of this class is designed to work with primitives data types, and the class is also specialised for the Material,
|
||||||
* Density and MaterialdensityPair classes.
|
* Density and MaterialdensityPair classes.
|
||||||
*
|
*
|
||||||
* If you create a custom class for your voxel data then you probably want to include a specialisation of DefaultMarchingCubesController,
|
* If you create a custom class for your voxel data then you probably want to include a specialisation of DefaultMarchingCubesController,
|
||||||
* though you don't have to if you don't want to use the Marching Cubes algorithm or if you prefer to define a seperate Marching Cubes controller
|
* though you don't have to if you don't want to use the Marching Cubes algorithm or if you prefer to define a seperate Marching Cubes controller
|
||||||
* and pass it as an explicit parameter (rather than relying on the default).
|
* and pass it as an explicit parameter (rather than relying on the default).
|
||||||
*
|
*
|
||||||
* For primitive types, the DefaultMarchingCubesController considers the value of the voxel to represent it's density and just returns a constant
|
* For primitive types, the DefaultMarchingCubesController considers the value of the voxel to represent it's density and just returns a constant
|
||||||
* for the material. So you can, for example, run the MarchingCubesSurfaceExtractor on a volume of floats or ints.
|
* for the material. So you can, for example, run the MarchingCubesSurfaceExtractor on a volume of floats or ints.
|
||||||
*
|
*
|
||||||
* It is possible to customise the behaviour of the controller by providing a threshold value through the constructor. The extracted surface
|
* It is possible to customise the behaviour of the controller by providing a threshold value through the constructor. The extracted surface
|
||||||
* will pass through the density value specified by the threshold, and so you should make sure that the threshold value you choose is between
|
* will pass through the density value specified by the threshold, and so you should make sure that the threshold value you choose is between
|
||||||
* the minimum and maximum values found in your volume data. By default it is in the middle of the representable range of the underlying type.
|
* the minimum and maximum values found in your volume data. By default it is in the middle of the representable range of the underlying type.
|
||||||
*
|
*
|
||||||
* \sa MarchingCubesSurfaceExtractor
|
* \sa MarchingCubesSurfaceExtractor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<typename VoxelType>
|
template<typename VoxelType>
|
||||||
class DefaultMarchingCubesController
|
class DefaultMarchingCubesController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Used to inform the MarchingCubesSurfaceExtractor about which type it should use for representing densities.
|
/// Used to inform the MarchingCubesSurfaceExtractor about which type it should use for representing densities.
|
||||||
typedef VoxelType DensityType;
|
typedef VoxelType DensityType;
|
||||||
/// Used to inform the MarchingCubesSurfaceExtractor about which type it should use for representing materials. We're using a float here
|
/// Used to inform the MarchingCubesSurfaceExtractor about which type it should use for representing materials. We're using a float here
|
||||||
/// because this implementation always returns a constant value off 1.0f. PolyVox also uses floats to store the materials in the mesh vertices
|
/// because this implementation always returns a constant value off 1.0f. PolyVox also uses floats to store the materials in the mesh vertices
|
||||||
/// but this is not really desirable on modern hardware. We'll probably come back to material representation in the future.
|
/// but this is not really desirable on modern hardware. We'll probably come back to material representation in the future.
|
||||||
typedef float MaterialType;
|
typedef float MaterialType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* This version of the constructor takes no parameters and sets the threshold to the middle of the representable range of the underlying type.
|
* This version of the constructor takes no parameters and sets the threshold to the middle of the representable range of the underlying type.
|
||||||
* For example, if the voxel type is 'uint8_t' then the representable range is 0-255, and the threshold will be set to 127. On the other hand,
|
* For example, if the voxel type is 'uint8_t' then the representable range is 0-255, and the threshold will be set to 127. On the other hand,
|
||||||
* if the voxel type is 'float' then the representable range is -FLT_MAX to FLT_MAX and the threshold will be set to zero.
|
* if the voxel type is 'float' then the representable range is -FLT_MAX to FLT_MAX and the threshold will be set to zero.
|
||||||
*/
|
*/
|
||||||
DefaultMarchingCubesController(void)
|
DefaultMarchingCubesController(void)
|
||||||
:m_tThreshold(((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2)
|
:m_tThreshold(((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2)
|
||||||
,m_eWrapMode(WrapModes::Border)
|
{
|
||||||
,m_tBorder(VoxelType(0))
|
}
|
||||||
{
|
|
||||||
}
|
/**
|
||||||
|
* Converts the underlying voxel type into a density value.
|
||||||
/**
|
*
|
||||||
* Converts the underlying voxel type into a density value.
|
* The default implementation of this function just returns the voxel type directly and is suitable for primitives types. Specialisations of
|
||||||
*
|
* this class can modify this behaviour.
|
||||||
* The default implementation of this function just returns the voxel type directly and is suitable for primitives types. Specialisations of
|
*/
|
||||||
* this class can modify this behaviour.
|
DensityType convertToDensity(VoxelType voxel)
|
||||||
*/
|
{
|
||||||
DensityType convertToDensity(VoxelType voxel)
|
return voxel;
|
||||||
{
|
}
|
||||||
return voxel;
|
|
||||||
}
|
/**
|
||||||
|
* Converts the underlying voxel type into a material value.
|
||||||
/**
|
*
|
||||||
* Converts the underlying voxel type into a material value.
|
* 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.
|
||||||
* 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;
|
||||||
{
|
}
|
||||||
return 1;
|
|
||||||
}
|
/**
|
||||||
|
* Returns the density value which was passed to the constructor.
|
||||||
VoxelType getBorderValue(void)
|
*
|
||||||
{
|
* As mentioned in the class description, the extracted surface will pass through the density value specified by the threshold, and so you
|
||||||
return m_tBorder;
|
* should make sure that the threshold value you choose is between the minimum and maximum values found in your volume data. By default it
|
||||||
}
|
* is in the middle of the representable range of the underlying type.
|
||||||
|
*/
|
||||||
/**
|
DensityType getThreshold(void)
|
||||||
* Returns the density value which was passed to the constructor.
|
{
|
||||||
*
|
return m_tThreshold;
|
||||||
* As mentioned in the class description, the extracted surface will pass through the density value specified by the threshold, and so you
|
}
|
||||||
* should make sure that the threshold value you choose is between the minimum and maximum values found in your volume data. By default it
|
|
||||||
* is in the middle of the representable range of the underlying type.
|
void setThreshold(DensityType tThreshold)
|
||||||
*/
|
{
|
||||||
DensityType getThreshold(void)
|
m_tThreshold = tThreshold;
|
||||||
{
|
}
|
||||||
return m_tThreshold;
|
|
||||||
}
|
private:
|
||||||
|
DensityType m_tThreshold;
|
||||||
WrapMode getWrapMode(void)
|
};
|
||||||
{
|
}
|
||||||
return m_eWrapMode;
|
|
||||||
}
|
#endif
|
||||||
|
|
||||||
void setThreshold(DensityType tThreshold)
|
|
||||||
{
|
|
||||||
m_tThreshold = tThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType(0))
|
|
||||||
{
|
|
||||||
m_eWrapMode = eWrapMode;
|
|
||||||
m_tBorder = tBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DensityType m_tThreshold;
|
|
||||||
WrapMode m_eWrapMode;
|
|
||||||
VoxelType m_tBorder;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -155,13 +155,11 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
// Default to a threshold value halfway between the min and max possible values.
|
// Default to a threshold value halfway between the min and max possible values.
|
||||||
m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2;
|
m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2;
|
||||||
m_eWrapMode = WrapModes::Border;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMarchingCubesController(DensityType tThreshold)
|
DefaultMarchingCubesController(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
m_eWrapMode = WrapModes::Border;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(Density<Type> voxel)
|
DensityType convertToDensity(Density<Type> voxel)
|
||||||
@ -174,35 +172,18 @@ namespace PolyVox
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Density<Type> getBorderValue(void)
|
|
||||||
{
|
|
||||||
return m_tBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
DensityType getThreshold(void)
|
DensityType getThreshold(void)
|
||||||
{
|
{
|
||||||
return m_tThreshold;
|
return m_tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapMode getWrapMode(void)
|
|
||||||
{
|
|
||||||
return m_eWrapMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setThreshold(DensityType tThreshold)
|
void setThreshold(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWrapMode(WrapMode eWrapMode)
|
|
||||||
{
|
|
||||||
m_eWrapMode = eWrapMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DensityType m_tThreshold;
|
DensityType m_tThreshold;
|
||||||
WrapMode m_eWrapMode;
|
|
||||||
Density<Type> m_tBorder;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* This file provides the default compiler capabilities for for Visual Studio.
|
||||||
|
* On other compilers CMake will detect which features are available and create
|
||||||
|
* a file like this.
|
||||||
|
*
|
||||||
|
* To Enable these features in Visual Studio, define the variables in this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PolyVox_CompilerCapabilities_H__
|
||||||
|
#define __PolyVox_CompilerCapabilities_H__
|
||||||
|
|
||||||
|
//#undef HAS_CXX11_CONSTEXPR
|
||||||
|
|
||||||
|
#define HAS_CXX11_STATIC_ASSERT
|
||||||
|
|
||||||
|
#define HAS_CXX11_CSTDINT_H
|
||||||
|
|
||||||
|
#define HAS_CXX11_SHARED_PTR
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* This file is an input file for the CMake build system. It is processed and
|
||||||
|
* placed in the build directory by CMake.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PolyVox_CompilerCapabilities_H__
|
||||||
|
#define __PolyVox_CompilerCapabilities_H__
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_CONSTEXPR
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_STATIC_ASSERT
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_CSTDINT_H
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_SHARED_PTR
|
||||||
|
|
||||||
|
#endif
|
124
library/PolyVoxCore/include/PolyVoxCore/Impl/ErrorHandling.h
Normal file
124
library/PolyVoxCore/include/PolyVoxCore/Impl/ErrorHandling.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __PolyVox_ErrorHandling_H__
|
||||||
|
#define __PolyVox_ErrorHandling_H__
|
||||||
|
|
||||||
|
#include <cstdlib> //For std::exit
|
||||||
|
#include <iostream> //For std::cerr
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#define POLYVOX_ASSERTS_ENABLED
|
||||||
|
#define POLYVOX_THROW_ENABLED
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define POLYVOX_HALT() __debugbreak()
|
||||||
|
#else
|
||||||
|
#define POLYVOX_HALT() std::exit(EXIT_FAILURE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define POLYVOX_UNUSED(x) do { (void)sizeof(x); } while(0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assertions
|
||||||
|
* ----------
|
||||||
|
* The code below implements a custom assert function called POLYVOX_ASSERT which has a number of advantages compared
|
||||||
|
* to the standard C/C++ assert(). It is inspired by http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
|
||||||
|
* which provides code under the MIT license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef POLYVOX_ASSERTS_ENABLED
|
||||||
|
|
||||||
|
#define POLYVOX_ASSERT(condition, message) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (!(condition)) \
|
||||||
|
{ \
|
||||||
|
std::cerr << std::endl << std::endl; \
|
||||||
|
std::cerr << " PolyVox Assertion Failed!" << std::endl; \
|
||||||
|
std::cerr << " =========================" << std::endl; \
|
||||||
|
std::cerr << " Condition: " << #condition << std::endl; \
|
||||||
|
std::cerr << " Message: " << (message) << std::endl; \
|
||||||
|
std::cerr << " Location: " << "Line " << __LINE__ << " of " << __FILE__ << std::endl << std::endl; \
|
||||||
|
POLYVOX_HALT(); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define POLYVOX_ASSERT(condition, message) \
|
||||||
|
do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Static Assertions
|
||||||
|
* -----------------
|
||||||
|
* These map to C+11 static_assert if available or our own implentation otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(HAS_CXX11_STATIC_ASSERT)
|
||||||
|
//In this case we can just use static_assert
|
||||||
|
#define POLYVOX_STATIC_ASSERT static_assert
|
||||||
|
#else
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
// empty default template
|
||||||
|
template <bool b>
|
||||||
|
struct StaticAssert {};
|
||||||
|
|
||||||
|
// template specialized on true
|
||||||
|
template <>
|
||||||
|
struct StaticAssert<true>
|
||||||
|
{
|
||||||
|
// If the static assertion is failing then this function won't exist. It will then
|
||||||
|
// appear in the error message which gives a clue to the user about what is wrong.
|
||||||
|
static void ERROR_The_static_assertion_has_failed() {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#define POLYVOX_STATIC_ASSERT(condition, message) StaticAssert<(condition)>::ERROR_The_static_assertion_has_failed();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exceptions
|
||||||
|
* ----------
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
#ifdef POLYVOX_THROW_ENABLED
|
||||||
|
#define POLYVOX_THROW(type, message) throw type((message))
|
||||||
|
#else
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
typedef void (*ThrowHandler)(std::exception& e, const char* file, int line);
|
||||||
|
|
||||||
|
ThrowHandler getThrowHandler();
|
||||||
|
void setThrowHandler(ThrowHandler newHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define POLYVOX_THROW(type, message) \
|
||||||
|
type except = (type)((message)); \
|
||||||
|
getThrowHandler()((except), __FILE__, __LINE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //__PolyVox_ErrorHandling_H__
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
|||||||
#ifndef __PolyVox_TypeDef_H__
|
#ifndef __PolyVox_TypeDef_H__
|
||||||
#define __PolyVox_TypeDef_H__
|
#define __PolyVox_TypeDef_H__
|
||||||
|
|
||||||
|
#include "PolyVoxCore/Impl/CompilerCapabilities.h"
|
||||||
|
|
||||||
//Definitions needed to make library functions accessable
|
//Definitions needed to make library functions accessable
|
||||||
// See http://gcc.gnu.org/wiki/Visibility for more info.
|
// See http://gcc.gnu.org/wiki/Visibility for more info.
|
||||||
#if defined _WIN32 || defined __CYGWIN__
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
@ -44,6 +46,13 @@ freely, subject to the following restrictions:
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined SWIG
|
||||||
|
//Do nothing in this case
|
||||||
|
#else
|
||||||
|
#undef POLYVOX_DEPRECATED
|
||||||
|
#define POLYVOX_DEPRECATED //Define it to nothing to avoid warnings
|
||||||
|
#endif
|
||||||
|
|
||||||
// Now we use the generic helper definitions above to define POLYVOX_API and POLYVOX_LOCAL.
|
// Now we use the generic helper definitions above to define POLYVOX_API and POLYVOX_LOCAL.
|
||||||
// POLYVOX_API is used for the public API symbols. It either imports or exports (or does nothing for static build)
|
// POLYVOX_API is used for the public API symbols. It either imports or exports (or does nothing for static build)
|
||||||
// POLYVOX_LOCAL is used for non-api symbols.
|
// POLYVOX_LOCAL is used for non-api symbols.
|
||||||
@ -65,9 +74,6 @@ freely, subject to the following restrictions:
|
|||||||
//To support old (pre-vc2010) Microsoft compilers we use boost to replace the
|
//To support old (pre-vc2010) Microsoft compilers we use boost to replace the
|
||||||
//std::shared_ptr and potentially other C++0x features. To use this capability you
|
//std::shared_ptr and potentially other C++0x features. To use this capability you
|
||||||
//will need to make sure you have boost installed on your system.
|
//will need to make sure you have boost installed on your system.
|
||||||
#include <boost/smart_ptr.hpp>
|
|
||||||
#define polyvox_shared_ptr boost::shared_ptr
|
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#define polyvox_function boost::function
|
#define polyvox_function boost::function
|
||||||
|
|
||||||
@ -75,13 +81,26 @@ freely, subject to the following restrictions:
|
|||||||
#define polyvox_bind boost::bind
|
#define polyvox_bind boost::bind
|
||||||
#define polyvox_placeholder_1 _1
|
#define polyvox_placeholder_1 _1
|
||||||
#define polyvox_placeholder_2 _2
|
#define polyvox_placeholder_2 _2
|
||||||
|
#else
|
||||||
#include <boost/static_assert.hpp>
|
//We have a decent compiler - use real C++0x features
|
||||||
#define static_assert(condition, message) BOOST_STATIC_ASSERT(condition)
|
#include <functional>
|
||||||
|
#define polyvox_function std::function
|
||||||
|
#define polyvox_bind std::bind
|
||||||
|
#define polyvox_placeholder_1 std::placeholders::_1
|
||||||
|
#define polyvox_placeholder_2 std::placeholders::_2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAS_CXX11_CONSTEXPR)
|
||||||
|
#define polyvox_constexpr_const constexpr //constexpr which falls back to const
|
||||||
|
#define polyvox_constexpr constexpr //constexpr which falls back to nothing
|
||||||
|
#else
|
||||||
|
#define polyvox_constexpr_const const
|
||||||
|
#define polyvox_constexpr
|
||||||
|
#endif
|
||||||
|
|
||||||
//As long as we're requiring boost, we'll use it to compensate
|
#if defined(HAS_CXX11_CSTDINT_H)
|
||||||
//for the missing cstdint header too.
|
#include <cstdint>
|
||||||
|
#else
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
using boost::int8_t;
|
using boost::int8_t;
|
||||||
using boost::int16_t;
|
using boost::int16_t;
|
||||||
@ -89,17 +108,14 @@ freely, subject to the following restrictions:
|
|||||||
using boost::uint8_t;
|
using boost::uint8_t;
|
||||||
using boost::uint16_t;
|
using boost::uint16_t;
|
||||||
using boost::uint32_t;
|
using boost::uint32_t;
|
||||||
#else
|
#endif
|
||||||
//We have a decent compiler - use real C++0x features
|
|
||||||
#include <cstdint>
|
#if defined(HAS_CXX11_SHARED_PTR)
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#define polyvox_shared_ptr std::shared_ptr
|
#define polyvox_shared_ptr std::shared_ptr
|
||||||
#define polyvox_function std::function
|
#else
|
||||||
#define polyvox_bind std::bind
|
#include <boost/smart_ptr.hpp>
|
||||||
#define polyvox_placeholder_1 std::placeholders::_1
|
#define polyvox_shared_ptr boost::shared_ptr
|
||||||
#define polyvox_placeholder_2 std::placeholders::_2
|
|
||||||
//#define static_assert static_assert //we can use this
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,10 +21,12 @@ freely, subject to the following restrictions:
|
|||||||
distribution.
|
distribution.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x)
|
#define CAN_GO_NEG_X(val) ((val > this->mVolume->getEnclosingRegion().getLowerCorner().getX()) && (val % this->mVolume->m_uBlockSideLength != 0))
|
||||||
#define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1))
|
#define CAN_GO_POS_X(val) ((val < this->mVolume->getEnclosingRegion().getUpperCorner().getX()) && ((val + 1) % this->mVolume->m_uBlockSideLength != 0))
|
||||||
//#define BORDER_LOW(x) (( x % mVolume->m_uBlockSideLength) != 0)
|
#define CAN_GO_NEG_Y(val) ((val > this->mVolume->getEnclosingRegion().getLowerCorner().getY()) && (val % this->mVolume->m_uBlockSideLength != 0))
|
||||||
//#define BORDER_HIGH(x) (( x % mVolume->m_uBlockSideLength) != mVolume->m_uBlockSideLength - 1)
|
#define CAN_GO_POS_Y(val) ((val < this->mVolume->getEnclosingRegion().getUpperCorner().getY()) && ((val + 1) % this->mVolume->m_uBlockSideLength != 0))
|
||||||
|
#define CAN_GO_NEG_Z(val) ((val > this->mVolume->getEnclosingRegion().getLowerCorner().getZ()) && (val % this->mVolume->m_uBlockSideLength != 0))
|
||||||
|
#define CAN_GO_POS_Z(val) ((val < this->mVolume->getEnclosingRegion().getUpperCorner().getZ()) && ((val + 1) % this->mVolume->m_uBlockSideLength != 0))
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
@ -280,7 +282,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -290,7 +292,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -300,7 +302,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -310,7 +312,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -320,7 +322,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1);
|
return *(mCurrentVoxel - 1);
|
||||||
}
|
}
|
||||||
@ -330,7 +332,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -340,7 +342,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -350,7 +352,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -360,7 +362,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -372,7 +374,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -382,7 +384,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -392,7 +394,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -402,7 +404,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -422,7 +424,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -432,7 +434,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -442,7 +444,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -452,7 +454,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -464,7 +466,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -474,7 +476,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -484,7 +486,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -494,7 +496,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -504,7 +506,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1);
|
return *(mCurrentVoxel + 1);
|
||||||
}
|
}
|
||||||
@ -514,7 +516,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -524,7 +526,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -534,7 +536,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -544,7 +546,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
|
VoxelType LargeVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -552,5 +554,9 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef BORDER_LOW
|
#undef CAN_GO_NEG_X
|
||||||
#undef BORDER_HIGH
|
#undef CAN_GO_POS_X
|
||||||
|
#undef CAN_GO_NEG_Y
|
||||||
|
#undef CAN_GO_POS_Y
|
||||||
|
#undef CAN_GO_NEG_Z
|
||||||
|
#undef CAN_GO_POS_Z
|
||||||
|
@ -1,220 +1,217 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
3. This notice may not be removed or altered from any source
|
||||||
distribution.
|
distribution.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef __PolyVox_SurfaceExtractor_H__
|
#ifndef __PolyVox_SurfaceExtractor_H__
|
||||||
#define __PolyVox_SurfaceExtractor_H__
|
#define __PolyVox_SurfaceExtractor_H__
|
||||||
|
|
||||||
#include "Impl/MarchingCubesTables.h"
|
#include "Impl/MarchingCubesTables.h"
|
||||||
#include "Impl/TypeDef.h"
|
#include "Impl/TypeDef.h"
|
||||||
|
|
||||||
#include "PolyVoxCore/Array.h"
|
#include "PolyVoxCore/Array.h"
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVoxCore/BaseVolume.h" //For wrap modes... should move these?
|
||||||
#include "PolyVoxCore/DefaultMarchingCubesController.h"
|
#include "PolyVoxCore/SurfaceMesh.h"
|
||||||
|
#include "PolyVoxCore/DefaultMarchingCubesController.h"
|
||||||
namespace PolyVox
|
|
||||||
{
|
namespace PolyVox
|
||||||
template< typename VolumeType, typename Controller = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
{
|
||||||
class MarchingCubesSurfaceExtractor
|
template< typename VolumeType, typename Controller = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
||||||
{
|
class MarchingCubesSurfaceExtractor
|
||||||
public:
|
{
|
||||||
MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename Controller::MaterialType> >* result, Controller controller = Controller());
|
public:
|
||||||
|
// This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template
|
||||||
void execute();
|
// Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC?
|
||||||
|
#if defined(_MSC_VER)
|
||||||
private:
|
MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename Controller::MaterialType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(0), Controller controller = Controller());
|
||||||
//Compute the cell bitmask for a particular slice in z.
|
#else
|
||||||
template<bool isPrevZAvail>
|
MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename Controller::MaterialType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(0), Controller controller = Controller());
|
||||||
uint32_t computeBitmaskForSlice(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask);
|
#endif
|
||||||
|
|
||||||
//Compute the cell bitmask for a given cell.
|
void execute();
|
||||||
template<bool isPrevXAvail, bool isPrevYAvail, bool isPrevZAvail>
|
|
||||||
void computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask);
|
private:
|
||||||
|
//Compute the cell bitmask for a particular slice in z.
|
||||||
//Use the cell bitmasks to generate all the vertices needed for that slice
|
template<bool isPrevZAvail>
|
||||||
void generateVerticesForSlice(const Array2DUint8& pCurrentBitmask,
|
uint32_t computeBitmaskForSlice(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask);
|
||||||
Array2DInt32& m_pCurrentVertexIndicesX,
|
|
||||||
Array2DInt32& m_pCurrentVertexIndicesY,
|
//Compute the cell bitmask for a given cell.
|
||||||
Array2DInt32& m_pCurrentVertexIndicesZ);
|
template<bool isPrevXAvail, bool isPrevYAvail, bool isPrevZAvail>
|
||||||
|
void computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask, uint32_t uXRegSpace, uint32_t uYRegSpace);
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// NOTE: These two functions are in the .h file rather than the .inl due to an apparent bug in VC2010.
|
//Use the cell bitmasks to generate all the vertices needed for that slice
|
||||||
//See http://stackoverflow.com/questions/1484885/strange-vc-compile-error-c2244 for details.
|
void generateVerticesForSlice(const Array2DUint8& pCurrentBitmask,
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
Array2DInt32& m_pCurrentVertexIndicesX,
|
||||||
Vector3DFloat computeCentralDifferenceGradient(const typename VolumeType::Sampler& volIter)
|
Array2DInt32& m_pCurrentVertexIndicesY,
|
||||||
{
|
Array2DInt32& m_pCurrentVertexIndicesZ);
|
||||||
//FIXME - Should actually use DensityType here, both in principle and because the maths may be
|
|
||||||
//faster (and to reduce casts). So it would be good to add a way to get DensityType from a voxel.
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//But watch out for when the DensityType is unsigned and the difference could be negative.
|
// NOTE: These two functions are in the .h file rather than the .inl due to an apparent bug in VC2010.
|
||||||
float voxel1nx = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py0pz()));
|
//See http://stackoverflow.com/questions/1484885/strange-vc-compile-error-c2244 for details.
|
||||||
float voxel1px = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py0pz()));
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Vector3DFloat computeCentralDifferenceGradient(const typename VolumeType::Sampler& volIter)
|
||||||
float voxel1ny = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny0pz()));
|
{
|
||||||
float voxel1py = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py0pz()));
|
//FIXME - Should actually use DensityType here, both in principle and because the maths may be
|
||||||
|
//faster (and to reduce casts). So it would be good to add a way to get DensityType from a voxel.
|
||||||
float voxel1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1nz()));
|
//But watch out for when the DensityType is unsigned and the difference could be negative.
|
||||||
float voxel1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1pz()));
|
float voxel1nx = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py0pz()));
|
||||||
|
float voxel1px = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py0pz()));
|
||||||
return Vector3DFloat
|
|
||||||
(
|
float voxel1ny = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny0pz()));
|
||||||
voxel1nx - voxel1px,
|
float voxel1py = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py0pz()));
|
||||||
voxel1ny - voxel1py,
|
|
||||||
voxel1nz - voxel1pz
|
float voxel1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1nz()));
|
||||||
);
|
float voxel1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1pz()));
|
||||||
}
|
|
||||||
|
return Vector3DFloat
|
||||||
Vector3DFloat computeSobelGradient(const typename VolumeType::Sampler& volIter)
|
(
|
||||||
{
|
voxel1nx - voxel1px,
|
||||||
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
|
voxel1ny - voxel1py,
|
||||||
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
|
voxel1nz - voxel1pz
|
||||||
|
);
|
||||||
//FIXME - Should actually use DensityType here, both in principle and because the maths may be
|
}
|
||||||
//faster (and to reduce casts). So it would be good to add a way to get DensityType from a voxel.
|
|
||||||
//But watch out for when the DensityType is unsigned and the difference could be negative.
|
Vector3DFloat computeSobelGradient(const typename VolumeType::Sampler& volIter)
|
||||||
const float pVoxel1nx1ny1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1ny1nz()));
|
{
|
||||||
const float pVoxel1nx1ny0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1ny0pz()));
|
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
|
||||||
const float pVoxel1nx1ny1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1ny1pz()));
|
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
|
||||||
const float pVoxel1nx0py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py1nz()));
|
|
||||||
const float pVoxel1nx0py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py0pz()));
|
//FIXME - Should actually use DensityType here, both in principle and because the maths may be
|
||||||
const float pVoxel1nx0py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py1pz()));
|
//faster (and to reduce casts). So it would be good to add a way to get DensityType from a voxel.
|
||||||
const float pVoxel1nx1py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1py1nz()));
|
//But watch out for when the DensityType is unsigned and the difference could be negative.
|
||||||
const float pVoxel1nx1py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1py0pz()));
|
const float pVoxel1nx1ny1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1ny1nz()));
|
||||||
const float pVoxel1nx1py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1py1pz()));
|
const float pVoxel1nx1ny0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1ny0pz()));
|
||||||
|
const float pVoxel1nx1ny1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1ny1pz()));
|
||||||
const float pVoxel0px1ny1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny1nz()));
|
const float pVoxel1nx0py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py1nz()));
|
||||||
const float pVoxel0px1ny0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny0pz()));
|
const float pVoxel1nx0py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py0pz()));
|
||||||
const float pVoxel0px1ny1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny1pz()));
|
const float pVoxel1nx0py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx0py1pz()));
|
||||||
const float pVoxel0px0py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1nz()));
|
const float pVoxel1nx1py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1py1nz()));
|
||||||
//const float pVoxel0px0py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py0pz()));
|
const float pVoxel1nx1py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1py0pz()));
|
||||||
const float pVoxel0px0py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1pz()));
|
const float pVoxel1nx1py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1nx1py1pz()));
|
||||||
const float pVoxel0px1py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py1nz()));
|
|
||||||
const float pVoxel0px1py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py0pz()));
|
const float pVoxel0px1ny1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny1nz()));
|
||||||
const float pVoxel0px1py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py1pz()));
|
const float pVoxel0px1ny0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny0pz()));
|
||||||
|
const float pVoxel0px1ny1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1ny1pz()));
|
||||||
const float pVoxel1px1ny1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1ny1nz()));
|
const float pVoxel0px0py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1nz()));
|
||||||
const float pVoxel1px1ny0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1ny0pz()));
|
//const float pVoxel0px0py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py0pz()));
|
||||||
const float pVoxel1px1ny1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1ny1pz()));
|
const float pVoxel0px0py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px0py1pz()));
|
||||||
const float pVoxel1px0py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py1nz()));
|
const float pVoxel0px1py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py1nz()));
|
||||||
const float pVoxel1px0py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py0pz()));
|
const float pVoxel0px1py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py0pz()));
|
||||||
const float pVoxel1px0py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py1pz()));
|
const float pVoxel0px1py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel0px1py1pz()));
|
||||||
const float pVoxel1px1py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1py1nz()));
|
|
||||||
const float pVoxel1px1py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1py0pz()));
|
const float pVoxel1px1ny1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1ny1nz()));
|
||||||
const float pVoxel1px1py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1py1pz()));
|
const float pVoxel1px1ny0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1ny0pz()));
|
||||||
|
const float pVoxel1px1ny1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1ny1pz()));
|
||||||
const float xGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
|
const float pVoxel1px0py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py1nz()));
|
||||||
weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
|
const float pVoxel1px0py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py0pz()));
|
||||||
pVoxel1nx1ny1pz - weights[0][1][0] * pVoxel1nx0py1nz -
|
const float pVoxel1px0py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px0py1pz()));
|
||||||
weights[1][1][0] * pVoxel1nx0py0pz - weights[2][1][0] *
|
const float pVoxel1px1py1nz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1py1nz()));
|
||||||
pVoxel1nx0py1pz - weights[0][2][0] * pVoxel1nx1py1nz -
|
const float pVoxel1px1py0pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1py0pz()));
|
||||||
weights[1][2][0] * pVoxel1nx1py0pz - weights[2][2][0] *
|
const float pVoxel1px1py1pz = static_cast<float>(m_controller.convertToDensity(volIter.peekVoxel1px1py1pz()));
|
||||||
pVoxel1nx1py1pz + weights[0][0][2] * pVoxel1px1ny1nz +
|
|
||||||
weights[1][0][2] * pVoxel1px1ny0pz + weights[2][0][2] *
|
const float xGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
|
||||||
pVoxel1px1ny1pz + weights[0][1][2] * pVoxel1px0py1nz +
|
weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
|
||||||
weights[1][1][2] * pVoxel1px0py0pz + weights[2][1][2] *
|
pVoxel1nx1ny1pz - weights[0][1][0] * pVoxel1nx0py1nz -
|
||||||
pVoxel1px0py1pz + weights[0][2][2] * pVoxel1px1py1nz +
|
weights[1][1][0] * pVoxel1nx0py0pz - weights[2][1][0] *
|
||||||
weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
|
pVoxel1nx0py1pz - weights[0][2][0] * pVoxel1nx1py1nz -
|
||||||
pVoxel1px1py1pz);
|
weights[1][2][0] * pVoxel1nx1py0pz - weights[2][2][0] *
|
||||||
|
pVoxel1nx1py1pz + weights[0][0][2] * pVoxel1px1ny1nz +
|
||||||
const float yGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
|
weights[1][0][2] * pVoxel1px1ny0pz + weights[2][0][2] *
|
||||||
weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
|
pVoxel1px1ny1pz + weights[0][1][2] * pVoxel1px0py1nz +
|
||||||
pVoxel1nx1ny1pz + weights[0][2][0] * pVoxel1nx1py1nz +
|
weights[1][1][2] * pVoxel1px0py0pz + weights[2][1][2] *
|
||||||
weights[1][2][0] * pVoxel1nx1py0pz + weights[2][2][0] *
|
pVoxel1px0py1pz + weights[0][2][2] * pVoxel1px1py1nz +
|
||||||
pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz -
|
weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
|
||||||
weights[1][0][1] * pVoxel0px1ny0pz - weights[2][0][1] *
|
pVoxel1px1py1pz);
|
||||||
pVoxel0px1ny1pz + weights[0][2][1] * pVoxel0px1py1nz +
|
|
||||||
weights[1][2][1] * pVoxel0px1py0pz + weights[2][2][1] *
|
const float yGrad(- weights[0][0][0] * pVoxel1nx1ny1nz -
|
||||||
pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz -
|
weights[1][0][0] * pVoxel1nx1ny0pz - weights[2][0][0] *
|
||||||
weights[1][0][2] * pVoxel1px1ny0pz - weights[2][0][2] *
|
pVoxel1nx1ny1pz + weights[0][2][0] * pVoxel1nx1py1nz +
|
||||||
pVoxel1px1ny1pz + weights[0][2][2] * pVoxel1px1py1nz +
|
weights[1][2][0] * pVoxel1nx1py0pz + weights[2][2][0] *
|
||||||
weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
|
pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz -
|
||||||
pVoxel1px1py1pz);
|
weights[1][0][1] * pVoxel0px1ny0pz - weights[2][0][1] *
|
||||||
|
pVoxel0px1ny1pz + weights[0][2][1] * pVoxel0px1py1nz +
|
||||||
const float zGrad(- weights[0][0][0] * pVoxel1nx1ny1nz +
|
weights[1][2][1] * pVoxel0px1py0pz + weights[2][2][1] *
|
||||||
weights[2][0][0] * pVoxel1nx1ny1pz - weights[0][1][0] *
|
pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz -
|
||||||
pVoxel1nx0py1nz + weights[2][1][0] * pVoxel1nx0py1pz -
|
weights[1][0][2] * pVoxel1px1ny0pz - weights[2][0][2] *
|
||||||
weights[0][2][0] * pVoxel1nx1py1nz + weights[2][2][0] *
|
pVoxel1px1ny1pz + weights[0][2][2] * pVoxel1px1py1nz +
|
||||||
pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz +
|
weights[1][2][2] * pVoxel1px1py0pz + weights[2][2][2] *
|
||||||
weights[2][0][1] * pVoxel0px1ny1pz - weights[0][1][1] *
|
pVoxel1px1py1pz);
|
||||||
pVoxel0px0py1nz + weights[2][1][1] * pVoxel0px0py1pz -
|
|
||||||
weights[0][2][1] * pVoxel0px1py1nz + weights[2][2][1] *
|
const float zGrad(- weights[0][0][0] * pVoxel1nx1ny1nz +
|
||||||
pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz +
|
weights[2][0][0] * pVoxel1nx1ny1pz - weights[0][1][0] *
|
||||||
weights[2][0][2] * pVoxel1px1ny1pz - weights[0][1][2] *
|
pVoxel1nx0py1nz + weights[2][1][0] * pVoxel1nx0py1pz -
|
||||||
pVoxel1px0py1nz + weights[2][1][2] * pVoxel1px0py1pz -
|
weights[0][2][0] * pVoxel1nx1py1nz + weights[2][2][0] *
|
||||||
weights[0][2][2] * pVoxel1px1py1nz + weights[2][2][2] *
|
pVoxel1nx1py1pz - weights[0][0][1] * pVoxel0px1ny1nz +
|
||||||
pVoxel1px1py1pz);
|
weights[2][0][1] * pVoxel0px1ny1pz - weights[0][1][1] *
|
||||||
|
pVoxel0px0py1nz + weights[2][1][1] * pVoxel0px0py1pz -
|
||||||
//Note: The above actually give gradients going from low density to high density.
|
weights[0][2][1] * pVoxel0px1py1nz + weights[2][2][1] *
|
||||||
//For our normals we want the the other way around, so we switch the components as we return them.
|
pVoxel0px1py1pz - weights[0][0][2] * pVoxel1px1ny1nz +
|
||||||
return Vector3DFloat(-xGrad,-yGrad,-zGrad);
|
weights[2][0][2] * pVoxel1px1ny1pz - weights[0][1][2] *
|
||||||
}
|
pVoxel1px0py1nz + weights[2][1][2] * pVoxel1px0py1pz -
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
weights[0][2][2] * pVoxel1px1py1nz + weights[2][2][2] *
|
||||||
// End of compiler bug workaroumd.
|
pVoxel1px1py1pz);
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
//Note: The above actually give gradients going from low density to high density.
|
||||||
//Use the cell bitmasks to generate all the indices needed for that slice
|
//For our normals we want the the other way around, so we switch the components as we return them.
|
||||||
void generateIndicesForSlice(const Array2DUint8& pPreviousBitmask,
|
return Vector3DFloat(-xGrad,-yGrad,-zGrad);
|
||||||
const Array2DInt32& m_pPreviousVertexIndicesX,
|
}
|
||||||
const Array2DInt32& m_pPreviousVertexIndicesY,
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const Array2DInt32& m_pPreviousVertexIndicesZ,
|
// End of compiler bug workaroumd.
|
||||||
const Array2DInt32& m_pCurrentVertexIndicesX,
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const Array2DInt32& m_pCurrentVertexIndicesY);
|
|
||||||
|
//Use the cell bitmasks to generate all the indices needed for that slice
|
||||||
//The volume data and a sampler to access it.
|
void generateIndicesForSlice(const Array2DUint8& pPreviousBitmask,
|
||||||
VolumeType* m_volData;
|
const Array2DInt32& m_pPreviousVertexIndicesX,
|
||||||
typename VolumeType::Sampler m_sampVolume;
|
const Array2DInt32& m_pPreviousVertexIndicesY,
|
||||||
|
const Array2DInt32& m_pPreviousVertexIndicesZ,
|
||||||
//Holds a position in volume space.
|
const Array2DInt32& m_pCurrentVertexIndicesX,
|
||||||
int32_t iXVolSpace;
|
const Array2DInt32& m_pCurrentVertexIndicesY);
|
||||||
int32_t iYVolSpace;
|
|
||||||
int32_t iZVolSpace;
|
//The volume data and a sampler to access it.
|
||||||
|
VolumeType* m_volData;
|
||||||
//Holds a position in region space.
|
typename VolumeType::Sampler m_sampVolume;
|
||||||
uint32_t uXRegSpace;
|
|
||||||
uint32_t uYRegSpace;
|
//Used to return the number of cells in a slice which contain triangles.
|
||||||
uint32_t uZRegSpace;
|
uint32_t m_uNoOfOccupiedCells;
|
||||||
|
|
||||||
//Used to return the number of cells in a slice which contain triangles.
|
//The surface patch we are currently filling.
|
||||||
uint32_t m_uNoOfOccupiedCells;
|
SurfaceMesh<PositionMaterialNormal<typename Controller::MaterialType> >* m_meshCurrent;
|
||||||
|
|
||||||
//The surface patch we are currently filling.
|
//Information about the region we are currently processing
|
||||||
SurfaceMesh<PositionMaterialNormal<typename Controller::MaterialType> >* m_meshCurrent;
|
Region m_regSizeInVoxels;
|
||||||
|
Region m_regSizeInCells;
|
||||||
//Information about the region we are currently processing
|
/*Region m_regSizeInVoxelsCropped;
|
||||||
Region m_regSizeInVoxels;
|
Region m_regSizeInVoxelsUncropped;
|
||||||
Region m_regSizeInCells;
|
Region m_regVolumeCropped;*/
|
||||||
/*Region m_regSizeInVoxelsCropped;
|
Region m_regSlicePrevious;
|
||||||
Region m_regSizeInVoxelsUncropped;
|
Region m_regSliceCurrent;
|
||||||
Region m_regVolumeCropped;*/
|
|
||||||
Region m_regSlicePrevious;
|
//Used to convert arbitrary voxel types in densities and materials.
|
||||||
Region m_regSliceCurrent;
|
Controller m_controller;
|
||||||
|
|
||||||
//Our threshold value
|
//Our threshold value
|
||||||
typename Controller::DensityType m_tThreshold;
|
typename Controller::DensityType m_tThreshold;
|
||||||
|
};
|
||||||
//Used to convert arbitrary voxel types in densities and materials.
|
}
|
||||||
Controller m_controller;
|
|
||||||
};
|
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.inl"
|
||||||
}
|
|
||||||
|
#endif
|
||||||
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.inl"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -119,13 +119,11 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
// Default to a threshold value halfway between the min and max possible values.
|
// Default to a threshold value halfway between the min and max possible values.
|
||||||
m_tThreshold = (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2;
|
m_tThreshold = (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2;
|
||||||
m_eWrapMode = WrapModes::Border;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMarchingCubesController(DensityType tThreshold)
|
DefaultMarchingCubesController(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
m_eWrapMode = WrapModes::Border;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> voxel)
|
DensityType convertToDensity(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> voxel)
|
||||||
@ -138,35 +136,18 @@ namespace PolyVox
|
|||||||
return voxel.getMaterial();
|
return voxel.getMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> getBorderValue(void)
|
|
||||||
{
|
|
||||||
return m_tBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
DensityType getThreshold(void)
|
DensityType getThreshold(void)
|
||||||
{
|
{
|
||||||
return m_tThreshold;
|
return m_tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapMode getWrapMode(void)
|
|
||||||
{
|
|
||||||
return m_eWrapMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setThreshold(DensityType tThreshold)
|
void setThreshold(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWrapMode(WrapMode eWrapMode)
|
|
||||||
{
|
|
||||||
m_eWrapMode = eWrapMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DensityType m_tThreshold;
|
DensityType m_tThreshold;
|
||||||
WrapMode m_eWrapMode;
|
|
||||||
MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> m_tBorder;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
||||||
|
@ -31,7 +31,7 @@ namespace PolyVox
|
|||||||
RawVolume<VoxelType>::RawVolume(const Region& regValid)
|
RawVolume<VoxelType>::RawVolume(const Region& regValid)
|
||||||
:BaseVolume<VoxelType>(regValid)
|
:BaseVolume<VoxelType>(regValid)
|
||||||
{
|
{
|
||||||
setBorderValue(VoxelType());
|
this->setBorderValue(VoxelType());
|
||||||
|
|
||||||
//Create a volume of the right size.
|
//Create a volume of the right size.
|
||||||
initialise(regValid);
|
initialise(regValid);
|
||||||
|
@ -21,10 +21,12 @@ freely, subject to the following restrictions:
|
|||||||
distribution.
|
distribution.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x)
|
#define CAN_GO_NEG_X(val) ((val > this->mVolume->getEnclosingRegion().getLowerCorner().getX()) && (val % this->mVolume->m_uBlockSideLength != 0))
|
||||||
#define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1))
|
#define CAN_GO_POS_X(val) ((val < this->mVolume->getEnclosingRegion().getUpperCorner().getX()) && ((val + 1) % this->mVolume->m_uBlockSideLength != 0))
|
||||||
//#define BORDER_LOW(x) (( x % this->mVolume->m_uBlockSideLength) != 0)
|
#define CAN_GO_NEG_Y(val) ((val > this->mVolume->getEnclosingRegion().getLowerCorner().getY()) && (val % this->mVolume->m_uBlockSideLength != 0))
|
||||||
//#define BORDER_HIGH(x) (( x % this->mVolume->m_uBlockSideLength) != this->mVolume->m_uBlockSideLength - 1)
|
#define CAN_GO_POS_Y(val) ((val < this->mVolume->getEnclosingRegion().getUpperCorner().getY()) && ((val + 1) % this->mVolume->m_uBlockSideLength != 0))
|
||||||
|
#define CAN_GO_NEG_Z(val) ((val > this->mVolume->getEnclosingRegion().getLowerCorner().getZ()) && (val % this->mVolume->m_uBlockSideLength != 0))
|
||||||
|
#define CAN_GO_POS_Z(val) ((val < this->mVolume->getEnclosingRegion().getUpperCorner().getZ()) && ((val + 1) % this->mVolume->m_uBlockSideLength != 0))
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
@ -299,7 +301,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -309,7 +311,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -319,7 +321,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -329,7 +331,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -339,7 +341,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1);
|
return *(mCurrentVoxel - 1);
|
||||||
}
|
}
|
||||||
@ -349,7 +351,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -359,7 +361,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -369,7 +371,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -379,7 +381,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -391,7 +393,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -401,7 +403,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -411,7 +413,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -421,7 +423,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -441,7 +443,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -451,7 +453,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -461,7 +463,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -471,7 +473,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -483,7 +485,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -493,7 +495,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -503,7 +505,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -513,7 +515,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -523,7 +525,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1);
|
return *(mCurrentVoxel + 1);
|
||||||
}
|
}
|
||||||
@ -533,7 +535,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -543,7 +545,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -553,7 +555,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -563,7 +565,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
|
VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
|
||||||
{
|
{
|
||||||
if((this->isCurrentPositionValid()) && BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
|
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
|
||||||
{
|
{
|
||||||
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
|
||||||
}
|
}
|
||||||
@ -571,5 +573,9 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef BORDER_LOW
|
#undef CAN_GO_NEG_X
|
||||||
#undef BORDER_HIGH
|
#undef CAN_GO_POS_X
|
||||||
|
#undef CAN_GO_NEG_Y
|
||||||
|
#undef CAN_GO_POS_Y
|
||||||
|
#undef CAN_GO_NEG_Z
|
||||||
|
#undef CAN_GO_POS_Z
|
||||||
|
@ -21,6 +21,8 @@ freely, subject to the following restrictions:
|
|||||||
distribution.
|
distribution.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template <typename VertexType>
|
template <typename VertexType>
|
||||||
|
@ -24,11 +24,11 @@ freely, subject to the following restrictions:
|
|||||||
#ifndef __PolyVox_Vector_H__
|
#ifndef __PolyVox_Vector_H__
|
||||||
#define __PolyVox_Vector_H__
|
#define __PolyVox_Vector_H__
|
||||||
|
|
||||||
|
#include "Impl/ErrorHandling.h"
|
||||||
#include "Impl/TypeDef.h"
|
#include "Impl/TypeDef.h"
|
||||||
|
|
||||||
#include "PolyVoxForwardDeclarations.h"
|
#include "PolyVoxForwardDeclarations.h"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -52,10 +52,8 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all constructors, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size == 2, "This constructor should only be used for vectors with two elements.");
|
||||||
//static_assert(Size == 2, "This constructor should only be used for vectors with two elements.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_tElements[0] = x;
|
m_tElements[0] = x;
|
||||||
m_tElements[1] = y;
|
m_tElements[1] = y;
|
||||||
@ -69,10 +67,8 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all constructors, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size == 3, "This constructor should only be used for vectors with three elements.");
|
||||||
//static_assert(Size == 3, "This constructor should only be used for vectors with three elements.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_tElements[0] = x;
|
m_tElements[0] = x;
|
||||||
m_tElements[1] = y;
|
m_tElements[1] = y;
|
||||||
@ -89,10 +85,8 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all constructors, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size == 4, "This constructor should only be used for vectors with four elements.");
|
||||||
//static_assert(Size == 4, "This constructor should only be used for vectors with four elements.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_tElements[0] = x;
|
m_tElements[0] = x;
|
||||||
m_tElements[1] = y;
|
m_tElements[1] = y;
|
||||||
@ -135,14 +129,14 @@ namespace PolyVox
|
|||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
Vector<Size, StorageType, OperationType>::~Vector(void)
|
Vector<Size, StorageType, OperationType>::~Vector(void)
|
||||||
{
|
{
|
||||||
// We put the static_asserts in the destructor because there is one one of these,
|
// We put the static asserts in the destructor because there is one one of these,
|
||||||
// where as there are multiple constructors.
|
// where as there are multiple constructors.
|
||||||
|
|
||||||
// Force a vector to have a length greater than one. There is no need for a
|
// Force a vector to have a length greater than one. There is no need for a
|
||||||
// vector with one element, and supporting this would cause confusion over the
|
// vector with one element, and supporting this would cause confusion over the
|
||||||
// behaviour of the constructor taking a single value, as this fills all elements
|
// behaviour of the constructor taking a single value, as this fills all elements
|
||||||
// to that value rather than just the first one.
|
// to that value rather than just the first one.
|
||||||
//static_assert(Size > 1, "Vector must have a length greater than one.");
|
POLYVOX_STATIC_ASSERT(Size > 1, "Vector must have a length greater than one.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -420,7 +414,7 @@ namespace PolyVox
|
|||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const
|
||||||
{
|
{
|
||||||
assert(index < Size);
|
POLYVOX_ASSERT(index < Size, "Attempted to access invalid vector element.");
|
||||||
return m_tElements[index];
|
return m_tElements[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,10 +441,8 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all getters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size >= 3, "You can only get the 'z' component from a vector with at least three elements.");
|
||||||
//static_assert(Size >= 3, "You can only get the 'z' component from a vector with at least three elements.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return m_tElements[2];
|
return m_tElements[2];
|
||||||
}
|
}
|
||||||
@ -460,10 +452,8 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all getters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size >= 4, "You can only get the 'w' component from a vector with at least four elements.");
|
||||||
//static_assert(Size >= 4, "You can only get the 'w' component from a vector with at least four elements.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return m_tElements[3];
|
return m_tElements[3];
|
||||||
}
|
}
|
||||||
@ -475,7 +465,7 @@ namespace PolyVox
|
|||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue)
|
inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue)
|
||||||
{
|
{
|
||||||
assert(index < Size);
|
POLYVOX_ASSERT(index < Size, "Attempted to access invalid vector element.");
|
||||||
m_tElements[index] = tValue;
|
m_tElements[index] = tValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,10 +490,9 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
|
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements.");
|
||||||
//static_assert(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements.");
|
|
||||||
#endif
|
|
||||||
m_tElements[0] = x;
|
m_tElements[0] = x;
|
||||||
m_tElements[1] = y;
|
m_tElements[1] = y;
|
||||||
m_tElements[2] = z;
|
m_tElements[2] = z;
|
||||||
@ -518,10 +507,9 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
|
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements.");
|
||||||
//static_assert(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements.");
|
|
||||||
#endif
|
|
||||||
m_tElements[0] = x;
|
m_tElements[0] = x;
|
||||||
m_tElements[1] = y;
|
m_tElements[1] = y;
|
||||||
m_tElements[2] = z;
|
m_tElements[2] = z;
|
||||||
@ -551,11 +539,10 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
|
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size >= 3, "You can only set the 'w' component from a vector with at least three elements.");
|
||||||
//static_assert(Size >= 3, "You can only set the 'w' component from a vector with at least three elements.");
|
|
||||||
#endif
|
m_tElements[2] = tZ;
|
||||||
m_tElements[2] = tZ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -563,11 +550,10 @@ namespace PolyVox
|
|||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
|
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
|
||||||
{
|
{
|
||||||
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
|
POLYVOX_STATIC_ASSERT(Size >= 4, "You can only set the 'w' component from a vector with at least four elements.");
|
||||||
//static_assert(Size >= 4, "You can only set the 'w' component from a vector with at least four elements.");
|
|
||||||
#endif
|
m_tElements[3] = tW;
|
||||||
m_tElements[3] = tW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -663,7 +649,7 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
// Standard float rules apply for divide-by-zero
|
// Standard float rules apply for divide-by-zero
|
||||||
m_tElements[ct] /= fLength;
|
m_tElements[ct] /= fLength;
|
||||||
assert(m_tElements[ct] == m_tElements[ct]); //Will assert if NAN
|
POLYVOX_ASSERT(m_tElements[ct] == m_tElements[ct], "Obtained NAN during vector normalisation. Perhaps the input vector was too short?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//namespace PolyVox
|
}//namespace PolyVox
|
||||||
|
@ -1,65 +1,63 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
3. This notice may not be removed or altered from any source
|
||||||
distribution.
|
distribution.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "PolyVoxCore/Impl/Utility.h"
|
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||||
|
#include "PolyVoxCore/Impl/Utility.h"
|
||||||
#include <cassert>
|
|
||||||
#include <stdexcept>
|
namespace PolyVox
|
||||||
|
{
|
||||||
namespace PolyVox
|
//Note: this function only works for inputs which are a power of two and not zero
|
||||||
{
|
//If this is not the case then the output is undefined.
|
||||||
//Note: this function only works for inputs which are a power of two and not zero
|
uint8_t logBase2(uint32_t uInput)
|
||||||
//If this is not the case then the output is undefined.
|
{
|
||||||
uint8_t logBase2(uint32_t uInput)
|
//Debug mode validation
|
||||||
{
|
POLYVOX_ASSERT(uInput != 0, "Cannot compute the log of zero.");
|
||||||
//Debug mode validation
|
POLYVOX_ASSERT(isPowerOf2(uInput), "Input must be a power of two in order to compute the log.");
|
||||||
assert(uInput != 0);
|
|
||||||
assert(isPowerOf2(uInput));
|
//Release mode validation
|
||||||
|
if(uInput == 0)
|
||||||
//Release mode validation
|
{
|
||||||
if(uInput == 0)
|
POLYVOX_THROW(std::invalid_argument, "Cannot compute the log of zero.");
|
||||||
{
|
}
|
||||||
//throw std::invalid_argument("Cannot compute the log of zero.");
|
if(!isPowerOf2(uInput))
|
||||||
}
|
{
|
||||||
if(!isPowerOf2(uInput))
|
POLYVOX_THROW(std::invalid_argument, "Input must be a power of two in order to compute the log.");
|
||||||
{
|
}
|
||||||
//throw std::invalid_argument("Input must be a power of two in order to compute the log.");
|
|
||||||
}
|
uint32_t uResult = 0;
|
||||||
|
while( (uInput >> uResult) != 0)
|
||||||
uint32_t uResult = 0;
|
{
|
||||||
while( (uInput >> uResult) != 0)
|
++uResult;
|
||||||
{
|
}
|
||||||
++uResult;
|
return static_cast<uint8_t>(uResult-1);
|
||||||
}
|
}
|
||||||
return static_cast<uint8_t>(uResult-1);
|
|
||||||
}
|
|
||||||
|
bool isPowerOf2(uint32_t uInput)
|
||||||
|
{
|
||||||
bool isPowerOf2(uint32_t uInput)
|
if(uInput == 0)
|
||||||
{
|
return false;
|
||||||
if(uInput == 0)
|
else
|
||||||
return false;
|
return ((uInput & (uInput-1)) == 0);
|
||||||
else
|
}
|
||||||
return ((uInput & (uInput-1)) == 0);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
# 3. This notice may not be removed or altered from any source
|
# 3. This notice may not be removed or altered from any source
|
||||||
# distribution.
|
# distribution.
|
||||||
|
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
|
||||||
|
|
||||||
PROJECT(PolyVoxUtil)
|
PROJECT(PolyVoxUtil)
|
||||||
|
|
||||||
#Projects source files
|
#Projects source files
|
||||||
@ -42,7 +40,7 @@ SOURCE_GROUP("Sources" FILES ${UTIL_SRC_FILES})
|
|||||||
SOURCE_GROUP("Headers" FILES ${UTIL_INC_FILES})
|
SOURCE_GROUP("Headers" FILES ${UTIL_INC_FILES})
|
||||||
|
|
||||||
#Tell CMake the paths
|
#Tell CMake the paths
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include)
|
||||||
#There has to be a better way!
|
#There has to be a better way!
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/debug ${PolyVoxCore_BINARY_DIR}/release ${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/debug ${PolyVoxCore_BINARY_DIR}/release ${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ if(ENABLE_BINDINGS)
|
|||||||
include(${SWIG_USE_FILE})
|
include(${SWIG_USE_FILE})
|
||||||
|
|
||||||
include_directories(${PYTHON_INCLUDE_PATH})
|
include_directories(${PYTHON_INCLUDE_PATH})
|
||||||
include_directories(${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include/PolyVoxCore)
|
include_directories(${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include/PolyVoxCore)
|
||||||
link_directories(${PolyVoxCore_BINARY_DIR})
|
link_directories(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
set(CMAKE_SWIG_FLAGS "")
|
set(CMAKE_SWIG_FLAGS "")
|
||||||
@ -48,6 +48,11 @@ if(ENABLE_BINDINGS)
|
|||||||
set_target_properties(${SWIG_MODULE_PolyVoxCorePython_REAL_NAME} PROPERTIES OUTPUT_NAME _PolyVoxCore)
|
set_target_properties(${SWIG_MODULE_PolyVoxCorePython_REAL_NAME} PROPERTIES OUTPUT_NAME _PolyVoxCore)
|
||||||
#set_target_properties(${SWIG_MODULE_PolyVoxCore_REAL_NAME} PROPERTIES SUFFIX ".pyd")
|
#set_target_properties(${SWIG_MODULE_PolyVoxCore_REAL_NAME} PROPERTIES SUFFIX ".pyd")
|
||||||
SET_PROPERTY(TARGET ${SWIG_MODULE_PolyVoxCorePython_REAL_NAME} PROPERTY FOLDER "Bindings")
|
SET_PROPERTY(TARGET ${SWIG_MODULE_PolyVoxCorePython_REAL_NAME} PROPERTY FOLDER "Bindings")
|
||||||
|
|
||||||
|
swig_add_module(PolyVoxCoreCSharp csharp PolyVoxCore.i)
|
||||||
|
set(SWIG_MODULE_PolyVoxCoreCSharp_EXTRA_FLAGS "-dllimport;PolyVoxCoreCSharp") #This _should_ be inside UseSWIG.cmake - http://www.cmake.org/Bug/view.php?id=13814
|
||||||
|
swig_link_libraries(PolyVoxCoreCSharp PolyVoxCore)
|
||||||
|
SET_PROPERTY(TARGET ${SWIG_MODULE_PolyVoxCoreCSharp_REAL_NAME} PROPERTY FOLDER "Bindings")
|
||||||
else()
|
else()
|
||||||
set(BUILD_BINDINGS OFF CACHE BOOL "Will the bindings be built" FORCE)
|
set(BUILD_BINDINGS OFF CACHE BOOL "Will the bindings be built" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
%module PolyVoxCore
|
%module PolyVoxCore
|
||||||
|
|
||||||
#define POLYVOX_API
|
#define POLYVOX_API
|
||||||
|
%include "PolyVoxCore/Impl/CompilerCapabilities.h"
|
||||||
%include "Impl/TypeDef.h"
|
%include "Impl/TypeDef.h"
|
||||||
#define __attribute__(x) //Silence DEPRECATED errors
|
#define __attribute__(x) //Silence DEPRECATED errors
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
%{
|
%{
|
||||||
#include "Raycast.h"
|
#include "Raycast.h"
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
|
||||||
template<typename VolumeType>
|
template<typename VolumeType>
|
||||||
class PyCallback
|
class PyCallback
|
||||||
{
|
{
|
||||||
@ -43,11 +45,17 @@ PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const Pol
|
|||||||
return PolyVox::raycastWithEndpoints(volData, v3dStart, v3dEnd, newCallback);
|
return PolyVox::raycastWithEndpoints(volData, v3dStart, v3dEnd, newCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "Raycast.h"
|
%include "Raycast.h"
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
|
||||||
template<typename VolumeType, typename Callback>
|
template<typename VolumeType, typename Callback>
|
||||||
PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const PolyVox::Vector3DFloat& v3dStart, const PolyVox::Vector3DFloat& v3dEnd, PyObject *callback);
|
PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const PolyVox::Vector3DFloat& v3dStart, const PolyVox::Vector3DFloat& v3dEnd, PyObject *callback);
|
||||||
|
|
||||||
%template(raycastWithEndpointsSimpleVolumeuint8) raycastWithEndpointsPython<PolyVox::SimpleVolume<uint8_t>, PyCallback<PolyVox::SimpleVolume<uint8_t> > >;
|
%template(raycastWithEndpointsSimpleVolumeuint8) raycastWithEndpointsPython<PolyVox::SimpleVolume<uint8_t>, PyCallback<PolyVox::SimpleVolume<uint8_t> > >;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -34,13 +34,29 @@ PROPERTY(PolyVox::Vector, z, getZ, setZ)
|
|||||||
STR()
|
STR()
|
||||||
};
|
};
|
||||||
|
|
||||||
%template(Vector3DFloat) PolyVox::Vector<3,float,float>;
|
%feature("pythonprepend") PolyVox::Vector::operator< %{
|
||||||
%template(Vector3DDouble) PolyVox::Vector<3,double,double>;
|
import warnings
|
||||||
%template(Vector3DInt8) PolyVox::Vector<3,int8_t,int32_t>;
|
warnings.warn("deprecated", DeprecationWarning)
|
||||||
%template(Vector3DUint8) PolyVox::Vector<3,uint8_t,int32_t>;
|
%}
|
||||||
%template(Vector3DInt16) PolyVox::Vector<3,int16_t,int32_t>;
|
|
||||||
%template(Vector3DUint16) PolyVox::Vector<3,uint16_t,int32_t>;
|
//%csattributes PolyVox::Vector::operator< "[System.Obsolete(\"deprecated\")]"
|
||||||
%template(Vector3DInt32) PolyVox::Vector<3,int32_t,int32_t>;
|
|
||||||
%template(Vector3DUint32) PolyVox::Vector<3,uint32_t,int32_t>;
|
%define VECTOR3(StorageType,OperationType,ReducedStorageType)
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType);
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::getW() const;
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::setW(ReducedStorageType);
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::setElements(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
|
||||||
|
%template(Vector3D ## StorageType) PolyVox::Vector<3,StorageType,OperationType>;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
VECTOR3(float,float,float)
|
||||||
|
VECTOR3(double,double,double)
|
||||||
|
VECTOR3(int8_t,int32_t,signed char)
|
||||||
|
VECTOR3(uint8_t,int32_t,unsigned char)
|
||||||
|
VECTOR3(int16_t,int32_t,signed short)
|
||||||
|
VECTOR3(uint16_t,int32_t,unsigned short)
|
||||||
|
VECTOR3(int32_t,int32_t,signed int)
|
||||||
|
VECTOR3(uint32_t,int32_t,unsigned int)
|
||||||
|
|
||||||
//%rename(assign) Vector3DFloat::operator=;
|
//%rename(assign) Vector3DFloat::operator=;
|
||||||
|
@ -39,7 +39,7 @@ MACRO(CREATE_TEST headerfile sourcefile executablename)
|
|||||||
SET_PROPERTY(TARGET ${executablename} PROPERTY FOLDER "Tests")
|
SET_PROPERTY(TARGET ${executablename} PROPERTY FOLDER "Tests")
|
||||||
ENDMACRO(CREATE_TEST)
|
ENDMACRO(CREATE_TEST)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${PolyVox_SOURCE_DIR}/PolyVoxCore/include ${CMAKE_CURRENT_BINARY_DIR})
|
INCLUDE_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/include ${PolyVox_SOURCE_DIR}/PolyVoxCore/include ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
REMOVE_DEFINITIONS(-DQT_GUI_LIB) #Make sure the tests don't link to the QtGui
|
REMOVE_DEFINITIONS(-DQT_GUI_LIB) #Make sure the tests don't link to the QtGui
|
||||||
|
|
||||||
# Test Template. Copy and paste this template for consistant naming.
|
# Test Template. Copy and paste this template for consistant naming.
|
||||||
|
@ -13,16 +13,16 @@ class TestSurfaceExtractor(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
||||||
#Create a small volume
|
#Create a small volume
|
||||||
r = PolyVoxCore.Region(PolyVoxCore.Vector3DInt32(0,0,0), PolyVoxCore.Vector3DInt32(31,31,31))
|
r = PolyVoxCore.Region(PolyVoxCore.Vector3Dint32_t(0,0,0), PolyVoxCore.Vector3Dint32_t(31,31,31))
|
||||||
self.vol = PolyVoxCore.SimpleVolumeuint8(r)
|
self.vol = PolyVoxCore.SimpleVolumeuint8(r)
|
||||||
#Set one single voxel to have a reasonably high density
|
#Set one single voxel to have a reasonably high density
|
||||||
self.vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), 200)
|
self.vol.setVoxelAt(PolyVoxCore.Vector3Dint32_t(5, 5, 5), 200)
|
||||||
|
|
||||||
def test_hit_voxel(self):
|
def test_hit_voxel(self):
|
||||||
self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeuint8(self.vol, PolyVoxCore.Vector3DFloat(0,0,0), PolyVoxCore.Vector3DFloat(31,31,31), test_functor), 1)
|
self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeuint8(self.vol, PolyVoxCore.Vector3Dfloat(0,0,0), PolyVoxCore.Vector3Dfloat(31,31,31), test_functor), 1)
|
||||||
|
|
||||||
def test_miss_voxel(self):
|
def test_miss_voxel(self):
|
||||||
self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeuint8(self.vol, PolyVoxCore.Vector3DFloat(0,0,0), PolyVoxCore.Vector3DFloat(0,31,31), test_functor), 0)
|
self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeuint8(self.vol, PolyVoxCore.Vector3Dfloat(0,0,0), PolyVoxCore.Vector3Dfloat(0,31,31), test_functor), 0)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -59,16 +59,6 @@ public:
|
|||||||
{
|
{
|
||||||
return 50.0f;
|
return 50.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapMode getWrapMode(void)
|
|
||||||
{
|
|
||||||
return WrapModes::Border;
|
|
||||||
}
|
|
||||||
|
|
||||||
float getBorderValue(void)
|
|
||||||
{
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types.
|
// These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types.
|
||||||
@ -132,7 +122,7 @@ void testForType(SurfaceMesh<PositionMaterialNormal>& result)
|
|||||||
|
|
||||||
DefaultMarchingCubesController<VoxelType> controller;
|
DefaultMarchingCubesController<VoxelType> controller;
|
||||||
controller.setThreshold(50);
|
controller.setThreshold(50);
|
||||||
MarchingCubesSurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, controller);
|
MarchingCubesSurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, WrapModes::Border, 0, controller);
|
||||||
extractor.execute();
|
extractor.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +146,7 @@ void testCustomController(SurfaceMesh<PositionMaterialNormal>& result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomMarchingCubesController controller;
|
CustomMarchingCubesController controller;
|
||||||
MarchingCubesSurfaceExtractor< SimpleVolume<float>, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, controller);
|
MarchingCubesSurfaceExtractor< SimpleVolume<float>, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, WrapModes::Border, 0, controller);
|
||||||
extractor.execute();
|
extractor.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@ class TestSurfaceExtractor(unittest.TestCase):
|
|||||||
import PolyVoxCore
|
import PolyVoxCore
|
||||||
|
|
||||||
#Create a small volume
|
#Create a small volume
|
||||||
r = PolyVoxCore.Region(PolyVoxCore.Vector3DInt32(0,0,0), PolyVoxCore.Vector3DInt32(31,31,31))
|
r = PolyVoxCore.Region(PolyVoxCore.Vector3Dint32_t(0,0,0), PolyVoxCore.Vector3Dint32_t(31,31,31))
|
||||||
vol = PolyVoxCore.SimpleVolumeuint8(r)
|
vol = PolyVoxCore.SimpleVolumeuint8(r)
|
||||||
#Set one single voxel to have a reasonably high density
|
#Set one single voxel to have a reasonably high density
|
||||||
vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), 200)
|
vol.setVoxelAt(PolyVoxCore.Vector3Dint32_t(5, 5, 5), 200)
|
||||||
self.mesh = PolyVoxCore.SurfaceMeshPositionMaterialNormal()
|
self.mesh = PolyVoxCore.SurfaceMeshPositionMaterialNormal()
|
||||||
extractor = PolyVoxCore.MarchingCubesSurfaceExtractorSimpleVolumeuint8(vol, r, self.mesh)
|
extractor = PolyVoxCore.MarchingCubesSurfaceExtractorSimpleVolumeuint8(vol, r, self.mesh)
|
||||||
extractor.execute()
|
extractor.execute()
|
||||||
|
@ -321,33 +321,33 @@ void TestVolume::testSimpleVolumeDirectAccess()
|
|||||||
|
|
||||||
void TestVolume::testSimpleVolumeSamplers()
|
void TestVolume::testSimpleVolumeSamplers()
|
||||||
{
|
{
|
||||||
/*int32_t result = 0;
|
int32_t result = 0;
|
||||||
QBENCHMARK
|
QBENCHMARK
|
||||||
{
|
{
|
||||||
result = testSamplersWithWrapping(m_pSimpleVolume);
|
result = testSamplersWithWrapping(m_pSimpleVolume);
|
||||||
}
|
}
|
||||||
QCOMPARE(result, static_cast<int32_t>(-601818385)); //FXME - Wrong value?!*/
|
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVolume::testLargeVolumeDirectAccess()
|
void TestVolume::testLargeVolumeDirectAccess()
|
||||||
{
|
{
|
||||||
/*int32_t result = 0;
|
int32_t result = 0;
|
||||||
QBENCHMARK
|
QBENCHMARK
|
||||||
{
|
{
|
||||||
result = testDirectAccessWithWrapping(m_pLargeVolume);
|
result = testDirectAccessWithWrapping(m_pLargeVolume);
|
||||||
}
|
}
|
||||||
QCOMPARE(result, static_cast<int32_t>(-601818385)); //FXME - Wrong value?!*/
|
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVolume::testLargeVolumeSamplers()
|
void TestVolume::testLargeVolumeSamplers()
|
||||||
{
|
{
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
/*QBENCHMARK
|
QBENCHMARK
|
||||||
{
|
{
|
||||||
result = testSamplersWithWrapping(m_pLargeVolume);
|
result = testSamplersWithWrapping(m_pLargeVolume);
|
||||||
}
|
}
|
||||||
QCOMPARE(result, static_cast<int32_t>(-601818385)); //FXME - Wrong value?!*/
|
QCOMPARE(result, static_cast<int32_t>(-928601007));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestVolume)
|
QTEST_MAIN(TestVolume)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user