Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/kernels/geometry/grid_intersector.h
9905 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "grid_soa.h"
7
#include "grid_soa_intersector1.h"
8
#include "grid_soa_intersector_packet.h"
9
#include "../common/ray.h"
10
11
namespace embree
12
{
13
namespace isa
14
{
15
template<typename T>
16
class SubdivPatch1Precalculations : public T
17
{
18
public:
19
__forceinline SubdivPatch1Precalculations (const Ray& ray, const void* ptr)
20
: T(ray,ptr) {}
21
};
22
23
template<int K, typename T>
24
class SubdivPatch1PrecalculationsK : public T
25
{
26
public:
27
__forceinline SubdivPatch1PrecalculationsK (const vbool<K>& valid, RayK<K>& ray)
28
: T(valid,ray) {}
29
};
30
31
class Grid1Intersector1
32
{
33
public:
34
typedef GridSOA Primitive;
35
typedef Grid1Precalculations<GridSOAIntersector1::Precalculations> Precalculations;
36
37
/*! Intersect a ray with the primitive. */
38
static __forceinline void intersect(Precalculations& pre, RayHit& ray, RayQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node)
39
{
40
GridSOAIntersector1::intersect(pre,ray,context,prim,lazy_node);
41
}
42
static __forceinline void intersect(Precalculations& pre, RayHit& ray, RayQueryContext* context, size_t ty0, const Primitive* prim, size_t ty, size_t& lazy_node) {
43
intersect(pre,ray,context,prim,ty,lazy_node);
44
}
45
46
/*! Test if the ray is occluded by the primitive */
47
static __forceinline bool occluded(Precalculations& pre, Ray& ray, RayQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node)
48
{
49
GridSOAIntersector1::occluded(pre,ray,context,prim,lazy_node);
50
}
51
static __forceinline bool occluded(Precalculations& pre, Ray& ray, RayQueryContext* context, size_t ty0, const Primitive* prim, size_t ty, size_t& lazy_node) {
52
return occluded(pre,ray,context,prim,ty,lazy_node);
53
}
54
55
static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node) {
56
assert(false && "not implemented");
57
return false;
58
}
59
60
static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, size_t ty0, const Primitive* prim, size_t ty, size_t& lazy_node) {
61
assert(false && "not implemented");
62
return false;
63
}
64
};
65
66
template <int K>
67
struct GridIntersectorK
68
{
69
typedef GridSOA Primitive;
70
typedef SubdivPatch1PrecalculationsK<K,typename GridSOAIntersectorK<K>::Precalculations> Precalculations;
71
72
73
static __forceinline void intersect(const vbool<K>& valid, Precalculations& pre, RayHitK<K>& ray, RayQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node)
74
{
75
GridSOAIntersectorK<K>::intersect(valid,pre,ray,context,prim,lazy_node);
76
}
77
78
static __forceinline vbool<K> occluded(const vbool<K>& valid, Precalculations& pre, RayK<K>& ray, RayQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node)
79
{
80
GridSOAIntersectorK<K>::occluded(valid,pre,ray,context,prim,lazy_node);
81
}
82
83
static __forceinline void intersect(Precalculations& pre, RayHitK<K>& ray, size_t k, RayQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node)
84
{
85
GridSOAIntersectorK<K>::intersect(pre,ray,k,context,prim,lazy_node);
86
}
87
88
static __forceinline bool occluded(Precalculations& pre, RayK<K>& ray, size_t k, RayQueryContext* context, const Primitive* prim, size_t ty, size_t& lazy_node)
89
{
90
GridSOAIntersectorK<K>::occluded(pre,ray,k,context,prim,lazy_node);
91
}
92
};
93
94
typedef Grid1IntersectorK<4> SubdivPatch1Intersector4;
95
typedef Grid1IntersectorK<8> SubdivPatch1Intersector8;
96
typedef Grid1IntersectorK<16> SubdivPatch1Intersector16;
97
98
}
99
}
100
101