scene_user_geometry.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. #include "scene_user_geometry.h"
  17. #include "scene.h"
  18. namespace embree
  19. {
  20. UserGeometry::UserGeometry (Scene* parent, RTCGeometryFlags gflags, size_t items, size_t numTimeSteps)
  21. : AccelSet(parent,gflags,items,numTimeSteps) {}
  22. void UserGeometry::setUserData (void* ptr) {
  23. intersectors.ptr = ptr;
  24. Geometry::setUserData(ptr);
  25. }
  26. void UserGeometry::setMask (unsigned mask)
  27. {
  28. if (parent->isStatic() && parent->isBuild())
  29. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  30. this->mask = mask;
  31. Geometry::update();
  32. }
  33. void UserGeometry::setBoundsFunction (RTCBoundsFunc bounds)
  34. {
  35. if (parent->isStatic() && parent->isBuild())
  36. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  37. this->boundsFunc = bounds;
  38. }
  39. void UserGeometry::setBoundsFunction2 (RTCBoundsFunc2 bounds, void* userPtr)
  40. {
  41. if (parent->isStatic() && parent->isBuild())
  42. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  43. this->boundsFunc2 = bounds;
  44. this->boundsFuncUserPtr = userPtr;
  45. }
  46. void UserGeometry::setBoundsFunction3 (RTCBoundsFunc3 bounds, void* userPtr)
  47. {
  48. if (parent->isStatic() && parent->isBuild())
  49. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  50. this->boundsFunc3 = bounds;
  51. this->boundsFuncUserPtr = userPtr;
  52. }
  53. void UserGeometry::setIntersectFunction (RTCIntersectFunc intersect1, bool ispc)
  54. {
  55. if (parent->isStreamMode())
  56. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetIntersectFunctionN (and optionally rtcSetIntersectFunction1Mp) in stream mode");
  57. if (parent->isStatic() && parent->isBuild())
  58. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  59. intersectors.intersector1.intersect = intersect1;
  60. }
  61. void UserGeometry::setIntersectFunction4 (RTCIntersectFunc4 intersect4, bool ispc)
  62. {
  63. if (parent->isStreamMode())
  64. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetIntersectFunctionN (and optionally rtcSetIntersectFunction1Mp) in stream mode");
  65. if (parent->isStatic() && parent->isBuild())
  66. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  67. intersectors.intersector4.intersect = (void*)intersect4;
  68. intersectors.intersector4.ispc = ispc;
  69. }
  70. void UserGeometry::setIntersectFunction8 (RTCIntersectFunc8 intersect8, bool ispc)
  71. {
  72. if (parent->isStreamMode())
  73. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetIntersectFunctionN (and optionally rtcSetIntersectFunction1Mp) in stream mode");
  74. if (parent->isStatic() && parent->isBuild())
  75. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  76. intersectors.intersector8.intersect = (void*)intersect8;
  77. intersectors.intersector8.ispc = ispc;
  78. }
  79. void UserGeometry::setIntersectFunction16 (RTCIntersectFunc16 intersect16, bool ispc)
  80. {
  81. if (parent->isStreamMode())
  82. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetIntersectFunctionN (and optionally rtcSetIntersectFunction1Mp) in stream mode");
  83. if (parent->isStatic() && parent->isBuild())
  84. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  85. intersectors.intersector16.intersect = (void*)intersect16;
  86. intersectors.intersector16.ispc = ispc;
  87. }
  88. void UserGeometry::setIntersectFunction1Mp (RTCIntersectFunc1Mp intersect)
  89. {
  90. if (!parent->isStreamMode())
  91. throw_RTCError(RTC_INVALID_OPERATION,"you can use rtcSetIntersectFunction1Mp only in stream mode");
  92. if (parent->isStatic() && parent->isBuild())
  93. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  94. intersectors.intersector1M.intersect = intersect;
  95. }
  96. void UserGeometry::setIntersectFunctionN (RTCIntersectFuncN intersect)
  97. {
  98. if (!parent->isStreamMode())
  99. throw_RTCError(RTC_INVALID_OPERATION,"you can use rtcSetIntersectFunctionN only in stream mode");
  100. if (parent->isStatic() && parent->isBuild())
  101. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  102. intersectors.intersectorN.intersect = intersect;
  103. }
  104. void UserGeometry::setOccludedFunction (RTCOccludedFunc occluded1, bool ispc)
  105. {
  106. if (parent->isStreamMode())
  107. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetOccludedFunctionN (and optionally rtcSetOccludedFunction1Mp) in stream mode");
  108. if (parent->isStatic() && parent->isBuild())
  109. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  110. intersectors.intersector1.occluded = occluded1;
  111. }
  112. void UserGeometry::setOccludedFunction4 (RTCOccludedFunc4 occluded4, bool ispc)
  113. {
  114. if (parent->isStreamMode())
  115. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetOccludedFunctionN (and optionally rtcSetOccludedFunction1Mp) in stream mode");
  116. if (parent->isStatic() && parent->isBuild())
  117. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  118. intersectors.intersector4.occluded = (void*)occluded4;
  119. intersectors.intersector4.ispc = ispc;
  120. }
  121. void UserGeometry::setOccludedFunction8 (RTCOccludedFunc8 occluded8, bool ispc)
  122. {
  123. if (parent->isStreamMode())
  124. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetOccludedFunctionN (and optionally rtcSetOccludedFunction1Mp) in stream mode");
  125. if (parent->isStatic() && parent->isBuild())
  126. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  127. intersectors.intersector8.occluded = (void*)occluded8;
  128. intersectors.intersector8.ispc = ispc;
  129. }
  130. void UserGeometry::setOccludedFunction16 (RTCOccludedFunc16 occluded16, bool ispc)
  131. {
  132. if (parent->isStreamMode())
  133. throw_RTCError(RTC_INVALID_OPERATION,"you have to use rtcSetOccludedFunctionN (and optionally rtcSetOccludedFunction1Mp) in stream mode");
  134. if (parent->isStatic() && parent->isBuild())
  135. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  136. intersectors.intersector16.occluded = (void*)occluded16;
  137. intersectors.intersector16.ispc = ispc;
  138. }
  139. void UserGeometry::setOccludedFunction1Mp (RTCOccludedFunc1Mp occluded)
  140. {
  141. if (!parent->isStreamMode())
  142. throw_RTCError(RTC_INVALID_OPERATION,"you can use rtcSetOccludedFunction1Mp only in stream mode");
  143. if (parent->isStatic() && parent->isBuild())
  144. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  145. intersectors.intersector1M.occluded = occluded;
  146. }
  147. void UserGeometry::setOccludedFunctionN (RTCOccludedFuncN occluded)
  148. {
  149. if (!parent->isStreamMode())
  150. throw_RTCError(RTC_INVALID_OPERATION,"you can use rtcSetOccludedFunctionN only in stream mode");
  151. if (parent->isStatic() && parent->isBuild())
  152. throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");
  153. intersectors.intersectorN.occluded = occluded;
  154. }
  155. }