Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/kernels/geometry/linei_intersector.h
9905 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "linei.h"
7
#include "line_intersector.h"
8
#include "intersector_epilog.h"
9
10
namespace embree
11
{
12
namespace isa
13
{
14
template<int M, bool filter>
15
struct FlatLinearCurveMiIntersector1
16
{
17
typedef LineMi<M> Primitive;
18
typedef CurvePrecalculations1 Precalculations;
19
20
static __forceinline void intersect(const Precalculations& pre, RayHit& ray, RayQueryContext* context, const Primitive& line)
21
{
22
STAT3(normal.trav_prims,1,1,1);
23
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
24
Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
25
const vbool<M> valid = line.valid();
26
FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Intersect1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
27
}
28
29
static __forceinline bool occluded(const Precalculations& pre, Ray& ray, RayQueryContext* context, const Primitive& line)
30
{
31
STAT3(shadow.trav_prims,1,1,1);
32
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
33
Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
34
const vbool<M> valid = line.valid();
35
return FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Occluded1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
36
}
37
38
static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& line)
39
{
40
return PrimitivePointQuery1<Primitive>::pointQuery(query, context, line);
41
}
42
};
43
44
template<int M, bool filter>
45
struct FlatLinearCurveMiMBIntersector1
46
{
47
typedef LineMi<M> Primitive;
48
typedef CurvePrecalculations1 Precalculations;
49
50
static __forceinline void intersect(const Precalculations& pre, RayHit& ray, RayQueryContext* context, const Primitive& line)
51
{
52
STAT3(normal.trav_prims,1,1,1);
53
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
54
Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time());
55
const vbool<M> valid = line.valid();
56
FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Intersect1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
57
}
58
59
static __forceinline bool occluded(const Precalculations& pre, Ray& ray, RayQueryContext* context, const Primitive& line)
60
{
61
STAT3(shadow.trav_prims,1,1,1);
62
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
63
Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time());
64
const vbool<M> valid = line.valid();
65
return FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Occluded1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
66
}
67
68
static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& line)
69
{
70
return PrimitivePointQuery1<Primitive>::pointQuery(query, context, line);
71
}
72
};
73
74
template<int M, int K, bool filter>
75
struct FlatLinearCurveMiIntersectorK
76
{
77
typedef LineMi<M> Primitive;
78
typedef CurvePrecalculationsK<K> Precalculations;
79
80
static __forceinline void intersect(const Precalculations& pre, RayHitK<K>& ray, size_t k, RayQueryContext* context, const Primitive& line)
81
{
82
STAT3(normal.trav_prims,1,1,1);
83
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
84
Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
85
const vbool<M> valid = line.valid();
86
FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Intersect1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
87
}
88
89
static __forceinline bool occluded(const Precalculations& pre, RayK<K>& ray, size_t k, RayQueryContext* context, const Primitive& line)
90
{
91
STAT3(shadow.trav_prims,1,1,1);
92
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
93
Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
94
const vbool<M> valid = line.valid();
95
return FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Occluded1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
96
}
97
};
98
99
template<int M, int K, bool filter>
100
struct FlatLinearCurveMiMBIntersectorK
101
{
102
typedef LineMi<M> Primitive;
103
typedef CurvePrecalculationsK<K> Precalculations;
104
105
static __forceinline void intersect(const Precalculations& pre, RayHitK<K>& ray, size_t k, RayQueryContext* context, const Primitive& line)
106
{
107
STAT3(normal.trav_prims,1,1,1);
108
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
109
Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time()[k]);
110
const vbool<M> valid = line.valid();
111
FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Intersect1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
112
}
113
114
static __forceinline bool occluded(const Precalculations& pre, RayK<K>& ray, size_t k, RayQueryContext* context, const Primitive& line)
115
{
116
STAT3(shadow.trav_prims,1,1,1);
117
const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
118
Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time()[k]);
119
const vbool<M> valid = line.valid();
120
return FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Occluded1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
121
}
122
};
123
}
124
}
125
126