Skip to content

Commit

Permalink
internal refactor and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-sawhney committed Jan 28, 2024
1 parent 6515465 commit 69cf990
Show file tree
Hide file tree
Showing 45 changed files with 8,439 additions and 8,669 deletions.
114 changes: 51 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,56 @@ project(fcpw)
option(FCPW_USE_ENOKI "Build enoki" ON)
option(FCPW_USE_EIGHT_WIDE_BRANCHING "Use 8 wide branching (default 4)" OFF)
option(FCPW_BUILD_TESTS "Build tests" OFF)
option(FCPW_TESTS_BENCHMARK_EMBREE "Benchmark embree" OFF)

################################################################################
# submodule check
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

if(CMAKE_BUILD_TYPE MATCHES RELEASE)
add_definitions(-DNDEBUG)
add_definitions(-DNDEBUG)
endif()

################################################################################
# add dependencies
get_directory_property(hasParent PARENT_DIRECTORY)

if(hasParent)
set(FCPW_EIGEN_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/eigen-git-mirror PARENT_SCOPE)
set(FCPW_EIGEN_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/eigen-git-mirror PARENT_SCOPE)
else()
set(FCPW_EIGEN_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/eigen-git-mirror)
set(FCPW_EIGEN_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/eigen-git-mirror)
endif()

if(FCPW_BUILD_TESTS)
if(FCPW_TESTS_BENCHMARK_EMBREE)
set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL "Enable ispc functionality")
set(EMBREE_TUTORIALS OFF CACHE BOOL "Enable embree tutorials")
add_subdirectory(deps/embree)
if(hasParent)
set(FCPW_TESTS_EMBREE_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/embree PARENT_SCOPE)
else()
set(FCPW_TESTS_EMBREE_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/embree)
endif()
endif()

set(TBB_BUILD_SHARED ON CACHE BOOL " " FORCE)
set(TBB_BUILD_STATIC OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TESTS OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC_PROXY OFF CACHE BOOL " " FORCE)
add_subdirectory(deps/tbb)
set_property(TARGET tbb tbb_def_files PROPERTY FOLDER "dependencies")
if(hasParent)
set(FCPW_TESTS_TBB_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/tbb/include PARENT_SCOPE)
else()
set(FCPW_TESTS_TBB_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/tbb/include)
endif()
set(TBB_BUILD_SHARED ON CACHE BOOL " " FORCE)
set(TBB_BUILD_STATIC OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TESTS OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC_PROXY OFF CACHE BOOL " " FORCE)
add_subdirectory(deps/tbb)
set_property(TARGET tbb tbb_def_files PROPERTY FOLDER "dependencies")
if(hasParent)
set(FCPW_TESTS_TBB_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/tbb/include PARENT_SCOPE)
else()
set(FCPW_TESTS_TBB_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/tbb/include)
endif()
endif()

if(FCPW_USE_ENOKI)
add_subdirectory(deps/enoki)
if(hasParent)
set(FCPW_ENOKI_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/enoki/include PARENT_SCOPE)
else()
set(FCPW_ENOKI_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/enoki/include)
endif()
add_subdirectory(deps/enoki)
if(hasParent)
set(FCPW_ENOKI_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/enoki/include PARENT_SCOPE)
else()
set(FCPW_ENOKI_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/enoki/include)
endif()

# Update the compilation flags
enoki_set_compile_flags()
enoki_set_native_flags()
# Update the compilation flags
enoki_set_compile_flags()
enoki_set_native_flags()
endif()

################################################################################
Expand All @@ -75,34 +63,34 @@ target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${${PROJE
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)

if(FCPW_USE_ENOKI)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_USE_ENOKI)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_USE_ENOKI)

# define SIMD width
string(TOUPPER "${ENOKI_ARCH_FLAGS}" ENOKI_ARCH_FLAGS_UPPER)
message(STATUS "Enoki Max ISA: " ${ENOKI_ARCH_FLAGS_UPPER})
if(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "SSE")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=4)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "AVX2")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=8)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "AVX")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=8)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "KNL")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=16)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "SKX")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=16)
else()
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=4)
endif()
# define SIMD width
string(TOUPPER "${ENOKI_ARCH_FLAGS}" ENOKI_ARCH_FLAGS_UPPER)
message(STATUS "Enoki Max ISA: " ${ENOKI_ARCH_FLAGS_UPPER})
if(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "SSE")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=4)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "AVX2")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=8)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "AVX")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=8)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "KNL")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=16)
elseif(${ENOKI_ARCH_FLAGS_UPPER} MATCHES "SKX")
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=16)
else()
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_SIMD_WIDTH=4)
endif()

if(FCPW_USE_EIGHT_WIDE_BRANCHING)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_USE_EIGHT_WIDE_BRANCHING)
endif()
if(FCPW_USE_EIGHT_WIDE_BRANCHING)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DFCPW_USE_EIGHT_WIDE_BRANCHING)
endif()
endif()

################################################################################
# build tests
if(FCPW_BUILD_TESTS)
set(ARGS_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/polyscope/deps/args)
add_subdirectory(deps/polyscope)
add_subdirectory(tests)
set(FCPW_ARGS_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/deps/polyscope/deps/args)
add_subdirectory(deps/polyscope)
add_subdirectory(tests)
endif()
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ in the file where you want to use *FCPW*. If you are not using Cmake, then you'l
and include Eigen and Enoki (optional) independently into your project. If you plan on building and running the tests, clone the following projects into the `deps` folder

```
git clone https://github.com/embree/embree.git deps/embree
git clone https://github.com/wjakob/tbb.git deps/tbb
git clone --recurse-submodules https://github.com/nmwsharp/polyscope.git deps/polyscope
```
Expand Down Expand Up @@ -68,9 +67,6 @@ for (int i = 0; i < nTriangles; i++) {
scene.setObjectTriangle(&indices[3*i], i, 0);
}

// compute vertex & edge normals (optional)
scene.computeObjectNormals(0);

// compute silhouette data (required only for closest silhouette point queries)
scene.computeSilhouettes();

Expand Down
90 changes: 45 additions & 45 deletions include/fcpw/aggregates/baseline.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,64 @@

namespace fcpw {

template<size_t DIM, typename PrimitiveType=Primitive<DIM>, typename SilhouetteType=SilhouettePrimitive<DIM>>
template<size_t DIM,
typename PrimitiveType=Primitive<DIM>,
typename SilhouetteType=SilhouettePrimitive<DIM>>
class Baseline: public Aggregate<DIM> {
public:
// constructor
Baseline(const std::vector<PrimitiveType *>& primitives_,
const std::vector<SilhouetteType *>& silhouettes_);
// constructor
Baseline(std::vector<PrimitiveType *>& primitives_,
std::vector<SilhouetteType *>& silhouettes_);

// returns bounding box
BoundingBox<DIM> boundingBox() const;
// returns bounding box
BoundingBox<DIM> boundingBox() const;

// returns centroid
Vector<DIM> centroid() const;
// returns centroid
Vector<DIM> centroid() const;

// returns surface area
float surfaceArea() const;
// returns surface area
float surfaceArea() const;

// returns signed volume
float signedVolume() const;
// returns signed volume
float signedVolume() const;

// intersects with ray, starting the traversal at the specified node in an aggregate
// NOTE: interactions are invalid when checkForOcclusion is enabled
int intersectFromNode(Ray<DIM>& r, std::vector<Interaction<DIM>>& is,
int nodeStartIndex, int aggregateIndex, int& nodesVisited,
bool checkForOcclusion=false, bool recordAllHits=false) const;
// intersects with ray, starting the traversal at the specified node in an aggregate
// NOTE: interactions are invalid when checkForOcclusion is enabled
int intersectFromNode(Ray<DIM>& r, std::vector<Interaction<DIM>>& is,
int nodeStartIndex, int aggregateIndex, int& nodesVisited,
bool checkForOcclusion=false, bool recordAllHits=false) const;

// intersects with sphere, starting the traversal at the specified node in an aggregate
// NOTE: interactions contain primitive index
int intersectFromNode(const BoundingSphere<DIM>& s,
std::vector<Interaction<DIM>>& is,
int nodeStartIndex, int aggregateIndex,
int& nodesVisited, bool recordOneHit=false,
const std::function<float(float)>& primitiveWeight={}) const;
// intersects with sphere, starting the traversal at the specified node in an aggregate
// NOTE: interactions contain primitive index
int intersectFromNode(const BoundingSphere<DIM>& s,
std::vector<Interaction<DIM>>& is,
int nodeStartIndex, int aggregateIndex,
int& nodesVisited, bool recordOneHit=false) const;

// intersects with sphere, starting the traversal at the specified node in an aggregate
// NOTE: interactions contain primitive index
int intersectStochasticFromNode(const BoundingSphere<DIM>& s,
std::vector<Interaction<DIM>>& is, float *randNums,
int nodeStartIndex, int aggregateIndex, int& nodesVisited,
const std::function<float(float)>& traversalWeight={},
const std::function<float(float)>& primitiveWeight={}) const;
// intersects with sphere, starting the traversal at the specified node in an aggregate
// NOTE: interactions contain primitive index
int intersectStochasticFromNode(const BoundingSphere<DIM>& s,
std::vector<Interaction<DIM>>& is, float *randNums,
int nodeStartIndex, int aggregateIndex, int& nodesVisited,
const std::function<float(float)>& branchTraversalWeight={}) const;

// finds closest point to sphere center, starting the traversal at the specified node in an aggregate
bool findClosestPointFromNode(BoundingSphere<DIM>& s, Interaction<DIM>& i,
int nodeStartIndex, int aggregateIndex,
int& nodesVisited, bool recordNormal=false) const;
// finds closest point to sphere center, starting the traversal at the specified node in an aggregate
bool findClosestPointFromNode(BoundingSphere<DIM>& s, Interaction<DIM>& i,
int nodeStartIndex, int aggregateIndex,
int& nodesVisited, bool recordNormal=false) const;

// finds closest silhouette point to sphere center, starting the traversal at the specified node in an aggregate
bool findClosestSilhouettePointFromNode(BoundingSphere<DIM>& s, Interaction<DIM>& i,
int nodeStartIndex, int aggregateIndex,
int& nodesVisited, bool flipNormalOrientation=false,
float squaredMinRadius=0.0f, float precision=1e-3f,
bool recordNormal=false) const;
// finds closest silhouette point to sphere center, starting the traversal at the specified node in an aggregate
bool findClosestSilhouettePointFromNode(BoundingSphere<DIM>& s, Interaction<DIM>& i,
int nodeStartIndex, int aggregateIndex,
int& nodesVisited, bool flipNormalOrientation=false,
float squaredMinRadius=0.0f, float precision=1e-3f,
bool recordNormal=false) const;

protected:
// members
const std::vector<PrimitiveType *>& primitives;
const std::vector<SilhouetteType *>& silhouettes;
bool primitiveTypeIsAggregate;
// members
std::vector<PrimitiveType *>& primitives;
std::vector<SilhouetteType *>& silhouettes;
bool primitiveTypeIsAggregate;
};

} // namespace fcpw
Expand Down
Loading

0 comments on commit 69cf990

Please sign in to comment.