1// Copyright 2009-2021 Intel Corporation
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include "accelset.h"
7
8namespace 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);
19 virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr);
20 virtual void setIntersectFunctionN (RTCIntersectFunctionN intersect);
21 virtual void setOccludedFunctionN (RTCOccludedFunctionN occluded);
22 virtual void build() {}
23 virtual void addElementsToCount (GeometryCounts & counts) const;
24 };
25
26 namespace isa
27 {
28 struct UserGeometryISA : public UserGeometry
29 {
30 UserGeometryISA (Device* device)
31 : UserGeometry(device) {}
32
33 PrimInfo createPrimRefArray(mvector<PrimRef>& prims, const range<size_t>& r, size_t k, unsigned int geomID) const
34 {
35 PrimInfo pinfo(empty);
36 for (size_t j=r.begin(); j<r.end(); j++)
37 {
38 BBox3fa bounds = empty;
39 if (!buildBounds(i: j,bbox: &bounds)) continue;
40 const PrimRef prim(bounds,geomID,unsigned(j));
41 pinfo.add_center2(prim);
42 prims[k++] = prim;
43 }
44 return pinfo;
45 }
46
47 PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, size_t itime, const range<size_t>& r, size_t k, unsigned int geomID) const
48 {
49 PrimInfo pinfo(empty);
50 for (size_t j=r.begin(); j<r.end(); j++)
51 {
52 BBox3fa bounds = empty;
53 if (!buildBounds(i: j,itime,bbox&: bounds)) continue;
54 const PrimRef prim(bounds,geomID,unsigned(j));
55 pinfo.add_center2(prim);
56 prims[k++] = prim;
57 }
58 return pinfo;
59 }
60
61 PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const
62 {
63 PrimInfoMB pinfo(empty);
64 for (size_t j=r.begin(); j<r.end(); j++)
65 {
66 if (!valid(i: j, itime_range: timeSegmentRange(range: t0t1))) continue;
67 const PrimRefMB prim(linearBounds(primID: j,dt: t0t1),this->numTimeSegments(),this->time_range,this->numTimeSegments(),geomID,unsigned(j));
68 pinfo.add_primref(prim);
69 prims[k++] = prim;
70 }
71 return pinfo;
72 }
73 };
74 }
75
76 DECLARE_ISA_FUNCTION(UserGeometry*, createUserGeometry, Device*);
77}
78

source code of qtquick3d/src/3rdparty/embree/kernels/common/scene_user_geometry.h