scene_user_geometry.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "accelset.h"
  5. namespace embree
  6. {
  7. /*! User geometry with user defined intersection functions */
  8. struct UserGeometry : public AccelSet
  9. {
  10. /*! type of this geometry */
  11. static const Geometry::GTypeMask geom_type = Geometry::MTY_USER_GEOMETRY;
  12. public:
  13. UserGeometry (Device* device, unsigned int items = 0, unsigned int numTimeSteps = 1);
  14. virtual void setMask (unsigned mask);
  15. virtual void setBoundsFunction (RTCBoundsFunction bounds, void* userPtr);
  16. virtual void setIntersectFunctionN (RTCIntersectFunctionN intersect);
  17. virtual void setOccludedFunctionN (RTCOccludedFunctionN occluded);
  18. virtual void build() {}
  19. virtual void addElementsToCount (GeometryCounts & counts) const;
  20. };
  21. namespace isa
  22. {
  23. struct UserGeometryISA : public UserGeometry
  24. {
  25. UserGeometryISA (Device* device)
  26. : UserGeometry(device) {}
  27. PrimInfo createPrimRefArray(mvector<PrimRef>& prims, const range<size_t>& r, size_t k, unsigned int geomID) const
  28. {
  29. PrimInfo pinfo(empty);
  30. for (size_t j=r.begin(); j<r.end(); j++)
  31. {
  32. BBox3fa bounds = empty;
  33. if (!buildBounds(j,&bounds)) continue;
  34. const PrimRef prim(bounds,geomID,unsigned(j));
  35. pinfo.add_center2(prim);
  36. prims[k++] = prim;
  37. }
  38. return pinfo;
  39. }
  40. PrimInfo createPrimRefArrayMB(mvector<PrimRef>& prims, size_t itime, const range<size_t>& r, size_t k, unsigned int geomID) const
  41. {
  42. PrimInfo pinfo(empty);
  43. for (size_t j=r.begin(); j<r.end(); j++)
  44. {
  45. BBox3fa bounds = empty;
  46. if (!buildBounds(j,itime,bounds)) continue;
  47. const PrimRef prim(bounds,geomID,unsigned(j));
  48. pinfo.add_center2(prim);
  49. prims[k++] = prim;
  50. }
  51. return pinfo;
  52. }
  53. PrimInfoMB createPrimRefMBArray(mvector<PrimRefMB>& prims, const BBox1f& t0t1, const range<size_t>& r, size_t k, unsigned int geomID) const
  54. {
  55. PrimInfoMB pinfo(empty);
  56. for (size_t j=r.begin(); j<r.end(); j++)
  57. {
  58. if (!valid(j, timeSegmentRange(t0t1))) continue;
  59. const PrimRefMB prim(linearBounds(j,t0t1),this->numTimeSegments(),this->time_range,this->numTimeSegments(),geomID,unsigned(j));
  60. pinfo.add_primref(prim);
  61. prims[k++] = prim;
  62. }
  63. return pinfo;
  64. }
  65. };
  66. }
  67. DECLARE_ISA_FUNCTION(UserGeometry*, createUserGeometry, Device*);
  68. }