geometry.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "default.h"
  5. #include "device.h"
  6. #include "buffer.h"
  7. #include "../common/point_query.h"
  8. #include "../builders/priminfo.h"
  9. namespace embree
  10. {
  11. class Scene;
  12. class Geometry;
  13. struct GeometryCounts
  14. {
  15. __forceinline GeometryCounts()
  16. : numFilterFunctions(0),
  17. numTriangles(0), numMBTriangles(0),
  18. numQuads(0), numMBQuads(0),
  19. numBezierCurves(0), numMBBezierCurves(0),
  20. numLineSegments(0), numMBLineSegments(0),
  21. numSubdivPatches(0), numMBSubdivPatches(0),
  22. numUserGeometries(0), numMBUserGeometries(0),
  23. numInstancesCheap(0), numMBInstancesCheap(0),
  24. numInstancesExpensive(0), numMBInstancesExpensive(0),
  25. numGrids(0), numMBGrids(0),
  26. numPoints(0), numMBPoints(0) {}
  27. __forceinline size_t size() const {
  28. return numTriangles + numQuads + numBezierCurves + numLineSegments + numSubdivPatches + numUserGeometries + numInstancesCheap + numInstancesExpensive + numGrids + numPoints
  29. + numMBTriangles + numMBQuads + numMBBezierCurves + numMBLineSegments + numMBSubdivPatches + numMBUserGeometries + numMBInstancesCheap + numMBInstancesExpensive + numMBGrids + numMBPoints;
  30. }
  31. __forceinline unsigned int enabledGeometryTypesMask() const
  32. {
  33. unsigned int mask = 0;
  34. if (numTriangles) mask |= 1 << 0;
  35. if (numQuads) mask |= 1 << 1;
  36. if (numBezierCurves+numLineSegments) mask |= 1 << 2;
  37. if (numSubdivPatches) mask |= 1 << 3;
  38. if (numUserGeometries) mask |= 1 << 4;
  39. if (numInstancesCheap) mask |= 1 << 5;
  40. if (numInstancesExpensive) mask |= 1 << 6;
  41. if (numGrids) mask |= 1 << 7;
  42. if (numPoints) mask |= 1 << 8;
  43. unsigned int maskMB = 0;
  44. if (numMBTriangles) maskMB |= 1 << 0;
  45. if (numMBQuads) maskMB |= 1 << 1;
  46. if (numMBBezierCurves+numMBLineSegments) maskMB |= 1 << 2;
  47. if (numMBSubdivPatches) maskMB |= 1 << 3;
  48. if (numMBUserGeometries) maskMB |= 1 << 4;
  49. if (numMBInstancesCheap) maskMB |= 1 << 5;
  50. if (numMBInstancesExpensive) maskMB |= 1 << 6;
  51. if (numMBGrids) maskMB |= 1 << 7;
  52. if (numMBPoints) maskMB |= 1 << 8;
  53. return (mask<<8) + maskMB;
  54. }
  55. __forceinline GeometryCounts operator+ (GeometryCounts const & rhs) const
  56. {
  57. GeometryCounts ret;
  58. ret.numFilterFunctions = numFilterFunctions + rhs.numFilterFunctions;
  59. ret.numTriangles = numTriangles + rhs.numTriangles;
  60. ret.numMBTriangles = numMBTriangles + rhs.numMBTriangles;
  61. ret.numQuads = numQuads + rhs.numQuads;
  62. ret.numMBQuads = numMBQuads + rhs.numMBQuads;
  63. ret.numBezierCurves = numBezierCurves + rhs.numBezierCurves;
  64. ret.numMBBezierCurves = numMBBezierCurves + rhs.numMBBezierCurves;
  65. ret.numLineSegments = numLineSegments + rhs.numLineSegments;
  66. ret.numMBLineSegments = numMBLineSegments + rhs.numMBLineSegments;
  67. ret.numSubdivPatches = numSubdivPatches + rhs.numSubdivPatches;
  68. ret.numMBSubdivPatches = numMBSubdivPatches + rhs.numMBSubdivPatches;
  69. ret.numUserGeometries = numUserGeometries + rhs.numUserGeometries;
  70. ret.numMBUserGeometries = numMBUserGeometries + rhs.numMBUserGeometries;
  71. ret.numInstancesCheap = numInstancesCheap + rhs.numInstancesCheap;
  72. ret.numMBInstancesCheap = numMBInstancesCheap + rhs.numMBInstancesCheap;
  73. ret.numInstancesExpensive = numInstancesExpensive + rhs.numInstancesExpensive;
  74. ret.numMBInstancesExpensive = numMBInstancesExpensive + rhs.numMBInstancesExpensive;
  75. ret.numGrids = numGrids + rhs.numGrids;
  76. ret.numMBGrids = numMBGrids + rhs.numMBGrids;
  77. ret.numPoints = numPoints + rhs.numPoints;
  78. ret.numMBPoints = numMBPoints + rhs.numMBPoints;
  79. return ret;
  80. }
  81. size_t numFilterFunctions; //!< number of geometries with filter functions enabled
  82. size_t numTriangles; //!< number of enabled triangles
  83. size_t numMBTriangles; //!< number of enabled motion blurred triangles
  84. size_t numQuads; //!< number of enabled quads
  85. size_t numMBQuads; //!< number of enabled motion blurred quads
  86. size_t numBezierCurves; //!< number of enabled curves
  87. size_t numMBBezierCurves; //!< number of enabled motion blurred curves
  88. size_t numLineSegments; //!< number of enabled line segments
  89. size_t numMBLineSegments; //!< number of enabled line motion blurred segments
  90. size_t numSubdivPatches; //!< number of enabled subdivision patches
  91. size_t numMBSubdivPatches; //!< number of enabled motion blurred subdivision patches
  92. size_t numUserGeometries; //!< number of enabled user geometries
  93. size_t numMBUserGeometries; //!< number of enabled motion blurred user geometries
  94. size_t numInstancesCheap; //!< number of enabled cheap instances
  95. size_t numMBInstancesCheap; //!< number of enabled motion blurred cheap instances
  96. size_t numInstancesExpensive; //!< number of enabled expensive instances
  97. size_t numMBInstancesExpensive; //!< number of enabled motion blurred expensive instances
  98. size_t numGrids; //!< number of enabled grid geometries
  99. size_t numMBGrids; //!< number of enabled motion blurred grid geometries
  100. size_t numPoints; //!< number of enabled points
  101. size_t numMBPoints; //!< number of enabled motion blurred points
  102. };
  103. /*! Base class all geometries are derived from */
  104. class Geometry : public RefCount
  105. {
  106. friend class Scene;
  107. public:
  108. /*! type of geometry */
  109. enum GType
  110. {
  111. GTY_FLAT_LINEAR_CURVE = 0,
  112. GTY_ROUND_LINEAR_CURVE = 1,
  113. GTY_ORIENTED_LINEAR_CURVE = 2,
  114. GTY_CONE_LINEAR_CURVE = 3,
  115. GTY_FLAT_BEZIER_CURVE = 4,
  116. GTY_ROUND_BEZIER_CURVE = 5,
  117. GTY_ORIENTED_BEZIER_CURVE = 6,
  118. GTY_FLAT_BSPLINE_CURVE = 8,
  119. GTY_ROUND_BSPLINE_CURVE = 9,
  120. GTY_ORIENTED_BSPLINE_CURVE = 10,
  121. GTY_FLAT_HERMITE_CURVE = 12,
  122. GTY_ROUND_HERMITE_CURVE = 13,
  123. GTY_ORIENTED_HERMITE_CURVE = 14,
  124. GTY_FLAT_CATMULL_ROM_CURVE = 16,
  125. GTY_ROUND_CATMULL_ROM_CURVE = 17,
  126. GTY_ORIENTED_CATMULL_ROM_CURVE = 18,
  127. GTY_TRIANGLE_MESH = 20,
  128. GTY_QUAD_MESH = 21,
  129. GTY_GRID_MESH = 22,
  130. GTY_SUBDIV_MESH = 23,
  131. GTY_SPHERE_POINT = 25,
  132. GTY_DISC_POINT = 26,
  133. GTY_ORIENTED_DISC_POINT = 27,
  134. GTY_USER_GEOMETRY = 29,
  135. GTY_INSTANCE_CHEAP = 30,
  136. GTY_INSTANCE_EXPENSIVE = 31,
  137. GTY_END = 32,
  138. GTY_BASIS_LINEAR = 0,
  139. GTY_BASIS_BEZIER = 4,
  140. GTY_BASIS_BSPLINE = 8,
  141. GTY_BASIS_HERMITE = 12,
  142. GTY_BASIS_CATMULL_ROM = 16,
  143. GTY_BASIS_MASK = 28,
  144. GTY_SUBTYPE_FLAT_CURVE = 0,
  145. GTY_SUBTYPE_ROUND_CURVE = 1,
  146. GTY_SUBTYPE_ORIENTED_CURVE = 2,
  147. GTY_SUBTYPE_MASK = 3,
  148. };
  149. enum GSubType
  150. {
  151. GTY_SUBTYPE_DEFAULT= 0,
  152. GTY_SUBTYPE_INSTANCE_LINEAR = 0,
  153. GTY_SUBTYPE_INSTANCE_QUATERNION = 1
  154. };
  155. enum GTypeMask
  156. {
  157. MTY_FLAT_LINEAR_CURVE = 1ul << GTY_FLAT_LINEAR_CURVE,
  158. MTY_ROUND_LINEAR_CURVE = 1ul << GTY_ROUND_LINEAR_CURVE,
  159. MTY_CONE_LINEAR_CURVE = 1ul << GTY_CONE_LINEAR_CURVE,
  160. MTY_ORIENTED_LINEAR_CURVE = 1ul << GTY_ORIENTED_LINEAR_CURVE,
  161. MTY_FLAT_BEZIER_CURVE = 1ul << GTY_FLAT_BEZIER_CURVE,
  162. MTY_ROUND_BEZIER_CURVE = 1ul << GTY_ROUND_BEZIER_CURVE,
  163. MTY_ORIENTED_BEZIER_CURVE = 1ul << GTY_ORIENTED_BEZIER_CURVE,
  164. MTY_FLAT_BSPLINE_CURVE = 1ul << GTY_FLAT_BSPLINE_CURVE,
  165. MTY_ROUND_BSPLINE_CURVE = 1ul << GTY_ROUND_BSPLINE_CURVE,
  166. MTY_ORIENTED_BSPLINE_CURVE = 1ul << GTY_ORIENTED_BSPLINE_CURVE,
  167. MTY_FLAT_HERMITE_CURVE = 1ul << GTY_FLAT_HERMITE_CURVE,
  168. MTY_ROUND_HERMITE_CURVE = 1ul << GTY_ROUND_HERMITE_CURVE,
  169. MTY_ORIENTED_HERMITE_CURVE = 1ul << GTY_ORIENTED_HERMITE_CURVE,
  170. MTY_FLAT_CATMULL_ROM_CURVE = 1ul << GTY_FLAT_CATMULL_ROM_CURVE,
  171. MTY_ROUND_CATMULL_ROM_CURVE = 1ul << GTY_ROUND_CATMULL_ROM_CURVE,
  172. MTY_ORIENTED_CATMULL_ROM_CURVE = 1ul << GTY_ORIENTED_CATMULL_ROM_CURVE,
  173. MTY_CURVE2 = MTY_FLAT_LINEAR_CURVE | MTY_ROUND_LINEAR_CURVE | MTY_CONE_LINEAR_CURVE | MTY_ORIENTED_LINEAR_CURVE,
  174. MTY_CURVE4 = MTY_FLAT_BEZIER_CURVE | MTY_ROUND_BEZIER_CURVE | MTY_ORIENTED_BEZIER_CURVE |
  175. MTY_FLAT_BSPLINE_CURVE | MTY_ROUND_BSPLINE_CURVE | MTY_ORIENTED_BSPLINE_CURVE |
  176. MTY_FLAT_HERMITE_CURVE | MTY_ROUND_HERMITE_CURVE | MTY_ORIENTED_HERMITE_CURVE |
  177. MTY_FLAT_CATMULL_ROM_CURVE | MTY_ROUND_CATMULL_ROM_CURVE | MTY_ORIENTED_CATMULL_ROM_CURVE,
  178. MTY_SPHERE_POINT = 1ul << GTY_SPHERE_POINT,
  179. MTY_DISC_POINT = 1ul << GTY_DISC_POINT,
  180. MTY_ORIENTED_DISC_POINT = 1ul << GTY_ORIENTED_DISC_POINT,
  181. MTY_POINTS = MTY_SPHERE_POINT | MTY_DISC_POINT | MTY_ORIENTED_DISC_POINT,
  182. MTY_CURVES = MTY_CURVE2 | MTY_CURVE4 | MTY_POINTS,
  183. MTY_TRIANGLE_MESH = 1ul << GTY_TRIANGLE_MESH,
  184. MTY_QUAD_MESH = 1ul << GTY_QUAD_MESH,
  185. MTY_GRID_MESH = 1ul << GTY_GRID_MESH,
  186. MTY_SUBDIV_MESH = 1ul << GTY_SUBDIV_MESH,
  187. MTY_USER_GEOMETRY = 1ul << GTY_USER_GEOMETRY,
  188. MTY_INSTANCE_CHEAP = 1ul << GTY_INSTANCE_CHEAP,
  189. MTY_INSTANCE_EXPENSIVE = 1ul << GTY_INSTANCE_EXPENSIVE,
  190. MTY_INSTANCE = MTY_INSTANCE_CHEAP | MTY_INSTANCE_EXPENSIVE
  191. };
  192. static const char* gtype_names[GTY_END];
  193. enum class State : unsigned {
  194. MODIFIED = 0,
  195. COMMITTED = 1,
  196. };
  197. public:
  198. /*! Geometry constructor */
  199. Geometry (Device* device, GType gtype, unsigned int numPrimitives, unsigned int numTimeSteps);
  200. /*! Geometry destructor */
  201. virtual ~Geometry();
  202. public:
  203. /*! tests if geometry is enabled */
  204. __forceinline bool isEnabled() const { return enabled; }
  205. /*! tests if geometry is disabled */
  206. __forceinline bool isDisabled() const { return !isEnabled(); }
  207. /*! tests if that geometry has some filter function set */
  208. __forceinline bool hasFilterFunctions () const {
  209. return (intersectionFilterN != nullptr) || (occlusionFilterN != nullptr);
  210. }
  211. /*! returns geometry type */
  212. __forceinline GType getType() const { return gtype; }
  213. /*! returns curve type */
  214. __forceinline GType getCurveType() const { return (GType)(gtype & GTY_SUBTYPE_MASK); }
  215. /*! returns curve basis */
  216. __forceinline GType getCurveBasis() const { return (GType)(gtype & GTY_BASIS_MASK); }
  217. /*! returns geometry type mask */
  218. __forceinline GTypeMask getTypeMask() const { return (GTypeMask)(1 << gtype); }
  219. /*! returns number of primitives */
  220. __forceinline size_t size() const { return numPrimitives; }
  221. /*! sets the number of primitives */
  222. virtual void setNumPrimitives(unsigned int numPrimitives_in);
  223. /*! sets number of time steps */
  224. virtual void setNumTimeSteps (unsigned int numTimeSteps_in);
  225. /*! sets motion blur time range */
  226. void setTimeRange (const BBox1f range);
  227. /*! sets number of vertex attributes */
  228. virtual void setVertexAttributeCount (unsigned int N) {
  229. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  230. }
  231. /*! sets number of topologies */
  232. virtual void setTopologyCount (unsigned int N) {
  233. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  234. }
  235. /*! sets the build quality */
  236. void setBuildQuality(RTCBuildQuality quality_in)
  237. {
  238. this->quality = quality_in;
  239. Geometry::update();
  240. }
  241. /* calculate time segment itime and fractional time ftime */
  242. __forceinline int timeSegment(float time, float& ftime) const {
  243. return getTimeSegment(time,time_range.lower,time_range.upper,fnumTimeSegments,ftime);
  244. }
  245. template<int N>
  246. __forceinline vint<N> timeSegment(const vfloat<N>& time, vfloat<N>& ftime) const {
  247. return getTimeSegment<N>(time,vfloat<N>(time_range.lower),vfloat<N>(time_range.upper),vfloat<N>(fnumTimeSegments),ftime);
  248. }
  249. /* calculate overlapping time segment range */
  250. __forceinline range<int> timeSegmentRange(const BBox1f& range) const {
  251. return getTimeSegmentRange(range,time_range,fnumTimeSegments);
  252. }
  253. /* returns time that corresponds to time step */
  254. __forceinline float timeStep(const int i) const {
  255. assert(i>=0 && i<(int)numTimeSteps);
  256. return time_range.lower + time_range.size()*float(i)/fnumTimeSegments;
  257. }
  258. /*! for all geometries */
  259. public:
  260. /*! Enable geometry. */
  261. virtual void enable();
  262. /*! Update geometry. */
  263. void update();
  264. /*! commit of geometry */
  265. virtual void commit();
  266. /*! Update geometry buffer. */
  267. virtual void updateBuffer(RTCBufferType type, unsigned int slot) {
  268. update(); // update everything for geometries not supporting this call
  269. }
  270. /*! Disable geometry. */
  271. virtual void disable();
  272. /*! Verify the geometry */
  273. virtual bool verify() { return true; }
  274. /*! called before every build */
  275. virtual void preCommit();
  276. /*! called after every build */
  277. virtual void postCommit();
  278. virtual void addElementsToCount (GeometryCounts & counts) const {
  279. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  280. };
  281. /*! sets constant tessellation rate for the geometry */
  282. virtual void setTessellationRate(float N) {
  283. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  284. }
  285. /*! Sets the maximal curve radius scale allowed by min-width feature. */
  286. virtual void setMaxRadiusScale(float s) {
  287. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  288. }
  289. /*! Set user data pointer. */
  290. virtual void setUserData(void* ptr);
  291. /*! Get user data pointer. */
  292. __forceinline void* getUserData() const {
  293. return userPtr;
  294. }
  295. /*! interpolates user data to the specified u/v location */
  296. virtual void interpolate(const RTCInterpolateArguments* const args) {
  297. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  298. }
  299. /*! interpolates user data to the specified u/v locations */
  300. virtual void interpolateN(const RTCInterpolateNArguments* const args);
  301. /* point query api */
  302. bool pointQuery(PointQuery* query, PointQueryContext* context);
  303. /*! for subdivision surfaces only */
  304. public:
  305. virtual void setSubdivisionMode (unsigned topologyID, RTCSubdivisionMode mode) {
  306. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  307. }
  308. virtual void setVertexAttributeTopology(unsigned int vertexBufferSlot, unsigned int indexBufferSlot) {
  309. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  310. }
  311. /*! Set displacement function. */
  312. virtual void setDisplacementFunction (RTCDisplacementFunctionN filter) {
  313. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  314. }
  315. virtual unsigned int getFirstHalfEdge(unsigned int faceID) {
  316. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  317. }
  318. virtual unsigned int getFace(unsigned int edgeID) {
  319. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  320. }
  321. virtual unsigned int getNextHalfEdge(unsigned int edgeID) {
  322. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  323. }
  324. virtual unsigned int getPreviousHalfEdge(unsigned int edgeID) {
  325. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  326. }
  327. virtual unsigned int getOppositeHalfEdge(unsigned int topologyID, unsigned int edgeID) {
  328. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  329. }
  330. /*! get fast access to first vertex buffer if applicable */
  331. virtual float * getCompactVertexArray () const {
  332. return nullptr;
  333. }
  334. /*! Returns the modified counter - how many times the geo has been modified */
  335. __forceinline unsigned int getModCounter () const {
  336. return modCounter_;
  337. }
  338. /*! for triangle meshes and bezier curves only */
  339. public:
  340. /*! Sets ray mask. */
  341. virtual void setMask(unsigned mask) {
  342. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  343. }
  344. /*! Sets specified buffer. */
  345. virtual void setBuffer(RTCBufferType type, unsigned int slot, RTCFormat format, const Ref<Buffer>& buffer, size_t offset, size_t stride, unsigned int num) {
  346. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  347. }
  348. /*! Gets specified buffer. */
  349. virtual void* getBuffer(RTCBufferType type, unsigned int slot) {
  350. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  351. }
  352. /*! Set intersection filter function for ray packets of size N. */
  353. virtual void setIntersectionFilterFunctionN (RTCFilterFunctionN filterN);
  354. /*! Set occlusion filter function for ray packets of size N. */
  355. virtual void setOcclusionFilterFunctionN (RTCFilterFunctionN filterN);
  356. /*! for instances only */
  357. public:
  358. /*! Sets the instanced scene */
  359. virtual void setInstancedScene(const Ref<Scene>& scene) {
  360. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  361. }
  362. /*! Sets transformation of the instance */
  363. virtual void setTransform(const AffineSpace3fa& transform, unsigned int timeStep) {
  364. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  365. }
  366. /*! Sets transformation of the instance */
  367. virtual void setQuaternionDecomposition(const AffineSpace3ff& qd, unsigned int timeStep) {
  368. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  369. }
  370. /*! Returns the transformation of the instance */
  371. virtual AffineSpace3fa getTransform(float time) {
  372. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  373. }
  374. /*! for user geometries only */
  375. public:
  376. /*! Set bounds function. */
  377. virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) {
  378. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  379. }
  380. /*! Set intersect function for ray packets of size N. */
  381. virtual void setIntersectFunctionN (RTCIntersectFunctionN intersect) {
  382. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  383. }
  384. /*! Set occlusion function for ray packets of size N. */
  385. virtual void setOccludedFunctionN (RTCOccludedFunctionN occluded) {
  386. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"operation not supported for this geometry");
  387. }
  388. /*! Set point query function. */
  389. void setPointQueryFunction(RTCPointQueryFunction func);
  390. /*! returns number of time segments */
  391. __forceinline unsigned numTimeSegments () const {
  392. return numTimeSteps-1;
  393. }
  394. public:
  395. virtual PrimInfo createPrimRefArray(mvector<PrimRef>& prims, const range<size_t>& r, size_t k, unsigned int geomID) const {
  396. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefArray not implemented for this geometry");
  397. }
  398. virtual PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, size_t itime, const range<size_t>& r, size_t k, unsigned int geomID) const {
  399. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry");
  400. }
  401. virtual PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const {
  402. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"createPrimRefMBArray not implemented for this geometry");
  403. }
  404. virtual LinearSpace3fa computeAlignedSpace(const size_t primID) const {
  405. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry");
  406. }
  407. virtual LinearSpace3fa computeAlignedSpaceMB(const size_t primID, const BBox1f time_range) const {
  408. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeAlignedSpace not implemented for this geometry");
  409. }
  410. virtual Vec3fa computeDirection(unsigned int primID) const {
  411. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeDirection not implemented for this geometry");
  412. }
  413. virtual Vec3fa computeDirection(unsigned int primID, size_t time) const {
  414. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"computeDirection not implemented for this geometry");
  415. }
  416. virtual BBox3fa vbounds(size_t primID) const {
  417. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry");
  418. }
  419. virtual BBox3fa vbounds(const LinearSpace3fa& space, size_t primID) const {
  420. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry");
  421. }
  422. virtual BBox3fa vbounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t i, size_t itime = 0) const {
  423. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vbounds not implemented for this geometry");
  424. }
  425. virtual LBBox3fa vlinearBounds(size_t primID, const BBox1f& time_range) const {
  426. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry");
  427. }
  428. virtual LBBox3fa vlinearBounds(const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const {
  429. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry");
  430. }
  431. virtual LBBox3fa vlinearBounds(const Vec3fa& ofs, const float scale, const float r_scale0, const LinearSpace3fa& space, size_t primID, const BBox1f& time_range) const {
  432. throw_RTCError(RTC_ERROR_INVALID_OPERATION,"vlinearBounds not implemented for this geometry");
  433. }
  434. public:
  435. __forceinline bool hasIntersectionFilter() const { return intersectionFilterN != nullptr; }
  436. __forceinline bool hasOcclusionFilter() const { return occlusionFilterN != nullptr; }
  437. public:
  438. Device* device; //!< device this geometry belongs to
  439. void* userPtr; //!< user pointer
  440. unsigned int numPrimitives; //!< number of primitives of this geometry
  441. unsigned int numTimeSteps; //!< number of time steps
  442. float fnumTimeSegments; //!< number of time segments (precalculation)
  443. BBox1f time_range; //!< motion blur time range
  444. unsigned int mask; //!< for masking out geometry
  445. unsigned int modCounter_ = 1; //!< counter for every modification - used to rebuild scenes when geo is modified
  446. struct {
  447. GType gtype : 8; //!< geometry type
  448. GSubType gsubtype : 8; //!< geometry subtype
  449. RTCBuildQuality quality : 3; //!< build quality for geometry
  450. unsigned state : 2;
  451. bool enabled : 1; //!< true if geometry is enabled
  452. };
  453. RTCFilterFunctionN intersectionFilterN;
  454. RTCFilterFunctionN occlusionFilterN;
  455. RTCPointQueryFunction pointQueryFunc;
  456. };
  457. }