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 // ======================================================================== //
2 // Copyright 2009-2018 Intel Corporation //
3 // //
4 // Licensed under the Apache License, Version 2.0 (the "License"); //
5 // you may not use this file except in compliance with the License. //
6 // You may obtain a copy of the License at //
7 // //
8 // http://www.apache.org/licenses/LICENSE-2.0 //
9 // //
10 // Unless required by applicable law or agreed to in writing, software //
11 // distributed under the License is distributed on an "AS IS" BASIS, //
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
13 // See the License for the specific language governing permissions and //
14 // limitations under the License. //
15 // ======================================================================== //
16 
17 #pragma once
18 
19 #include "rtcore_scene.h"
20 
22 
23 /* Opaque BVH type */
24 typedef struct RTCBVHTy* RTCBVH;
25 
26 /* Input build primitives for the builder */
27 struct RTC_ALIGN(32) RTCBuildPrimitive
28 {
29  float lower_x, lower_y, lower_z;
30  unsigned int geomID;
31  float upper_x, upper_y, upper_z;
32  unsigned int primID;
33 };
34 
35 /* Opaque thread local allocator type */
36 typedef struct RTCThreadLocalAllocatorTy* RTCThreadLocalAllocator;
37 
38 /* Callback to create a node */
39 typedef void* (*RTCCreateNodeFunction) (RTCThreadLocalAllocator allocator, unsigned int childCount, void* userPtr);
40 
41 /* Callback to set the pointer to all children */
42 typedef void (*RTCSetNodeChildrenFunction) (void* nodePtr, void** children, unsigned int childCount, void* userPtr);
43 
44 /* Callback to set the bounds of all children */
45 typedef void (*RTCSetNodeBoundsFunction) (void* nodePtr, const struct RTCBounds** bounds, unsigned int childCount, void* userPtr);
46 
47 /* Callback to create a leaf node */
48 typedef void* (*RTCCreateLeafFunction) (RTCThreadLocalAllocator allocator, const struct RTCBuildPrimitive* primitives, size_t primitiveCount, void* userPtr);
49 
50 /* Callback to split a build primitive */
51 typedef void (*RTCSplitPrimitiveFunction) (const struct RTCBuildPrimitive* primitive, unsigned int dimension, float position, struct RTCBounds* leftBounds, struct RTCBounds* rightBounds, void* userPtr);
52 
53 /* Build flags */
55 {
58 };
59 
61 {
63 };
64 
65 /* Input for builders */
67 {
68  size_t byteSize;
69 
72  unsigned int maxBranchingFactor;
73  unsigned int maxDepth;
74  unsigned int sahBlockSize;
75  unsigned int minLeafSize;
76  unsigned int maxLeafSize;
79 
81  struct RTCBuildPrimitive* primitives;
84 
91  void* userPtr;
92 };
93 
94 /* Returns the default build settings. */
96 {
97  struct RTCBuildArguments args;
98  args.byteSize = sizeof(args);
101  args.maxBranchingFactor = 2;
102  args.maxDepth = 32;
103  args.sahBlockSize = 1;
104  args.minLeafSize = 1;
106  args.traversalCost = 1.0f;
107  args.intersectionCost = 1.0f;
108  args.bvh = NULL;
109  args.primitives = NULL;
110  args.primitiveCount = 0;
111  args.primitiveArrayCapacity = 0;
112  args.createNode = NULL;
113  args.setNodeChildren = NULL;
114  args.setNodeBounds = NULL;
115  args.createLeaf = NULL;
116  args.splitPrimitive = NULL;
117  args.buildProgress = NULL;
118  args.userPtr = NULL;
119  return args;
120 }
121 
122 /* Creates a new BVH. */
124 
125 /* Builds a BVH. */
126 RTC_API void* rtcBuildBVH(const struct RTCBuildArguments* args);
127 
128 /* Allocates memory using the thread local allocator. */
129 RTC_API void* rtcThreadLocalAlloc(RTCThreadLocalAllocator allocator, size_t bytes, size_t align);
130 
131 /* Retains the BVH (increments reference count). */
133 
134 /* Releases the BVH (decrements reference count). */
136 
138 
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:54
unsigned int maxDepth
#define RTC_API
Definition: rtcore_config.h:65
typedefRTC_NAMESPACE_BEGIN struct RTCDeviceTy * RTCDevice
Definition: rtcore_device.h:24
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:33
unsigned int minLeafSize
struct RTCThreadLocalAllocatorTy * RTCThreadLocalAllocator
bool(* RTCProgressMonitorFunction)(void *ptr, double n)
Definition: rtcore_scene.h:71
unsigned int sahBlockSize
struct RTCBuildPrimitive * primitives
RTCCreateNodeFunction createNode
#define RTC_NAMESPACE_BEGIN
Definition: rtcore_config.h:32
unsigned int maxLeafSize