Skip to content

Commit

Permalink
Replace all embree 3 occurences
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Mar 1, 2024
1 parent 82baea0 commit 7be6208
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 22 deletions.
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ option(VIENNARAY_BUILD_TESTS "Build tests" OFF)

include("cmake/openmp.cmake")

find_package(embree 4 QUIET)
set(VIENNARAY_EMBREE_VERSION 4)
find_package(embree ${VIENNARAY_EMBREE_VERSION} QUIET)
set(VIENNARAY_SYSTEM_EMBREE ${embree_FOUND})
if (VIENNARAY_SYSTEM_EMBREE)
message(STATUS "[ViennaRay] Found embree 4 system installation")
set(VIENNARAY_EMBREE_VERSION 4)
else(VIENNARAY_SYSTEM_EMBREE)
# look for embree 3
find_package(embree 3 QUIET)
Expand Down Expand Up @@ -98,11 +98,18 @@ if (NOT VIENNARAY_SYSTEM_EMBREE)
OPTIONS "TBB_TEST OFF" "TBB_STRICT OFF")
endif()

CPMFindPackage(
NAME embree
VERSION ${VIENNARAY_EMBREE_VERSION}
GIT_REPOSITORY "https://github.com/embree/embree"
OPTIONS "EMBREE_TUTORIALS OFF")
if (VIENNARAY_EMBREE_VERSION EQUAL 3)
CPMFindPackage(
NAME embree
VERSION ${VIENNARAY_EMBREE_VERSION})
else(VIENNARAY_EMBREE_VERSION)
CPMFindPackage(
NAME embree
VERSION ${VIENNARAY_EMBREE_VERSION}
GIT_TAG v4.3.1
GIT_REPOSITORY "https://github.com/embree/embree"
OPTIONS "EMBREE_TUTORIALS OFF")
endif()

find_package(OpenMP REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX embree)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ git clone https://github.com/ViennaTools/ViennaRay.git
cd ViennaRay

cmake -B build -DCMAKE_INSTALL_PREFIX=/path/to/your/custom/install/
cmake --build build
cmake --install build
```

Expand Down
1 change: 0 additions & 1 deletion include/viennaray/rayGeometry.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef RAY_GEOMETRY_HPP
#define RAY_GEOMETRY_HPP

#include <embree3/rtcore.h>
#include <rayMetaGeometry.hpp>
#include <rayUtil.hpp>

Expand Down
4 changes: 4 additions & 0 deletions include/viennaray/rayMetaGeometry.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef RAY_METAGEOMETRY_HPP
#define RAY_METAGEOMETRY_HPP

#if VIENNARAY_EMBREE_VERSION < 4
#include <embree3/rtcore.h>
#else
#include <embree4/rtcore.h>
#endif
#include <rayUtil.hpp>

template <typename NumericType, int D> class rayMetaGeometry {
Expand Down
4 changes: 4 additions & 0 deletions include/viennaray/raySource.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef RAY_SOURCE_HPP
#define RAY_SOURCE_HPP

#if VIENNARAY_EMBREE_VERSION < 4
#include <embree3/rtcore.h>
#else
#include <embree4/rtcore.h>
#endif
#include <rayPreCompileMacros.hpp>
#include <rayRNG.hpp>
#include <rayUtil.hpp>
Expand Down
1 change: 0 additions & 1 deletion include/viennaray/rayTrace.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef RAY_TRACE_HPP
#define RAY_TRACE_HPP

#include <embree3/rtcore.h>
#include <rayBoundary.hpp>
#include <rayGeometry.hpp>
#include <rayHitCounter.hpp>
Expand Down
4 changes: 2 additions & 2 deletions include/viennaray/rayTraceKernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ template <typename NumericType, int D> class rayTraceKernel {
// probabilistic weight
const NumericType initialRayWeight = 1.;

#ifdef VIENNARAY_EMBREE_VERSION < 4
#if VIENNARAY_EMBREE_VERSION < 4
auto rtcContext = RTCIntersectContext{};
rtcInitIntersectContext(&rtcContext);
#endif
Expand Down Expand Up @@ -152,7 +152,7 @@ template <typename NumericType, int D> class rayTraceKernel {
// source

// Run the intersection
#ifdef VIENNARAY_EMBREE_VERSION < 4
#if VIENNARAY_EMBREE_VERSION < 4
rtcIntersect1(rtcScene, &rtcContext, &rayHit);
#else
rtcIntersect1(rtcScene, &rayHit);
Expand Down
4 changes: 2 additions & 2 deletions include/viennaray/rayUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace rayInternal {
constexpr double PI = 3.14159265358979323846;

template <int D>
constexpr double DiskFactor =
0.5 * (D == 3 ? 1.7320508 : 1.41421356237) * (1 + 1e-5);
constexpr double DiskFactor = 0.5 * (D == 3 ? 1.7320508 : 1.41421356237) *
(1 + 1e-5);

/* ------------- Vector operation functions ------------- */
template <typename NumericType>
Expand Down
1 change: 0 additions & 1 deletion tests/boundaryHit/boundaryHit.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayBoundary.hpp>
#include <rayGeometry.hpp>
#include <rayTestAsserts.hpp>
Expand Down
1 change: 0 additions & 1 deletion tests/boundaryHit2D/boundaryHit2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayBoundary.hpp>
#include <rayGeometry.hpp>
#include <rayTestAsserts.hpp>
Expand Down
1 change: 0 additions & 1 deletion tests/buildBoundary/buildBoundary.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayTestAsserts.hpp>
#include <rayTrace.hpp>

Expand Down
1 change: 0 additions & 1 deletion tests/buildBoundary2D/buildBoundary2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayTestAsserts.hpp>
#include <rayTrace.hpp>

Expand Down
1 change: 0 additions & 1 deletion tests/createGeometry/createGeometry.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayGeometry.hpp>
#include <rayTestAsserts.hpp>

Expand Down
1 change: 0 additions & 1 deletion tests/createRay/createRay.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayGeometry.hpp>
#include <rayRNG.hpp>
#include <raySourceGrid.hpp>
Expand Down
11 changes: 10 additions & 1 deletion tests/intersectionTest/intersectionTest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayBoundary.hpp>
#include <rayGeometry.hpp>
#include <rayTestAsserts.hpp>
Expand Down Expand Up @@ -51,8 +50,10 @@ int main() {
auto geometryID = rtcAttachGeometry(rtcscene, rtcgeometry);
rtcJoinCommitScene(rtcscene);

#if VIENNARAY_EMBREE_VERSION < 4
auto rtccontext = RTCIntersectContext{};
rtcInitIntersectContext(&rtccontext);
#endif
RAYTEST_ASSERT(rtcGetDeviceError(rtcDevice) == RTC_ERROR_NONE)

{
Expand All @@ -79,7 +80,11 @@ int main() {
rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID;

#if VIENNARAY_EMBREE_VERSION < 4
rtcIntersect1(rtcscene, &rtccontext, &rayhit);
#else
rtcIntersect1(rtcscene, &rayhit);
#endif

RAYTEST_ASSERT(rayhit.hit.geomID == geometryID)
RAYTEST_ASSERT(rayhit.hit.primID == 840)
Expand Down Expand Up @@ -110,7 +115,11 @@ int main() {
rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID;

#if VIENNARAY_EMBREE_VERSION < 4
rtcIntersect1(rtcscene, &rtccontext, &rayhit);
#else
rtcIntersect1(rtcscene, &rayhit);
#endif

RAYTEST_ASSERT(rayhit.hit.geomID == boundaryID)
RAYTEST_ASSERT(rayhit.hit.primID == 7)
Expand Down
1 change: 0 additions & 1 deletion tests/pointNeighborhood/pointNeighborhood.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayGeometry.hpp>
#include <rayTestAsserts.hpp>
#include <rayUtil.hpp>
Expand Down
1 change: 0 additions & 1 deletion tests/pointNeighborhood2D/pointNeighborhood2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <embree3/rtcore.h>
#include <rayGeometry.hpp>
#include <rayTestAsserts.hpp>

Expand Down

0 comments on commit 7be6208

Please sign in to comment.