HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rtcore_builder.h
Go to the documentation of this file.
1 // Copyright 2009-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include "rtcore_scene.h"
7 
9 
10 /* Opaque BVH type */
11 typedef struct RTCBVHTy* RTCBVH;
12 
13 /* Input build primitives for the builder */
14 struct RTC_ALIGN(32) RTCBuildPrimitive
15 {
16  float lower_x, lower_y, lower_z;
17  unsigned int geomID;
18  float upper_x, upper_y, upper_z;
19  unsigned int primID;
20 };
21 
22 /* Opaque thread local allocator type */
23 typedef struct RTCThreadLocalAllocatorTy* RTCThreadLocalAllocator;
24 
25 /* Callback to create a node */
26 typedef void* (*RTCCreateNodeFunction) (RTCThreadLocalAllocator allocator, unsigned int childCount, void* userPtr);
27 
28 /* Callback to set the pointer to all children */
29 typedef void (*RTCSetNodeChildrenFunction) (void* nodePtr, void** children, unsigned int childCount, void* userPtr);
30 
31 /* Callback to set the bounds of all children */
32 typedef void (*RTCSetNodeBoundsFunction) (void* nodePtr, const struct RTCBounds** bounds, unsigned int childCount, void* userPtr);
33 
34 /* Callback to create a leaf node */
35 typedef void* (*RTCCreateLeafFunction) (RTCThreadLocalAllocator allocator, const struct RTCBuildPrimitive* primitives, size_t primitiveCount, void* userPtr);
36 
37 /* Callback to split a build primitive */
38 typedef void (*RTCSplitPrimitiveFunction) (const struct RTCBuildPrimitive* primitive, unsigned int dimension, float position, struct RTCBounds* leftBounds, struct RTCBounds* rightBounds, void* userPtr);
39 
40 /* Build flags */
42 {
45 };
46 
48 {
50 };
51 
52 /* Input for builders */
54 {
55  size_t byteSize;
56 
59  unsigned int maxBranchingFactor;
60  unsigned int maxDepth;
61  unsigned int sahBlockSize;
62  unsigned int minLeafSize;
63  unsigned int maxLeafSize;
66 
68  struct RTCBuildPrimitive* primitives;
71 
78  void* userPtr;
79 };
80 
81 /* Returns the default build settings. */
83 {
84  struct RTCBuildArguments args;
85  args.byteSize = sizeof(args);
88  args.maxBranchingFactor = 2;
89  args.maxDepth = 32;
90  args.sahBlockSize = 1;
91  args.minLeafSize = 1;
93  args.traversalCost = 1.0f;
94  args.intersectionCost = 1.0f;
95  args.bvh = NULL;
96  args.primitives = NULL;
97  args.primitiveCount = 0;
98  args.primitiveArrayCapacity = 0;
99  args.createNode = NULL;
100  args.setNodeChildren = NULL;
101  args.setNodeBounds = NULL;
102  args.createLeaf = NULL;
103  args.splitPrimitive = NULL;
104  args.buildProgress = NULL;
105  args.userPtr = NULL;
106  return args;
107 }
108 
109 /* Creates a new BVH. */
111 
112 /* Builds a BVH. */
113 RTC_API void* rtcBuildBVH(const struct RTCBuildArguments* args);
114 
115 /* Allocates memory using the thread local allocator. */
116 RTC_API void* rtcThreadLocalAlloc(RTCThreadLocalAllocator allocator, size_t bytes, size_t align);
117 
118 /* Retains the BVH (increments reference count). */
120 
121 /* Releases the BVH (decrements reference count). */
123 
125 
typedefRTC_NAMESPACE_BEGIN struct RTCBVHTy * RTCBVH
void *(* RTCCreateNodeFunction)(RTCThreadLocalAllocator allocator, unsigned int childCount, void *userPtr)
const Args & args
Definition: printf.h:628
enum RTCBuildFlags buildFlags
RTC_API void * rtcThreadLocalAlloc(RTCThreadLocalAllocator allocator, size_t bytes, size_t align)
RTC_API void * rtcBuildBVH(const struct RTCBuildArguments *args)
#define RTC_FORCEINLINE
Definition: rtcore_common.h:41
unsigned int maxDepth
#define RTC_API
Definition: rtcore_config.h:55
typedefRTC_NAMESPACE_BEGIN struct RTCDeviceTy * RTCDevice
Definition: rtcore_device.h:11
unsigned int maxBranchingFactor
RTCSplitPrimitiveFunction splitPrimitive
RTC_API RTCBVH rtcNewBVH(RTCDevice device)
RTCBuildQuality
RTCBuildFlags
RTCProgressMonitorFunction buildProgress
RTCSetNodeBoundsFunction setNodeBounds
void(* RTCSetNodeBoundsFunction)(void *nodePtr, const struct RTCBounds **bounds, unsigned int childCount, void *userPtr)
RTCBuildConstants
RTC_API void rtcRetainBVH(RTCBVH bvh)
void(* RTCSplitPrimitiveFunction)(const struct RTCBuildPrimitive *primitive, unsigned int dimension, float position, struct RTCBounds *leftBounds, struct RTCBounds *rightBounds, void *userPtr)
RTCSetNodeChildrenFunction setNodeChildren
size_t primitiveArrayCapacity
void *(* RTCCreateLeafFunction)(RTCThreadLocalAllocator allocator, const struct RTCBuildPrimitive *primitives, size_t primitiveCount, void *userPtr)
void
Definition: png.h:1083
struct RTC_ALIGN(32) RTCBuildPrimitive
RTC_FORCEINLINE struct RTCBuildArguments rtcDefaultBuildArguments()
void(* RTCSetNodeChildrenFunction)(void *nodePtr, void **children, unsigned int childCount, void *userPtr)
enum RTCBuildQuality buildQuality
RTCCreateLeafFunction createLeaf
RTC_API void rtcReleaseBVH(RTCBVH bvh)
#define RTC_NAMESPACE_END
Definition: rtcore_config.h:23
unsigned int minLeafSize
struct RTCThreadLocalAllocatorTy * RTCThreadLocalAllocator
bool(* RTCProgressMonitorFunction)(void *ptr, double n)
Definition: rtcore_scene.h:62
unsigned int sahBlockSize
struct RTCBuildPrimitive * primitives
RTCCreateNodeFunction createNode
#define RTC_NAMESPACE_BEGIN
Definition: rtcore_config.h:22
unsigned int maxLeafSize