Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/kernels/common/scene_user_geometry.h
9905 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "accelset.h"
7
8
namespace embree
9
{
10
/*! User geometry with user defined intersection functions */
11
struct UserGeometry : public AccelSet
12
{
13
/*! type of this geometry */
14
static const Geometry::GTypeMask geom_type = Geometry::MTY_USER_GEOMETRY;
15
16
public:
17
UserGeometry (Device* device, unsigned int items = 0, unsigned int numTimeSteps = 1);
18
virtual void setMask (unsigned mask) override;
19
virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) override;
20
virtual void setIntersectFunctionN (RTCIntersectFunctionN intersect) override;
21
virtual void setOccludedFunctionN (RTCOccludedFunctionN occluded) override;
22
virtual void build() override {}
23
virtual void addElementsToCount (GeometryCounts & counts) const override;
24
virtual size_t getGeometryDataDeviceByteSize() const override;
25
virtual void convertToDeviceRepresentation(size_t offset, char* data_host, char* data_device) const override;
26
27
__forceinline float projectedPrimitiveArea(const size_t i) const { return 0.0f; }
28
};
29
30
namespace isa
31
{
32
struct UserGeometryISA : public UserGeometry
33
{
34
UserGeometryISA (Device* device)
35
: UserGeometry(device) {}
36
37
PrimInfo createPrimRefArray(PrimRef* prims, const range<size_t>& r, size_t k, unsigned int geomID) const
38
{
39
PrimInfo pinfo(empty);
40
for (size_t j=r.begin(); j<r.end(); j++)
41
{
42
BBox3fa bounds = empty;
43
if (!buildBounds(j,&bounds)) continue;
44
const PrimRef prim(bounds,geomID,unsigned(j));
45
pinfo.add_center2(prim);
46
prims[k++] = prim;
47
}
48
return pinfo;
49
}
50
51
PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, size_t itime, const range<size_t>& r, size_t k, unsigned int geomID) const
52
{
53
PrimInfo pinfo(empty);
54
for (size_t j=r.begin(); j<r.end(); j++)
55
{
56
BBox3fa bounds = empty;
57
if (!buildBounds(j,itime,bounds)) continue;
58
const PrimRef prim(bounds,geomID,unsigned(j));
59
pinfo.add_center2(prim);
60
prims[k++] = prim;
61
}
62
return pinfo;
63
}
64
65
PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& time_range, const range<size_t>& r, size_t k, unsigned int geomID) const
66
{
67
PrimInfo pinfo(empty);
68
const BBox1f t0t1 = BBox1f::intersect(getTimeRange(), time_range);
69
if (t0t1.empty()) return pinfo;
70
71
for (size_t j = r.begin(); j < r.end(); j++) {
72
LBBox3fa lbounds = empty;
73
if (!linearBounds(j, t0t1, lbounds))
74
continue;
75
const PrimRef prim(lbounds.bounds(), geomID, unsigned(j));
76
pinfo.add_center2(prim);
77
prims[k++] = prim;
78
}
79
return pinfo;
80
}
81
82
PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const
83
{
84
PrimInfoMB pinfo(empty);
85
for (size_t j=r.begin(); j<r.end(); j++)
86
{
87
if (!valid(j, timeSegmentRange(t0t1))) continue;
88
const PrimRefMB prim(linearBounds(j,t0t1),this->numTimeSegments(),this->time_range,this->numTimeSegments(),geomID,unsigned(j));
89
pinfo.add_primref(prim);
90
prims[k++] = prim;
91
}
92
return pinfo;
93
}
94
};
95
}
96
97
DECLARE_ISA_FUNCTION(UserGeometry*, createUserGeometry, Device*);
98
}
99
100