yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeFix type checking on generic extensions. (#5316)c97166aed

master
4.1 KiB193 linesraw
1implementing fcpw;
2__include bounding_volumes;
3
4public interface IBvhNode
5{
6    // returns the bounding box of the node
7    BoundingBox getBoundingBox();
8
9    // sets the bounding box of the node
10    [mutating]
11    void setBoundingBox(BoundingBox box_);
12
13    // checks if the node has a bounding cone
14    bool hasBoundingCone();
15
16    // returns the bounding cone of the node
17    BoundingCone getBoundingCone();
18
19    // sets the bounding cone of the node
20    [mutating]
21    void setBoundingCone(BoundingCone cone_);
22
23    // checks if the node is a leaf node
24    bool isLeaf();
25
26    // returns the offset to the right child of the interior node
27    uint getRightChildOffset();
28
29    // returns the number of primitives in the node
30    uint getNumPrimitives();
31
32    // returns the offset to the first primitive of the leaf node
33    uint getPrimitiveOffset();
34
35    // returns the number of silhouettes in the node
36    uint getNumSilhouettes();
37
38    // returns the offset to the first silhouette of the leaf node
39    uint getSilhouetteOffset();
40};
41
42public struct BvhNode : IBvhNode
43{
44    public BoundingBox box;
45    public uint nPrimitives;
46    public uint offset;
47
48    // returns the bounding box of the node
49    public BoundingBox getBoundingBox()
50    {
51        return box;
52    }
53
54    // sets the bounding box of the node
55    [mutating]
56    public void setBoundingBox(BoundingBox box_)
57    {
58        box = box_;
59    }
60
61    // checks if the node has a bounding cone
62    public bool hasBoundingCone()
63    {
64        return false;
65    }
66
67    // returns the bounding cone of the node
68    public BoundingCone getBoundingCone()
69    {
70        return BoundingCone();
71    }
72
73    // sets the bounding cone of the node
74    [mutating]
75    public void setBoundingCone(BoundingCone cone_)
76    {
77        // do nothing
78    }
79
80    // checks if the node is a leaf node
81    public bool isLeaf()
82    {
83        return nPrimitives > 0;
84    }
85
86    // returns the offset to the right child of the interior node
87    public uint getRightChildOffset()
88    {
89        return offset;
90    }
91
92    // returns the number of primitives in the node
93    public uint getNumPrimitives()
94    {
95        return nPrimitives;
96    }
97
98    // returns the offset to the first primitive of the leaf node
99    public uint getPrimitiveOffset()
100    {
101        return offset;
102    }
103
104    // returns the number of silhouettes in the node
105    public uint getNumSilhouettes()
106    {
107        return 0;
108    }
109
110    // returns the offset to the first silhouette of the leaf node
111    public uint getSilhouetteOffset()
112    {
113        return 0;
114    }
115};
116
117public struct SnchNode : IBvhNode
118{
119    public BoundingBox box;
120    public BoundingCone cone;
121    public uint nPrimitives;
122    public uint offset;
123    public uint nSilhouettes;
124    public uint silhouetteOffset;
125
126    // returns the bounding box of the node
127    public BoundingBox getBoundingBox()
128    {
129        return box;
130    }
131
132    // sets the bounding box of the node
133    [mutating]
134    public void setBoundingBox(BoundingBox box_)
135    {
136        box = box_;
137    }
138
139    // checks if the node has a bounding cone
140    public bool hasBoundingCone()
141    {
142        return true;
143    }
144
145    // returns the bounding cone of the node
146    public BoundingCone getBoundingCone()
147    {
148        return cone;
149    }
150
151    // sets the bounding cone of the node
152    [mutating]
153    public void setBoundingCone(BoundingCone cone_)
154    {
155        cone = cone_;
156    }
157
158    // checks if the node is a leaf node
159    public bool isLeaf()
160    {
161        return nPrimitives > 0;
162    }
163
164    // returns the offset to the right child of the interior node
165    public uint getRightChildOffset()
166    {
167        return offset;
168    }
169
170    // returns the number of primitives in the node
171    public uint getNumPrimitives()
172    {
173        return nPrimitives;
174    }
175
176    // returns the offset to the first primitive of the leaf node
177    public uint getPrimitiveOffset()
178    {
179        return offset;
180    }
181
182    // returns the number of silhouettes in the node
183    public uint getNumSilhouettes()
184    {
185        return nSilhouettes;
186    }
187
188    // returns the offset to the first silhouette of the leaf node
189    public uint getSilhouetteOffset()
190    {
191        return silhouetteOffset;
192    }
193};