object.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. namespace embree
  19. {
  20. struct Object
  21. {
  22. struct Type : public PrimitiveType
  23. {
  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. /*! constructs a virtual object */
  35. Object (unsigned geomID, unsigned primID)
  36. : geomID(geomID), primID(primID) {}
  37. /*! fill triangle from triangle list */
  38. __forceinline void fill(const PrimRef* prims, size_t& i, size_t end, Scene* scene)
  39. {
  40. const PrimRef& prim = prims[i]; i++;
  41. new (this) Object(prim.geomID(), prim.primID());
  42. }
  43. /*! fill triangle from triangle list */
  44. __forceinline LBBox3fa fillMB(const PrimRef* prims, size_t& i, size_t end, Scene* scene, size_t itime, size_t numTimeSteps)
  45. {
  46. const PrimRef& prim = prims[i]; i++;
  47. const unsigned geomID = prim.geomID();
  48. const unsigned primID = prim.primID();
  49. new (this) Object(geomID, primID);
  50. AccelSet* accel = (AccelSet*) scene->get(geomID);
  51. return accel->linearBounds(primID,itime,numTimeSteps);
  52. }
  53. /* Updates the primitive */
  54. __forceinline BBox3fa update(AccelSet* mesh) {
  55. return mesh->bounds(primID);
  56. }
  57. public:
  58. unsigned geomID; //!< geometry ID
  59. unsigned primID; //!< primitive ID
  60. };
  61. }