From 2e98414fd3550fef660d484d04e733dc257907b4 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Wed, 10 Dec 2014 15:47:54 +0000 Subject: [PATCH] Start updating the library bindings Nothing works at the moment and the bindings are likely going to have to change significantly. In the meantime just disable them by default to avoid confusion. --- library/bindings/CMakeLists.txt | 2 +- library/bindings/Chunk.i | 9 ++++ library/bindings/CubicSurfaceExtractor.i | 2 +- library/bindings/PagedVolume.i | 50 +++++++++++++++++++ library/bindings/PolyVoxCore.i | 63 +++++++++++------------- library/bindings/SurfaceMesh.i | 22 ++++----- library/bindings/VertexTypes.i | 4 +- 7 files changed, 103 insertions(+), 49 deletions(-) create mode 100644 library/bindings/Chunk.i create mode 100644 library/bindings/PagedVolume.i diff --git a/library/bindings/CMakeLists.txt b/library/bindings/CMakeLists.txt index f4573be6..9df9b456 100644 --- a/library/bindings/CMakeLists.txt +++ b/library/bindings/CMakeLists.txt @@ -19,7 +19,7 @@ # 3. This notice may not be removed or altered from any source # distribution. -option(ENABLE_BINDINGS "Build bindings" ON) +option(ENABLE_BINDINGS "Build bindings" OFF) #Off by default if(ENABLE_BINDINGS) find_package(SWIG) mark_as_advanced(SWIG_DIR SWIG_VERSION) diff --git a/library/bindings/Chunk.i b/library/bindings/Chunk.i new file mode 100644 index 00000000..b2559e4c --- /dev/null +++ b/library/bindings/Chunk.i @@ -0,0 +1,9 @@ +%module Chunk +%{ +#include "Chunk.h" +%} + +%include "Chunk.h" + +VOLUMETYPES(Chunk) + \ No newline at end of file diff --git a/library/bindings/CubicSurfaceExtractor.i b/library/bindings/CubicSurfaceExtractor.i index 6246925b..805c2d1d 100644 --- a/library/bindings/CubicSurfaceExtractor.i +++ b/library/bindings/CubicSurfaceExtractor.i @@ -5,5 +5,5 @@ %include "CubicSurfaceExtractor.h" -%template(CubicSurfaceExtractorSimpleVolumeuint8) PolyVox::CubicSurfaceExtractor, PolyVox::DefaultIsQuadNeeded >; +%template(extractCubicMeshSimpleVolumeuint8) extractCubicMesh >; //EXTRACTORS(CubicSurfaceExtractor) diff --git a/library/bindings/PagedVolume.i b/library/bindings/PagedVolume.i new file mode 100644 index 00000000..45f81903 --- /dev/null +++ b/library/bindings/PagedVolume.i @@ -0,0 +1,50 @@ +%module PagedVolume + +#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS + +namespace PolyVox +{ + class PolyVox::PagedVolume_Chunk { + public: + PagedVolume_Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, PolyVox::PagedVolume_Pager* pPager = nullptr); + ~PagedVolume_Chunk(); + + VoxelType* getData(void) const; + uint32_t getDataSizeInBytes(void) const; + + VoxelType getVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const; + VoxelType getVoxel(const Vector3DUint16& v3dPos) const; + + void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue); + void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue); + }; + + class PolyVox::PagedVolume_Pager { + public: + /// Constructor + PagedVolume_Pager() {}; + /// Destructor + virtual ~PagedVolume_Pager() {}; + + virtual void pageIn(const Region& region, PagedVolume_Chunk* pChunk) = 0; + virtual void pageOut(const Region& region, PagedVolume_Chunk* pChunk) = 0; + }; +} + +%{ +#include "PagedVolume.h" +%} + +%include "PagedVolume.h" + +%{ +namespace PolyVox +{ + // SWIG thinks that Inner is a global class, so we need to trick the C++ + // compiler into understanding this so called global type. + typedef PagedVolume::Pager PagedVolume_Pager; + typedef PagedVolume::Chunk PagedVolume_Chunk; +} +%} + +VOLUMETYPES(PagedVolume) diff --git a/library/bindings/PolyVoxCore.i b/library/bindings/PolyVoxCore.i index 3f6a2d0b..0e902ccd 100644 --- a/library/bindings/PolyVoxCore.i +++ b/library/bindings/PolyVoxCore.i @@ -28,30 +28,29 @@ const char* __str__() { //This macro will be called in the volume interface files to define the various volume types. %define VOLUMETYPES(class) %template(class ## int8) PolyVox::class; -%template(class ## int16) PolyVox::class; -%template(class ## int32) PolyVox::class; -%template(class ## uint8) PolyVox::class; -%template(class ## uint16) PolyVox::class; -%template(class ## uint32) PolyVox::class; -%template(class ## float) PolyVox::class; +//%template(class ## int16) PolyVox::class; +//%template(class ## int32) PolyVox::class; +//%template(class ## uint8) PolyVox::class; +//%template(class ## uint16) PolyVox::class; +//%template(class ## uint32) PolyVox::class; +//%template(class ## float) PolyVox::class; %enddef //Template based on voxel type %define EXTRACTOR(class, volumetype) %template(class ## volumetype ## int8) PolyVox::class >; -%template(class ## volumetype ## int16) PolyVox::class >; -%template(class ## volumetype ## int32) PolyVox::class >; -%template(class ## volumetype ## uint8) PolyVox::class >; -%template(class ## volumetype ## uint16) PolyVox::class >; -%template(class ## volumetype ## uint32) PolyVox::class >; -%template(class ## volumetype ## float) PolyVox::class >; +//%template(class ## volumetype ## int16) PolyVox::class >; +//%template(class ## volumetype ## int32) PolyVox::class >; +//%template(class ## volumetype ## uint8) PolyVox::class >; +//%template(class ## volumetype ## uint16) PolyVox::class >; +//%template(class ## volumetype ## uint32) PolyVox::class >; +//%template(class ## volumetype ## float) PolyVox::class >; %enddef //Template based on volume type %define EXTRACTORS(shortname) -EXTRACTOR(shortname, SimpleVolume) +EXTRACTOR(shortname, PagedVolume) EXTRACTOR(shortname, RawVolume) -EXTRACTOR(shortname, LargeVolume) %enddef %feature("autodoc", "1"); @@ -75,24 +74,20 @@ EXTRACTOR(shortname, LargeVolume) %include "Vector.i" %include "DefaultMarchingCubesController.i" %include "Region.i" -%include "Block.i" -%include "CompressedBlock.i" -%include "UncompressedBlock.i" -%include "BlockCompressor.i" -%include "Pager.i" -%include "FilePager.i" -%include "MinizBlockCompressor.i" -%include "RLEBlockCompressor.i" +//%include "Chunk.i" +//%include "CompressedBlock.i" +//%include "UncompressedBlock.i" +//%include "BlockCompressor.i" +//%include "Pager.i" +//%include "FilePager.i" +//%include "MinizBlockCompressor.i" +//%include "RLEBlockCompressor.i" %include "BaseVolume.i" -%include "SimpleVolume.i" -%include "RawVolume.i" -%include "LargeVolume.i" -//%include "SubArray.i" -//%include "Array.i" -%include "VertexTypes.i" -%include "SurfaceMesh.i" -%include "MarchingCubesSurfaceExtractor.i" -%include "CubicSurfaceExtractor.i" -%include "CubicSurfaceExtractorWithNormals.i" -%include "Raycast.i" -%include "Picking.i" +//%include "RawVolume.i" +%include "PagedVolume.i" +//%include "VertexTypes.i" +//%include "SurfaceMesh.i" +////%include "MarchingCubesSurfaceExtractor.i" +////%include "CubicSurfaceExtractor.i" +//%include "Raycast.i" +//%include "Picking.i" diff --git a/library/bindings/SurfaceMesh.i b/library/bindings/SurfaceMesh.i index dd135a72..0588971c 100644 --- a/library/bindings/SurfaceMesh.i +++ b/library/bindings/SurfaceMesh.i @@ -1,20 +1,20 @@ %module SurfaceMesh %{ #include "Region.h" -#include "VertexTypes.h" -#include "SurfaceMesh.h" +#include "Vertex.h" +#include "Mesh.h" %} %include "Region.h" -%include "VertexTypes.h" -%include "SurfaceMesh.h" +%include "Vertex.h" +%include "Mesh.h" //%template(VertexTypeVector) std::vector; -%template(PositionMaterialVector) std::vector; -%template(PositionMaterialNormalVector) std::vector; -%template(LodRecordVector) std::vector; -%template(uint8Vector) std::vector; -%template(uint32Vector) std::vector; +//%template(PositionMaterialVector) std::vector; +//%template(PositionMaterialNormalVector) std::vector; +//%template(LodRecordVector) std::vector; +//%template(uint8Vector) std::vector; +//%template(uint32Vector) std::vector; -%template(SurfaceMeshPositionMaterial) PolyVox::SurfaceMesh; -%template(SurfaceMeshPositionMaterialNormal) PolyVox::SurfaceMesh; \ No newline at end of file +%template(MeshPositionMaterial) PolyVox::Mesh, uint16_t >; +%template(MeshPositionMaterialNormal) PolyVox::Mesh, uint16_t >; \ No newline at end of file diff --git a/library/bindings/VertexTypes.i b/library/bindings/VertexTypes.i index 3ed1ff48..5f0f4e2b 100644 --- a/library/bindings/VertexTypes.i +++ b/library/bindings/VertexTypes.i @@ -2,12 +2,12 @@ %{ #include "Impl/TypeDef.h" #include "Vector.h" -#include "VertexTypes.h" +#include "Vertex.h" %} %include "Impl/TypeDef.h" %include "Vector.h" -%include "VertexTypes.h" +%include "Vertex.h" //%template (PositionMaterial) PolyVox::PositionMaterial; //%template (PositionMaterialNormal) PolyVox::PositionMaterialNormal; \ No newline at end of file