summaryrefslogtreecommitdiff
path: root/thirdparty/embree-aarch64/kernels/common/geometry.h
blob: 953974bfd29c7d9b97b1f5d1b059ea51c949e614 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
// Copyright 2009-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "default.h"
#include "device.h"
#include "buffer.h"
#include "../common/point_query.h"
#include "../builders/priminfo.h"

namespace embree
{
  class Scene;
  class Geometry;

  struct GeometryCounts 
  {
    __forceinline GeometryCounts()
      : numFilterFunctions(0),
        numTriangles(0), numMBTriangles(0), 
        numQuads(0), numMBQuads(0), 
        numBezierCurves(0), numMBBezierCurves(0), 
        numLineSegments(0), numMBLineSegments(0), 
        numSubdivPatches(0), numMBSubdivPatches(0), 
        numUserGeometries(0), numMBUserGeometries(0), 
        numInstancesCheap(0), numMBInstancesCheap(0), 
        numInstancesExpensive(0), numMBInstancesExpensive(0), 
        numGrids(0), numMBGrids(0), 
        numPoints(0), numMBPoints(0) {}

    __forceinline size_t size() const {
      return    numTriangles + numQuads + numBezierCurves + numLineSegments + numSubdivPatches + numUserGeometries + numInstancesCheap + numInstancesExpensive + numGrids + numPoints
              + numMBTriangles + numMBQuads + numMBBezierCurves + numMBLineSegments + numMBSubdivPatches + numMBUserGeometries + numMBInstancesCheap + numMBInstancesExpensive + numMBGrids + numMBPoints;
    }

    __forceinline unsigned int enabledGeometryTypesMask() const
    {
      unsigned int mask = 0;
      if (numTriangles) mask |= 1 << 0;
      if (numQuads) mask |= 1 << 1;
      if (numBezierCurves+numLineSegments) mask |= 1 << 2;
      if (numSubdivPatches) mask |= 1 << 3;
      if (numUserGeometries) mask |= 1 << 4;
      if (numInstancesCheap) mask |= 1 << 5;
      if (numInstancesExpensive) mask |= 1 << 6;
      if (numGrids) mask |= 1 << 7;
      if (numPoints) mask |= 1 << 8;

      unsigned int maskMB = 0;
      if (numMBTriangles) maskMB |= 1 << 0;
      if (numMBQuads) maskMB |= 1 << 1;
      if (numMBBezierCurves+numMBLineSegments) maskMB |= 1 << 2;
      if (numMBSubdivPatches) maskMB |= 1 << 3;
      if (numMBUserGeometries) maskMB |= 1 << 4;
      if (numMBInstancesCheap) maskMB |= 1 << 5;
      if (numMBInstancesExpensive) maskMB |= 1 << 6;
      if (numMBGrids) maskMB |= 1 << 7;
      if (numMBPoints) maskMB |= 1 << 8;
      
      return (mask<<8) + maskMB;
    }

    __forceinline GeometryCounts operator+ (GeometryCounts const & rhs) const
    {
      GeometryCounts ret;
      ret.numFilterFunctions = numFilterFunctions + rhs.numFilterFunctions;
      ret.numTriangles = numTriangles + rhs.numTriangles;
      ret.numMBTriangles = numMBTriangles + rhs.numMBTriangles;
      ret.numQuads = numQuads + rhs.numQuads;
      ret.numMBQuads = numMBQuads + rhs.numMBQuads;
      ret.numBezierCurves = numBezierCurves + rhs.numBezierCurves;
      ret.numMBBezierCurves = numMBBezierCurves + rhs.numMBBezierCurves;
      ret.numLineSegments = numLineSegments + rhs.numLineSegments;
      ret.numMBLineSegments = numMBLineSegments + rhs.numMBLineSegments;
      ret.numSubdivPatches = numSubdivPatches + rhs.numSubdivPatches;
      ret.numMBSubdivPatches = numMBSubdivPatches + rhs.numMBSubdivPatches;
      ret.numUserGeometries = numUserGeometries + rhs.numUserGeometries;
      ret.numMBUserGeometries = numMBUserGeometries + rhs.numMBUserGeometries;
      ret.numInstancesCheap = numInstancesCheap + rhs.numInstancesCheap;
      ret.numMBInstancesCheap = numMBInstancesCheap + rhs.numMBInstancesCheap;
      ret.numInstancesExpensive = numInstancesExpensive + rhs.numInstancesExpensive;
      ret.numMBInstancesExpensive = numMBInstancesExpensive + rhs.numMBInstancesExpensive;
      ret.numGrids = numGrids + rhs.numGrids;
      ret.numMBGrids = numMBGrids + rhs.numMBGrids;
      ret.numPoints = numPoints + rhs.numPoints;
      ret.numMBPoints = numMBPoints + rhs.numMBPoints;

      return ret;
    }

    size_t numFilterFunctions;       //!< number of geometries with filter functions enabled
    size_t numTriangles;             //!< number of enabled triangles
    size_t numMBTriangles;           //!< number of enabled motion blured triangles
    size_t numQuads;                 //!< number of enabled quads
    size_t numMBQuads;               //!< number of enabled motion blurred quads
    size_t numBezierCurves;          //!< number of enabled curves
    size_t numMBBezierCurves;        //!< number of enabled motion blurred curves
    size_t numLineSegments;          //!< number of enabled line segments
    size_t numMBLineSegments;        //!< number of enabled line motion blurred segments
    size_t numSubdivPatches;         //!< number of enabled subdivision patches
    size_t numMBSubdivPatches;       //!< number of enabled motion blured subdivision patches
    size_t numUserGeometries;        //!< number of enabled user geometries
    size_t numMBUserGeometries;      //!< number of enabled motion blurred user geometries
    size_t numInstancesCheap;        //!< number of enabled cheap instances
    size_t numMBInstancesCheap;      //!< number of enabled motion blurred cheap instances
    size_t numInstancesExpensive;    //!< number of enabled expensive instances
    size_t numMBInstancesExpensive;  //!< number of enabled motion blurred expensive instances
    size_t numGrids;                 //!< number of enabled grid geometries
    size_t numMBGrids;               //!< number of enabled motion blurred grid geometries
    size_t numPoints;                //!< number of enabled points
    size_t numMBPoints;              //!< number of enabled motion blurred points
  };

  /*! Base class all geometries are derived from */
  class Geometry : public RefCount
  {
    friend class Scene;
  public:

    /*! type of geometry */
    enum GType
    {
      GTY_FLAT_LINEAR_CURVE = 0,
      GTY_ROUND_LINEAR_CURVE = 1,
      GTY_ORIENTED_LINEAR_CURVE = 2,
      GTY_CONE_LINEAR_CURVE = 3,
      
      GTY_FLAT_BEZIER_CURVE = 4,
      GTY_ROUND_BEZIER_CURVE = 5,
      GTY_ORIENTED_BEZIER_CURVE = 6,
      
      GTY_FLAT_BSPLINE_CURVE = 8,
      GTY_ROUND_BSPLINE_CURVE = 9,
      GTY_ORIENTED_BSPLINE_CURVE = 10,

      GTY_FLAT_HERMITE_CURVE = 12,
      GTY_ROUND_HERMITE_CURVE = 13,
      GTY_ORIENTED_HERMITE_CURVE = 14,
      
      GTY_FLAT_CATMULL_ROM_CURVE = 16,
      GTY_ROUND_CATMULL_ROM_CURVE = 17,
      GTY_ORIENTED_CATMULL_ROM_CURVE = 18,      

      GTY_TRIANGLE_MESH = 20,
      GTY_QUAD_MESH = 21,
      GTY_GRID_MESH = 22,
      GTY_SUBDIV_MESH = 23,

      GTY_SPHERE_POINT = 25,
      GTY_DISC_POINT = 26,
      GTY_ORIENTED_DISC_POINT = 27,
      
      GTY_USER_GEOMETRY = 29,
      GTY_INSTANCE_CHEAP = 30,
      GTY_INSTANCE_EXPENSIVE = 31,
      GTY_END = 32,

      GTY_BASIS_LINEAR = 0,
      GTY_BASIS_BEZIER = 4,
      GTY_BASIS_BSPLINE = 8,
      GTY_BASIS_HERMITE = 12,
      GTY_BASIS_CATMULL_ROM = 16,
      GTY_BASIS_MASK = 28,

      GTY_SUBTYPE_FLAT_CURVE = 0,
      GTY_SUBTYPE_ROUND_CURVE = 1,
      GTY_SUBTYPE_ORIENTED_CURVE = 2,
      GTY_SUBTYPE_MASK = 3,
    };

    enum GSubType
    {
      GTY_SUBTYPE_DEFAULT= 0,
      GTY_SUBTYPE_INSTANCE_LINEAR = 0,
      GTY_SUBTYPE_INSTANCE_QUATERNION = 1
    };

    enum GTypeMask
    {
      MTY_FLAT_LINEAR_CURVE = 1ul << GTY_FLAT_LINEAR_CURVE,
      MTY_ROUND_LINEAR_CURVE = 1ul << GTY_ROUND_LINEAR_CURVE,
      MTY_CONE_LINEAR_CURVE = 1ul << GTY_CONE_LINEAR_CURVE,
      MTY_ORIENTED_LINEAR_CURVE = 1ul << GTY_ORIENTED_LINEAR_CURVE,
      
      MTY_FLAT_BEZIER_CURVE = 1ul << GTY_FLAT_BEZIER_CURVE,
      MTY_ROUND_BEZIER_CURVE = 1ul << GTY_ROUND_BEZIER_CURVE,
      MTY_ORIENTED_BEZIER_CURVE = 1ul << GTY_ORIENTED_BEZIER_CURVE,
      
      MTY_FLAT_BSPLINE_CURVE = 1ul << GTY_FLAT_BSPLINE_CURVE,
      MTY_ROUND_BSPLINE_CURVE = 1ul << GTY_ROUND_BSPLINE_CURVE,
      MTY_ORIENTED_BSPLINE_CURVE = 1ul << GTY_ORIENTED_BSPLINE_CURVE,

      MTY_FLAT_HERMITE_CURVE = 1ul << GTY_FLAT_HERMITE_CURVE,
      MTY_ROUND_HERMITE_CURVE = 1ul << GTY_ROUND_HERMITE_CURVE,
      MTY_ORIENTED_HERMITE_CURVE = 1ul << GTY_ORIENTED_HERMITE_CURVE,

      MTY_FLAT_CATMULL_ROM_CURVE = 1ul << GTY_FLAT_CATMULL_ROM_CURVE,
      MTY_ROUND_CATMULL_ROM_CURVE = 1ul << GTY_ROUND_CATMULL_ROM_CURVE,
      MTY_ORIENTED_CATMULL_ROM_CURVE = 1ul << GTY_ORIENTED_CATMULL_ROM_CURVE,

      MTY_CURVE2 = MTY_FLAT_LINEAR_CURVE | MTY_ROUND_LINEAR_CURVE | MTY_CONE_LINEAR_CURVE | MTY_ORIENTED_LINEAR_CURVE,
      
      MTY_CURVE4 = MTY_FLAT_BEZIER_CURVE | MTY_ROUND_BEZIER_CURVE | MTY_ORIENTED_BEZIER_CURVE |
                   MTY_FLAT_BSPLINE_CURVE | MTY_ROUND_BSPLINE_CURVE | MTY_ORIENTED_BSPLINE_CURVE |
                   MTY_FLAT_HERMITE_CURVE | MTY_ROUND_HERMITE_CURVE | MTY_ORIENTED_HERMITE_CURVE |
                   MTY_FLAT_CATMULL_ROM_CURVE | MTY_ROUND_CATMULL_ROM_CURVE | MTY_ORIENTED_CATMULL_ROM_CURVE,

      MTY_SPHERE_POINT = 1ul << GTY_SPHERE_POINT,
      MTY_DISC_POINT = 1ul << GTY_DISC_POINT,
      MTY_ORIENTED_DISC_POINT = 1ul << GTY_ORIENTED_DISC_POINT,

      MTY_POINTS = MTY_SPHERE_POINT | MTY_DISC_POINT | MTY_ORIENTED_DISC_POINT,

      MTY_CURVES = MTY_CURVE2 | MTY_CURVE4 | MTY_POINTS,

      MTY_TRIANGLE_MESH = 1ul << GTY_TRIANGLE_MESH,
      MTY_QUAD_MESH = 1ul << GTY_QUAD_MESH,
      MTY_GRID_MESH = 1ul << GTY_GRID_MESH,
      MTY_SUBDIV_MESH = 1ul << GTY_SUBDIV_MESH,
      MTY_USER_GEOMETRY = 1ul << GTY_USER_GEOMETRY,

      MTY_INSTANCE_CHEAP = 1ul << GTY_INSTANCE_CHEAP,
      MTY_INSTANCE_EXPENSIVE = 1ul << GTY_INSTANCE_EXPENSIVE,
      MTY_INSTANCE = MTY_INSTANCE_CHEAP | MTY_INSTANCE_EXPENSIVE
    };

    static const char* gtype_names[GTY_END];

    enum class State : unsigned {
      MODIFIED = 0,
      COMMITTED = 1,
    };

  public:
    
    /*! Geometry constructor */
    Geometry (Device* device, GType gtype, unsigned int numPrimitives, unsigned int numTimeSteps);

    /*! Geometry destructor */
    virtual ~Geometry();

  public:

    /*! tests if geometry is enabled */
    __forceinline bool isEnabled() const { return enabled; }

    /*! tests if geometry is disabled */
    __forceinline bool isDisabled() const { return !isEnabled(); }

    /*! tests if that geometry has some filter function set */
    __forceinline bool hasFilterFunctions () const {
      return (intersectionFilterN  != nullptr) || (occlusionFilterN  != nullptr);
    }

    /*! returns geometry type */
    __forceinline GType getType() const { return gtype; }

    /*! returns curve type */
    __forceinline GType getCurveType() const { return (GType)(gtype & GTY_SUBTYPE_MASK); }

    /*! returns curve basis */
    __forceinline GType getCurveBasis() const { return (GType)(gtype & GTY_BASIS_MASK); }

    /*! returns geometry type mask */
    __forceinline GTypeMask getTypeMask() const { return (GTypeMask)(1 << gtype); }

    /*! returns number of primitives */
    __forceinline size_t size() const { return numPrimitives; }

    /*! sets the number of primitives */
    virtual void setNumPrimitives(unsigned int numPrimitives_in);

    /*! sets number of time steps */
    virtual void setNumTimeSteps (unsigned int numTimeSteps_in);

    /*! sets motion blur time range */
    void setTimeRange (const BBox1f range);

    /*! sets number of vertex attributes */
    virtual void setVertexAttributeCount (unsigned int N) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! sets number of topologies */
    virtual void setTopologyCount (unsigned int N) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! sets the build quality */
    void setBuildQuality(RTCBuildQuality quality_in)
    {
      this->quality = quality_in;
      Geometry::update();
    }

    /* calculate time segment itime and fractional time ftime */
    __forceinline int timeSegment(float time, float& ftime) const {
      return getTimeSegment(time,time_range.lower,time_range.upper,fnumTimeSegments,ftime);
    }

    template<int N>
      __forceinline vint<N> timeSegment(const vfloat<N>& time, vfloat<N>& ftime) const {
      return getTimeSegment(time,vfloat<N>(time_range.lower),vfloat<N>(time_range.upper),vfloat<N>(fnumTimeSegments),ftime);
    }
    
    /* calculate overlapping time segment range */
    __forceinline range<int> timeSegmentRange(const BBox1f& range) const {
      return getTimeSegmentRange(range,time_range,fnumTimeSegments);
    }

    /* returns time that corresponds to time step */
    __forceinline float timeStep(const int i) const {
      assert(i>=0 && i<(int)numTimeSteps);
      return time_range.lower + time_range.size()*float(i)/fnumTimeSegments;
    }
    
    /*! for all geometries */
  public:

    /*! Enable geometry. */
    virtual void enable();

    /*! Update geometry. */
    void update();
    
    /*! commit of geometry */
    virtual void commit();

    /*! Update geometry buffer. */
    virtual void updateBuffer(RTCBufferType type, unsigned int slot) {
      update(); // update everything for geometries not supporting this call
    }
    
    /*! Disable geometry. */
    virtual void disable();

    /*! Verify the geometry */
    virtual bool verify() { return true; }

    /*! called before every build */
    virtual void preCommit();
  
    /*! called after every build */
    virtual void postCommit();

    virtual void addElementsToCount (GeometryCounts & counts) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    };

    /*! sets constant tessellation rate for the geometry */
    virtual void setTessellationRate(float N) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Sets the maximal curve radius scale allowed by min-width feature. */
    virtual void setMaxRadiusScale(float s) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Set user data pointer. */
    virtual void setUserData(void* ptr);
      
    /*! Get user data pointer. */
    __forceinline void* getUserData() const {
      return userPtr;
    }

    /*! interpolates user data to the specified u/v location */
    virtual void interpolate(const RTCInterpolateArguments* const args) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! interpolates user data to the specified u/v locations */
    virtual void interpolateN(const RTCInterpolateNArguments* const args);

    /* point query api */
    bool pointQuery(PointQuery* query, PointQueryContext* context);

    /*! for subdivision surfaces only */
  public:
    virtual void setSubdivisionMode (unsigned topologyID, RTCSubdivisionMode mode) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    virtual void setVertexAttributeTopology(unsigned int vertexBufferSlot, unsigned int indexBufferSlot) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Set displacement function. */
    virtual void setDisplacementFunction (RTCDisplacementFunctionN filter) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    virtual unsigned int getFirstHalfEdge(unsigned int faceID) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    virtual unsigned int getFace(unsigned int edgeID) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }
    
    virtual unsigned int getNextHalfEdge(unsigned int edgeID) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    virtual unsigned int getPreviousHalfEdge(unsigned int edgeID) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    virtual unsigned int getOppositeHalfEdge(unsigned int topologyID, unsigned int edgeID) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! get fast access to first vertex buffer if applicable */
    virtual float * getCompactVertexArray () const {
      return nullptr;
    }

    /*! Returns the modified counter - how many times the geo has been modified */
    __forceinline unsigned int getModCounter () const {
      return modCounter_;
    }

    /*! for triangle meshes and bezier curves only */
  public:


    /*! Sets ray mask. */
    virtual void setMask(unsigned mask) { 
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }
    
    /*! Sets specified buffer. */
    virtual void setBuffer(RTCBufferType type, unsigned int slot, RTCFormat format, const Ref<Buffer>& buffer, size_t offset, size_t stride, unsigned int num) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Gets specified buffer. */
    virtual void* getBuffer(RTCBufferType type, unsigned int slot) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
    }

    /*! Set intersection filter function for ray packets of size N. */
    virtual void setIntersectionFilterFunctionN (RTCFilterFunctionN filterN);

    /*! Set occlusion filter function for ray packets of size N. */
    virtual void setOcclusionFilterFunctionN (RTCFilterFunctionN filterN);

    /*! for instances only */
  public:

    /*! Sets the instanced scene */
    virtual void setInstancedScene(const Ref<Scene>& scene) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
    }

    /*! Sets transformation of the instance */
    virtual void setTransform(const AffineSpace3fa& transform, unsigned int timeStep) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Sets transformation of the instance */
    virtual void setQuaternionDecomposition(const AffineSpace3ff& qd, unsigned int timeStep) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Returns the transformation of the instance */
    virtual AffineSpace3fa getTransform(float time) {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! for user geometries only */
  public:

    /*! Set bounds function. */
    virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) { 
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }

    /*! Set intersect function for ray packets of size N. */
    virtual void setIntersectFunctionN (RTCIntersectFunctionN intersect) { 
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }
    
    /*! Set occlusion function for ray packets of size N. */
    virtual void setOccludedFunctionN (RTCOccludedFunctionN occluded) { 
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry"); 
    }
    
    /*! Set point query function. */
    void setPointQueryFunction(RTCPointQueryFunction func);

    /*! returns number of time segments */
    __forceinline unsigned numTimeSegments () const {
      return numTimeSteps-1;
    }

  public:

    virtual PrimInfo createPrimRefArray(mvector<PrimRef>& prims, const range<size_t>& r, size_t k, unsigned int geomID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefArray not implemented for this geometry"); 
    }

    virtual PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, size_t itime, const range<size_t>& r, size_t k, unsigned int geomID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry"); 
    }

    virtual PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry"); 
    }

    virtual LinearSpace3fa computeAlignedSpace(const size_t primID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry"); 
    }

    virtual LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f time_range) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry"); 
    }
    
    virtual Vec3fa computeDirection(unsigned int primID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeDirection not implemented for this geometry"); 
    }

    virtual Vec3fa computeDirection(unsigned int primID, size_t time) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeDirection not implemented for this geometry"); 
    }

    virtual BBox3fa vbounds(size_t primID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry"); 
    }
    
    virtual BBox3fa vbounds(const LinearSpace3fa& space, size_t primID) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry"); 
    }

    virtual BBox3fa vbounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t i, size_t itime = 0) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry"); 
    }

    virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry"); 
    }
    
    virtual LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry"); 
    }

    virtual LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const {
      throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry"); 
    }
    
  public:
    __forceinline bool hasIntersectionFilter() const { return intersectionFilterN != nullptr; }
    __forceinline bool hasOcclusionFilter() const { return occlusionFilterN != nullptr; }

  public:
    Device* device;             //!< device this geometry belongs to

    void* userPtr;              //!< user pointer
    unsigned int numPrimitives; //!< number of primitives of this geometry
    
    unsigned int numTimeSteps;  //!< number of time steps
    float fnumTimeSegments;     //!< number of time segments (precalculation)
    BBox1f time_range;          //!< motion blur time range
    
    unsigned int mask;             //!< for masking out geometry
    unsigned int modCounter_ = 1; //!< counter for every modification - used to rebuild scenes when geo is modified
    
    struct {
      GType gtype : 8;                //!< geometry type
      GSubType gsubtype : 8;          //!< geometry subtype
      RTCBuildQuality quality : 3;    //!< build quality for geometry
      unsigned state : 2;
      bool enabled : 1;              //!< true if geometry is enabled
    };
       
    RTCFilterFunctionN intersectionFilterN;
    RTCFilterFunctionN occlusionFilterN;
    RTCPointQueryFunction pointQueryFunc;
  };
}