Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/kernels/common/geometry.h
9905 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "default.h"
7
#include "device.h"
8
#include "buffer.h"
9
#include "../common/point_query.h"
10
#include "../builders/priminfo.h"
11
#include "../builders/priminfo_mb.h"
12
13
namespace embree
14
{
15
class Scene;
16
class Geometry;
17
18
struct GeometryCounts
19
{
20
__forceinline GeometryCounts()
21
: numFilterFunctions(0),
22
numTriangles(0), numMBTriangles(0),
23
numQuads(0), numMBQuads(0),
24
numBezierCurves(0), numMBBezierCurves(0),
25
numLineSegments(0), numMBLineSegments(0),
26
numSubdivPatches(0), numMBSubdivPatches(0),
27
numUserGeometries(0), numMBUserGeometries(0),
28
numInstancesCheap(0), numMBInstancesCheap(0),
29
numInstancesExpensive(0), numMBInstancesExpensive(0),
30
numInstanceArrays(0), numMBInstanceArrays(0),
31
numGrids(0), numMBGrids(0),
32
numSubGrids(0), numMBSubGrids(0),
33
numPoints(0), numMBPoints(0) {}
34
35
__forceinline size_t size() const {
36
return numTriangles + numQuads + numBezierCurves + numLineSegments + numSubdivPatches + numUserGeometries + numInstancesCheap + numInstancesExpensive + numInstanceArrays + numGrids + numPoints
37
+ numMBTriangles + numMBQuads + numMBBezierCurves + numMBLineSegments + numMBSubdivPatches + numMBUserGeometries + numMBInstancesCheap + numMBInstancesExpensive + numMBInstanceArrays + numMBGrids + numMBPoints;
38
}
39
40
__forceinline unsigned int enabledGeometryTypesMask() const
41
{
42
unsigned int mask = 0;
43
if (numTriangles) mask |= 1 << 0;
44
if (numQuads) mask |= 1 << 1;
45
if (numBezierCurves+numLineSegments) mask |= 1 << 2;
46
if (numSubdivPatches) mask |= 1 << 3;
47
if (numUserGeometries) mask |= 1 << 4;
48
if (numInstancesCheap) mask |= 1 << 5;
49
if (numInstancesExpensive) mask |= 1 << 6;
50
if (numInstanceArrays) mask |= 1 << 7;
51
if (numGrids) mask |= 1 << 8;
52
if (numPoints) mask |= 1 << 9;
53
54
unsigned int maskMB = 0;
55
if (numMBTriangles) maskMB |= 1 << 0;
56
if (numMBQuads) maskMB |= 1 << 1;
57
if (numMBBezierCurves+numMBLineSegments) maskMB |= 1 << 2;
58
if (numMBSubdivPatches) maskMB |= 1 << 3;
59
if (numMBUserGeometries) maskMB |= 1 << 4;
60
if (numMBInstancesCheap) maskMB |= 1 << 5;
61
if (numMBInstancesExpensive) maskMB |= 1 << 6;
62
if (numMBInstanceArrays) maskMB |= 1 << 7;
63
if (numMBGrids) maskMB |= 1 << 8;
64
if (numMBPoints) maskMB |= 1 << 9;
65
66
return (mask<<8) + maskMB;
67
}
68
69
__forceinline GeometryCounts operator+ (GeometryCounts const & rhs) const
70
{
71
GeometryCounts ret;
72
ret.numFilterFunctions = numFilterFunctions + rhs.numFilterFunctions;
73
ret.numTriangles = numTriangles + rhs.numTriangles;
74
ret.numMBTriangles = numMBTriangles + rhs.numMBTriangles;
75
ret.numQuads = numQuads + rhs.numQuads;
76
ret.numMBQuads = numMBQuads + rhs.numMBQuads;
77
ret.numBezierCurves = numBezierCurves + rhs.numBezierCurves;
78
ret.numMBBezierCurves = numMBBezierCurves + rhs.numMBBezierCurves;
79
ret.numLineSegments = numLineSegments + rhs.numLineSegments;
80
ret.numMBLineSegments = numMBLineSegments + rhs.numMBLineSegments;
81
ret.numSubdivPatches = numSubdivPatches + rhs.numSubdivPatches;
82
ret.numMBSubdivPatches = numMBSubdivPatches + rhs.numMBSubdivPatches;
83
ret.numUserGeometries = numUserGeometries + rhs.numUserGeometries;
84
ret.numMBUserGeometries = numMBUserGeometries + rhs.numMBUserGeometries;
85
ret.numInstancesCheap = numInstancesCheap + rhs.numInstancesCheap;
86
ret.numMBInstancesCheap = numMBInstancesCheap + rhs.numMBInstancesCheap;
87
ret.numInstancesExpensive = numInstancesExpensive + rhs.numInstancesExpensive;
88
ret.numMBInstancesExpensive = numMBInstancesExpensive + rhs.numMBInstancesExpensive;
89
ret.numInstanceArrays = numInstanceArrays + rhs.numInstanceArrays;
90
ret.numMBInstanceArrays = numMBInstanceArrays + rhs.numMBInstanceArrays;
91
ret.numGrids = numGrids + rhs.numGrids;
92
ret.numMBGrids = numMBGrids + rhs.numMBGrids;
93
ret.numSubGrids = numSubGrids + rhs.numSubGrids;
94
ret.numMBSubGrids = numMBSubGrids + rhs.numMBSubGrids;
95
ret.numPoints = numPoints + rhs.numPoints;
96
ret.numMBPoints = numMBPoints + rhs.numMBPoints;
97
98
return ret;
99
}
100
101
size_t numFilterFunctions; //!< number of geometries with filter functions enabled
102
size_t numTriangles; //!< number of enabled triangles
103
size_t numMBTriangles; //!< number of enabled motion blurred triangles
104
size_t numQuads; //!< number of enabled quads
105
size_t numMBQuads; //!< number of enabled motion blurred quads
106
size_t numBezierCurves; //!< number of enabled curves
107
size_t numMBBezierCurves; //!< number of enabled motion blurred curves
108
size_t numLineSegments; //!< number of enabled line segments
109
size_t numMBLineSegments; //!< number of enabled line motion blurred segments
110
size_t numSubdivPatches; //!< number of enabled subdivision patches
111
size_t numMBSubdivPatches; //!< number of enabled motion blurred subdivision patches
112
size_t numUserGeometries; //!< number of enabled user geometries
113
size_t numMBUserGeometries; //!< number of enabled motion blurred user geometries
114
size_t numInstancesCheap; //!< number of enabled cheap instances
115
size_t numMBInstancesCheap; //!< number of enabled motion blurred cheap instances
116
size_t numInstancesExpensive; //!< number of enabled expensive instances
117
size_t numMBInstancesExpensive; //!< number of enabled motion blurred expensive instances
118
size_t numInstanceArrays; //!< number of enabled instance arrays
119
size_t numMBInstanceArrays; //!< number of enabled motion blurred instance arrays
120
size_t numGrids; //!< number of enabled grid geometries
121
size_t numMBGrids; //!< number of enabled motion blurred grid geometries
122
size_t numSubGrids; //!< number of enabled grid geometries
123
size_t numMBSubGrids; //!< number of enabled motion blurred grid geometries
124
size_t numPoints; //!< number of enabled points
125
size_t numMBPoints; //!< number of enabled motion blurred points
126
};
127
128
/*! Base class all geometries are derived from */
129
class __aligned(16) Geometry : public RefCount
130
{
131
friend class Scene;
132
public:
133
134
/*! type of geometry */
135
enum GType
136
{
137
GTY_FLAT_LINEAR_CURVE = 0,
138
GTY_ROUND_LINEAR_CURVE = 1,
139
GTY_ORIENTED_LINEAR_CURVE = 2,
140
GTY_CONE_LINEAR_CURVE = 3,
141
142
GTY_FLAT_BEZIER_CURVE = 4,
143
GTY_ROUND_BEZIER_CURVE = 5,
144
GTY_ORIENTED_BEZIER_CURVE = 6,
145
146
GTY_FLAT_BSPLINE_CURVE = 8,
147
GTY_ROUND_BSPLINE_CURVE = 9,
148
GTY_ORIENTED_BSPLINE_CURVE = 10,
149
150
GTY_FLAT_HERMITE_CURVE = 12,
151
GTY_ROUND_HERMITE_CURVE = 13,
152
GTY_ORIENTED_HERMITE_CURVE = 14,
153
154
GTY_FLAT_CATMULL_ROM_CURVE = 16,
155
GTY_ROUND_CATMULL_ROM_CURVE = 17,
156
GTY_ORIENTED_CATMULL_ROM_CURVE = 18,
157
158
GTY_TRIANGLE_MESH = 20,
159
GTY_QUAD_MESH = 21,
160
GTY_GRID_MESH = 22,
161
GTY_SUBDIV_MESH = 23,
162
163
GTY_SPHERE_POINT = 25,
164
GTY_DISC_POINT = 26,
165
GTY_ORIENTED_DISC_POINT = 27,
166
167
GTY_USER_GEOMETRY = 29,
168
GTY_INSTANCE_CHEAP = 30,
169
GTY_INSTANCE_EXPENSIVE = 31,
170
GTY_INSTANCE_ARRAY = 24,
171
GTY_END = 32,
172
173
GTY_BASIS_LINEAR = 0,
174
GTY_BASIS_BEZIER = 4,
175
GTY_BASIS_BSPLINE = 8,
176
GTY_BASIS_HERMITE = 12,
177
GTY_BASIS_CATMULL_ROM = 16,
178
GTY_BASIS_MASK = 28,
179
180
GTY_SUBTYPE_FLAT_CURVE = 0,
181
GTY_SUBTYPE_ROUND_CURVE = 1,
182
GTY_SUBTYPE_ORIENTED_CURVE = 2,
183
GTY_SUBTYPE_MASK = 3,
184
};
185
186
enum GSubType
187
{
188
GTY_SUBTYPE_DEFAULT= 0,
189
GTY_SUBTYPE_INSTANCE_LINEAR = 0,
190
GTY_SUBTYPE_INSTANCE_QUATERNION = 1
191
};
192
193
enum GTypeMask
194
{
195
MTY_FLAT_LINEAR_CURVE = 1ul << GTY_FLAT_LINEAR_CURVE,
196
MTY_ROUND_LINEAR_CURVE = 1ul << GTY_ROUND_LINEAR_CURVE,
197
MTY_CONE_LINEAR_CURVE = 1ul << GTY_CONE_LINEAR_CURVE,
198
MTY_ORIENTED_LINEAR_CURVE = 1ul << GTY_ORIENTED_LINEAR_CURVE,
199
200
MTY_FLAT_BEZIER_CURVE = 1ul << GTY_FLAT_BEZIER_CURVE,
201
MTY_ROUND_BEZIER_CURVE = 1ul << GTY_ROUND_BEZIER_CURVE,
202
MTY_ORIENTED_BEZIER_CURVE = 1ul << GTY_ORIENTED_BEZIER_CURVE,
203
204
MTY_FLAT_BSPLINE_CURVE = 1ul << GTY_FLAT_BSPLINE_CURVE,
205
MTY_ROUND_BSPLINE_CURVE = 1ul << GTY_ROUND_BSPLINE_CURVE,
206
MTY_ORIENTED_BSPLINE_CURVE = 1ul << GTY_ORIENTED_BSPLINE_CURVE,
207
208
MTY_FLAT_HERMITE_CURVE = 1ul << GTY_FLAT_HERMITE_CURVE,
209
MTY_ROUND_HERMITE_CURVE = 1ul << GTY_ROUND_HERMITE_CURVE,
210
MTY_ORIENTED_HERMITE_CURVE = 1ul << GTY_ORIENTED_HERMITE_CURVE,
211
212
MTY_FLAT_CATMULL_ROM_CURVE = 1ul << GTY_FLAT_CATMULL_ROM_CURVE,
213
MTY_ROUND_CATMULL_ROM_CURVE = 1ul << GTY_ROUND_CATMULL_ROM_CURVE,
214
MTY_ORIENTED_CATMULL_ROM_CURVE = 1ul << GTY_ORIENTED_CATMULL_ROM_CURVE,
215
216
MTY_CURVE2 = MTY_FLAT_LINEAR_CURVE | MTY_ROUND_LINEAR_CURVE | MTY_CONE_LINEAR_CURVE | MTY_ORIENTED_LINEAR_CURVE,
217
218
MTY_CURVE4 = MTY_FLAT_BEZIER_CURVE | MTY_ROUND_BEZIER_CURVE | MTY_ORIENTED_BEZIER_CURVE |
219
MTY_FLAT_BSPLINE_CURVE | MTY_ROUND_BSPLINE_CURVE | MTY_ORIENTED_BSPLINE_CURVE |
220
MTY_FLAT_HERMITE_CURVE | MTY_ROUND_HERMITE_CURVE | MTY_ORIENTED_HERMITE_CURVE |
221
MTY_FLAT_CATMULL_ROM_CURVE | MTY_ROUND_CATMULL_ROM_CURVE | MTY_ORIENTED_CATMULL_ROM_CURVE,
222
223
MTY_SPHERE_POINT = 1ul << GTY_SPHERE_POINT,
224
MTY_DISC_POINT = 1ul << GTY_DISC_POINT,
225
MTY_ORIENTED_DISC_POINT = 1ul << GTY_ORIENTED_DISC_POINT,
226
227
MTY_POINTS = MTY_SPHERE_POINT | MTY_DISC_POINT | MTY_ORIENTED_DISC_POINT,
228
229
MTY_CURVES = MTY_CURVE2 | MTY_CURVE4 | MTY_POINTS,
230
231
MTY_TRIANGLE_MESH = 1ul << GTY_TRIANGLE_MESH,
232
MTY_QUAD_MESH = 1ul << GTY_QUAD_MESH,
233
MTY_GRID_MESH = 1ul << GTY_GRID_MESH,
234
MTY_SUBDIV_MESH = 1ul << GTY_SUBDIV_MESH,
235
MTY_USER_GEOMETRY = 1ul << GTY_USER_GEOMETRY,
236
237
MTY_INSTANCE_CHEAP = 1ul << GTY_INSTANCE_CHEAP,
238
MTY_INSTANCE_EXPENSIVE = 1ul << GTY_INSTANCE_EXPENSIVE,
239
MTY_INSTANCE = MTY_INSTANCE_CHEAP | MTY_INSTANCE_EXPENSIVE,
240
MTY_INSTANCE_ARRAY = 1ul << GTY_INSTANCE_ARRAY,
241
242
MTY_ALL = -1
243
};
244
245
static const char* gtype_names[GTY_END];
246
247
enum class State : unsigned {
248
MODIFIED = 0,
249
COMMITTED = 1,
250
};
251
252
public:
253
254
/*! Geometry constructor */
255
Geometry (Device* device, GType gtype, unsigned int numPrimitives, unsigned int numTimeSteps);
256
257
/*! Geometry destructor */
258
virtual ~Geometry();
259
260
public:
261
262
/*! tests if geometry is enabled */
263
__forceinline bool isEnabled() const { return enabled; }
264
265
/*! tests if geometry is disabled */
266
__forceinline bool isDisabled() const { return !isEnabled(); }
267
268
/* checks if argument version of filter functions are enabled */
269
__forceinline bool hasArgumentFilterFunctions() const {
270
return argumentFilterEnabled;
271
}
272
273
/*! tests if that geometry has some filter function set */
274
__forceinline bool hasGeometryFilterFunctions () const {
275
return (intersectionFilterN != nullptr) || (occlusionFilterN != nullptr);
276
}
277
278
/*! returns geometry type */
279
__forceinline GType getType() const { return gtype; }
280
281
/*! returns curve type */
282
__forceinline GType getCurveType() const { return (GType)(gtype & GTY_SUBTYPE_MASK); }
283
284
/*! returns curve basis */
285
__forceinline GType getCurveBasis() const { return (GType)(gtype & GTY_BASIS_MASK); }
286
287
/*! returns geometry type mask */
288
__forceinline GTypeMask getTypeMask() const { return (GTypeMask)(1 << gtype); }
289
290
/*! returns true of geometry contains motion blur */
291
__forceinline bool hasMotionBlur () const {
292
return numTimeSteps > 1;
293
}
294
295
/*! returns number of primitives */
296
__forceinline size_t size() const { return numPrimitives; }
297
298
/*! sets the number of primitives */
299
virtual void setNumPrimitives(unsigned int numPrimitives_in);
300
301
/*! sets number of time steps */
302
virtual void setNumTimeSteps (unsigned int numTimeSteps_in);
303
304
/*! sets motion blur time range */
305
void setTimeRange (const BBox1f range);
306
307
/*! gets motion blur time range */
308
BBox1f getTimeRange () const;
309
310
/*! sets number of vertex attributes */
311
virtual void setVertexAttributeCount (unsigned int N) {
312
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
313
}
314
315
/*! sets number of topologies */
316
virtual void setTopologyCount (unsigned int N) {
317
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
318
}
319
320
/*! sets the build quality */
321
void setBuildQuality(RTCBuildQuality quality_in)
322
{
323
this->quality = quality_in;
324
Geometry::update();
325
}
326
327
/* calculate time segment itime and fractional time ftime */
328
__forceinline int timeSegment(float time, float& ftime) const {
329
return getTimeSegment(time,time_range.lower,time_range.upper,fnumTimeSegments,ftime);
330
}
331
332
template<int N>
333
__forceinline vint<N> timeSegment(const vfloat<N>& time, vfloat<N>& ftime) const {
334
return getTimeSegment<N>(time,vfloat<N>(time_range.lower),vfloat<N>(time_range.upper),vfloat<N>(fnumTimeSegments),ftime);
335
}
336
337
/* calculate overlapping time segment range */
338
__forceinline range<int> timeSegmentRange(const BBox1f& range) const {
339
return getTimeSegmentRange(range,time_range,fnumTimeSegments);
340
}
341
342
/* returns time that corresponds to time step */
343
__forceinline float timeStep(const int i) const {
344
assert(i>=0 && i<(int)numTimeSteps);
345
return time_range.lower + time_range.size()*float(i)/fnumTimeSegments;
346
}
347
348
/*! for all geometries */
349
public:
350
351
/*! Enable geometry. */
352
virtual void enable();
353
354
/*! Update geometry. */
355
void update();
356
357
/*! commit of geometry */
358
virtual void commit();
359
360
/*! Update geometry buffer. */
361
virtual void updateBuffer(RTCBufferType type, unsigned int slot) {
362
update(); // update everything for geometries not supporting this call
363
}
364
365
/*! Disable geometry. */
366
virtual void disable();
367
368
/*! Verify the geometry */
369
virtual bool verify() { return true; }
370
371
/*! called before every build */
372
virtual void preCommit();
373
374
/*! called after every build */
375
virtual void postCommit();
376
377
virtual void addElementsToCount (GeometryCounts & counts) const {
378
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
379
};
380
381
/*! sets constant tessellation rate for the geometry */
382
virtual void setTessellationRate(float N) {
383
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
384
}
385
386
/*! Sets the maximal curve radius scale allowed by min-width feature. */
387
virtual void setMaxRadiusScale(float s) {
388
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
389
}
390
391
/*! Set user data pointer. */
392
virtual void setUserData(void* ptr);
393
394
/*! Get user data pointer. */
395
__forceinline void* getUserData() const {
396
return userPtr;
397
}
398
399
/*! interpolates user data to the specified u/v location */
400
virtual void interpolate(const RTCInterpolateArguments* const args) {
401
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
402
}
403
404
/*! interpolates user data to the specified u/v locations */
405
virtual void interpolateN(const RTCInterpolateNArguments* const args);
406
407
/* point query api */
408
bool pointQuery(PointQuery* query, PointQueryContext* context);
409
410
/*! for subdivision surfaces only */
411
public:
412
virtual void setSubdivisionMode (unsigned topologyID, RTCSubdivisionMode mode) {
413
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
414
}
415
416
virtual void setVertexAttributeTopology(unsigned int vertexBufferSlot, unsigned int indexBufferSlot) {
417
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
418
}
419
420
/*! Set displacement function. */
421
virtual void setDisplacementFunction (RTCDisplacementFunctionN filter) {
422
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
423
}
424
425
virtual unsigned int getFirstHalfEdge(unsigned int faceID) {
426
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
427
}
428
429
virtual unsigned int getFace(unsigned int edgeID) {
430
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
431
}
432
433
virtual unsigned int getNextHalfEdge(unsigned int edgeID) {
434
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
435
}
436
437
virtual unsigned int getPreviousHalfEdge(unsigned int edgeID) {
438
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
439
}
440
441
virtual unsigned int getOppositeHalfEdge(unsigned int topologyID, unsigned int edgeID) {
442
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
443
}
444
445
/*! get fast access to first vertex buffer if applicable */
446
virtual float * getCompactVertexArray () const {
447
return nullptr;
448
}
449
450
/*! Returns the modified counter - how many times the geo has been modified */
451
__forceinline unsigned int getModCounter () const {
452
return modCounter_;
453
}
454
455
/*! for triangle meshes and bezier curves only */
456
public:
457
458
459
/*! Sets ray mask. */
460
virtual void setMask(unsigned mask) {
461
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
462
}
463
464
/*! Sets specified buffer. */
465
virtual void setBuffer(RTCBufferType type, unsigned int slot, RTCFormat format, const Ref<Buffer>& buffer, size_t offset, size_t stride, unsigned int num) {
466
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
467
}
468
469
/*! Gets specified buffer. */
470
virtual void* getBufferData(RTCBufferType type, unsigned int slot, BufferDataPointerType pointerType) {
471
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
472
}
473
474
/*! Set intersection filter function for ray packets of size N. */
475
virtual void setIntersectionFilterFunctionN (RTCFilterFunctionN filterN);
476
477
/*! Set occlusion filter function for ray packets of size N. */
478
virtual void setOcclusionFilterFunctionN (RTCFilterFunctionN filterN);
479
480
/* Enables argument version of intersection or occlusion filter function. */
481
virtual void enableFilterFunctionFromArguments (bool enable) {
482
argumentFilterEnabled = enable;
483
}
484
485
/*! for instances only */
486
public:
487
488
/*! Sets the instanced scene */
489
virtual void setInstancedScene(const Ref<Scene>& scene) {
490
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
491
}
492
493
/*! Sets the instanced scenes */
494
virtual void setInstancedScenes(const RTCScene* scenes, size_t numScenes) {
495
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
496
}
497
498
/*! Sets transformation of the instance */
499
virtual void setTransform(const AffineSpace3fa& transform, unsigned int timeStep) {
500
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
501
}
502
503
/*! Sets transformation of the instance */
504
virtual void setQuaternionDecomposition(const AffineSpace3ff& qd, unsigned int timeStep) {
505
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
506
}
507
508
/*! Returns the transformation of the instance */
509
virtual AffineSpace3fa getTransform(float time) {
510
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
511
}
512
513
/*! Returns the transformation of the instance */
514
virtual AffineSpace3fa getTransform(size_t instance, float time) {
515
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
516
}
517
518
/*! for user geometries only */
519
public:
520
521
/*! Set bounds function. */
522
virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) {
523
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
524
}
525
526
/*! Set intersect function for ray packets of size N. */
527
virtual void setIntersectFunctionN (RTCIntersectFunctionN intersect) {
528
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
529
}
530
531
/*! Set occlusion function for ray packets of size N. */
532
virtual void setOccludedFunctionN (RTCOccludedFunctionN occluded) {
533
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
534
}
535
536
/*! Set point query function. */
537
void setPointQueryFunction(RTCPointQueryFunction func);
538
539
/*! returns number of time segments */
540
__forceinline unsigned numTimeSegments () const {
541
return numTimeSteps-1;
542
}
543
544
public:
545
546
/*! methods for converting host geometry data to device geometry data */
547
virtual size_t getGeometryDataDeviceByteSize() const {
548
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"getGeometryDataDeviceByteSize not implemented for this geometry");
549
}
550
551
virtual void convertToDeviceRepresentation(size_t offset, char* data_host, char* data_device) const {
552
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"convertToDeviceRepresentation not implemented for this geometry");
553
}
554
555
public:
556
557
virtual PrimInfo createPrimRefArray(PrimRef* prims, const range<size_t>& r, size_t k, unsigned int geomID) const {
558
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefArray not implemented for this geometry");
559
}
560
561
PrimInfo createPrimRefArray(mvector<PrimRef>& prims, const range<size_t>& r, size_t k, unsigned int geomID) const {
562
return createPrimRefArray(prims.data(),r,k,geomID);
563
}
564
565
PrimInfo createPrimRefArray(avector<PrimRef>& prims, const range<size_t>& r, size_t k, unsigned int geomID) const {
566
return createPrimRefArray(prims.data(),r,k,geomID);
567
}
568
569
virtual PrimInfo createPrimRefArray(mvector<PrimRef>& prims, mvector<SubGridBuildData>& sgrids, const range<size_t>& r, size_t k, unsigned int geomID) const {
570
return createPrimRefArray(prims,r,k,geomID);
571
}
572
573
virtual PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, size_t itime, const range<size_t>& r, size_t k, unsigned int geomID) const {
574
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry");
575
}
576
577
/*! Calculates the PrimRef over the complete time interval */
578
virtual PrimInfo createPrimRefArrayMB(PrimRef* prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
579
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry");
580
}
581
582
PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
583
return createPrimRefArrayMB(prims.data(),t0t1,r,k,geomID);
584
}
585
586
PrimInfo createPrimRefArrayMB(avector<PrimRef>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
587
return createPrimRefArrayMB(prims.data(),t0t1,r,k,geomID);
588
}
589
590
virtual PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
591
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry");
592
}
593
594
virtual PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, mvector<SubGridBuildData>& sgrids, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
595
return createPrimRefMBArray(prims,t0t1,r,k,geomID);
596
}
597
598
virtual LinearSpace3fa computeAlignedSpace(const size_t primID) const {
599
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry");
600
}
601
602
virtual LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f time_range) const {
603
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry");
604
}
605
606
virtual Vec3fa computeDirection(unsigned int primID) const {
607
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeDirection not implemented for this geometry");
608
}
609
610
virtual Vec3fa computeDirection(unsigned int primID, size_t time) const {
611
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeDirection not implemented for this geometry");
612
}
613
614
virtual BBox3fa vbounds(size_t primID) const {
615
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry");
616
}
617
618
virtual BBox3fa vbounds(const LinearSpace3fa& space, size_t primID) const {
619
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry");
620
}
621
622
virtual BBox3fa vbounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t i, size_t itime = 0) const {
623
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry");
624
}
625
626
virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const {
627
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry");
628
}
629
630
virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range, const SubGridBuildData * const sgrids) const {
631
return vlinearBounds(primID,time_range);
632
}
633
634
virtual LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const {
635
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry");
636
}
637
638
virtual LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const {
639
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry");
640
}
641
642
public:
643
__forceinline bool hasIntersectionFilter() const { return intersectionFilterN != nullptr; }
644
__forceinline bool hasOcclusionFilter() const { return occlusionFilterN != nullptr; }
645
646
public:
647
Device* device; //!< device this geometry belongs to
648
649
void* userPtr; //!< user pointer
650
unsigned int numPrimitives; //!< number of primitives of this geometry
651
652
unsigned int numTimeSteps; //!< number of time steps
653
float fnumTimeSegments; //!< number of time segments (precalculation)
654
BBox1f time_range; //!< motion blur time range
655
656
unsigned int mask; //!< for masking out geometry
657
unsigned int modCounter_ = 1; //!< counter for every modification - used to rebuild scenes when geo is modified
658
659
struct {
660
GType gtype : 8; //!< geometry type
661
GSubType gsubtype : 8; //!< geometry subtype
662
RTCBuildQuality quality : 3; //!< build quality for geometry
663
unsigned state : 2;
664
bool enabled : 1; //!< true if geometry is enabled
665
bool argumentFilterEnabled : 1; //!< true if argument filter functions are enabled for this geometry
666
};
667
668
RTCFilterFunctionN intersectionFilterN;
669
RTCFilterFunctionN occlusionFilterN;
670
RTCPointQueryFunction pointQueryFunc;
671
};
672
}
673
674