bezier1i.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #pragma once
  17. #include "primitive.h"
  18. #include "bezier1v.h"
  19. namespace embree
  20. {
  21. struct Bezier1i
  22. {
  23. struct Type : public PrimitiveType {
  24. Type ();
  25. size_t size(const char* This) const;
  26. };
  27. static Type type;
  28. public:
  29. /* Returns maximal number of stored primitives */
  30. static __forceinline size_t max_size() { return 1; }
  31. /* Returns required number of primitive blocks for N primitives */
  32. static __forceinline size_t blocks(size_t N) { return N; }
  33. public:
  34. /*! Default constructor. */
  35. __forceinline Bezier1i () {}
  36. /*! Construction from vertices and IDs. */
  37. __forceinline Bezier1i (const unsigned vertexID, const unsigned geomID, const unsigned primID)
  38. : vertexID(vertexID), geom(geomID), prim(primID) {}
  39. /*! returns geometry ID */
  40. __forceinline unsigned geomID() const { return geom; }
  41. /*! returns primitive ID */
  42. __forceinline unsigned primID() const { return prim; }
  43. /*! fill curve from curve list */
  44. __forceinline void fill(const PrimRef* prims, size_t& i, size_t end, Scene* scene)
  45. {
  46. const PrimRef& prim = prims[i];
  47. i++;
  48. const unsigned geomID = prim.geomID();
  49. const unsigned primID = prim.primID();
  50. const NativeCurves* curves = scene->get<NativeCurves>(geomID);
  51. const unsigned vertexID = curves->curve(primID);
  52. new (this) Bezier1i(vertexID,geomID,primID);
  53. }
  54. /*! fill curve from curve list */
  55. __forceinline void fill(const BezierPrim* prims, size_t& i, size_t end, Scene* scene)
  56. {
  57. const BezierPrim& curve = prims[i]; i++;
  58. const unsigned geomID = curve.geomID();
  59. const unsigned primID = curve.primID();
  60. const NativeCurves* curves = scene->get<NativeCurves>(geomID);
  61. const unsigned vertexID = curves->curve(primID);
  62. new (this) Bezier1i(vertexID,geomID,primID);
  63. }
  64. public:
  65. unsigned vertexID; //!< index of start vertex
  66. unsigned geom; //!< geometry ID
  67. unsigned prim; //!< primitive ID
  68. };
  69. }