mesh_subdivision.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * Copyright 2011-2016 Blender Foundation
  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 "render/mesh.h"
  17. #include "render/attribute.h"
  18. #include "render/camera.h"
  19. #include "subd/subd_split.h"
  20. #include "subd/subd_patch.h"
  21. #include "subd/subd_patch_table.h"
  22. #include "util/util_foreach.h"
  23. #include "util/util_algorithm.h"
  24. CCL_NAMESPACE_BEGIN
  25. #ifdef WITH_OPENSUBDIV
  26. CCL_NAMESPACE_END
  27. # include <opensubdiv/far/topologyRefinerFactory.h>
  28. # include <opensubdiv/far/primvarRefiner.h>
  29. # include <opensubdiv/far/patchTableFactory.h>
  30. # include <opensubdiv/far/patchMap.h>
  31. /* specializations of TopologyRefinerFactory for ccl::Mesh */
  32. namespace OpenSubdiv {
  33. namespace OPENSUBDIV_VERSION {
  34. namespace Far {
  35. template<>
  36. bool TopologyRefinerFactory<ccl::Mesh>::resizeComponentTopology(TopologyRefiner &refiner,
  37. ccl::Mesh const &mesh)
  38. {
  39. setNumBaseVertices(refiner, mesh.verts.size());
  40. setNumBaseFaces(refiner, mesh.subd_faces.size());
  41. const ccl::Mesh::SubdFace *face = mesh.subd_faces.data();
  42. for (int i = 0; i < mesh.subd_faces.size(); i++, face++) {
  43. setNumBaseFaceVertices(refiner, i, face->num_corners);
  44. }
  45. return true;
  46. }
  47. template<>
  48. bool TopologyRefinerFactory<ccl::Mesh>::assignComponentTopology(TopologyRefiner &refiner,
  49. ccl::Mesh const &mesh)
  50. {
  51. const ccl::Mesh::SubdFace *face = mesh.subd_faces.data();
  52. for (int i = 0; i < mesh.subd_faces.size(); i++, face++) {
  53. IndexArray face_verts = getBaseFaceVertices(refiner, i);
  54. int *corner = &mesh.subd_face_corners[face->start_corner];
  55. for (int j = 0; j < face->num_corners; j++, corner++) {
  56. face_verts[j] = *corner;
  57. }
  58. }
  59. return true;
  60. }
  61. template<>
  62. bool TopologyRefinerFactory<ccl::Mesh>::assignComponentTags(TopologyRefiner &refiner,
  63. ccl::Mesh const &mesh)
  64. {
  65. const ccl::Mesh::SubdEdgeCrease *crease = mesh.subd_creases.data();
  66. for (int i = 0; i < mesh.subd_creases.size(); i++, crease++) {
  67. Index edge = findBaseEdge(refiner, crease->v[0], crease->v[1]);
  68. if (edge != INDEX_INVALID) {
  69. setBaseEdgeSharpness(refiner, edge, crease->crease * 10.0f);
  70. }
  71. }
  72. for (int i = 0; i < mesh.verts.size(); i++) {
  73. ConstIndexArray vert_edges = getBaseVertexEdges(refiner, i);
  74. if (vert_edges.size() == 2) {
  75. float sharpness = refiner.getLevel(0).getEdgeSharpness(vert_edges[0]);
  76. sharpness = ccl::min(sharpness, refiner.getLevel(0).getEdgeSharpness(vert_edges[1]));
  77. setBaseVertexSharpness(refiner, i, sharpness);
  78. }
  79. }
  80. return true;
  81. }
  82. template<>
  83. bool TopologyRefinerFactory<ccl::Mesh>::assignFaceVaryingTopology(TopologyRefiner & /*refiner*/,
  84. ccl::Mesh const & /*mesh*/)
  85. {
  86. return true;
  87. }
  88. template<>
  89. void TopologyRefinerFactory<ccl::Mesh>::reportInvalidTopology(TopologyError /*err_code*/,
  90. char const * /*msg*/,
  91. ccl::Mesh const & /*mesh*/)
  92. {
  93. }
  94. } /* namespace Far */
  95. } /* namespace OPENSUBDIV_VERSION */
  96. } /* namespace OpenSubdiv */
  97. CCL_NAMESPACE_BEGIN
  98. using namespace OpenSubdiv;
  99. /* struct that implements OpenSubdiv's vertex interface */
  100. template<typename T> struct OsdValue {
  101. T value;
  102. OsdValue()
  103. {
  104. }
  105. void Clear(void * = 0)
  106. {
  107. memset(&value, 0, sizeof(T));
  108. }
  109. void AddWithWeight(OsdValue<T> const &src, float weight)
  110. {
  111. value += src.value * weight;
  112. }
  113. };
  114. template<> void OsdValue<uchar4>::AddWithWeight(OsdValue<uchar4> const &src, float weight)
  115. {
  116. for (int i = 0; i < 4; i++) {
  117. value[i] += (uchar)(src.value[i] * weight);
  118. }
  119. }
  120. /* class for holding OpenSubdiv data used during tessellation */
  121. class OsdData {
  122. Mesh *mesh;
  123. vector<OsdValue<float3>> verts;
  124. Far::TopologyRefiner *refiner;
  125. Far::PatchTable *patch_table;
  126. Far::PatchMap *patch_map;
  127. public:
  128. OsdData() : mesh(NULL), refiner(NULL), patch_table(NULL), patch_map(NULL)
  129. {
  130. }
  131. ~OsdData()
  132. {
  133. delete refiner;
  134. delete patch_table;
  135. delete patch_map;
  136. }
  137. void build_from_mesh(Mesh *mesh_)
  138. {
  139. mesh = mesh_;
  140. /* type and options */
  141. Sdc::SchemeType type = Sdc::SCHEME_CATMARK;
  142. Sdc::Options options;
  143. options.SetVtxBoundaryInterpolation(Sdc::Options::VTX_BOUNDARY_EDGE_ONLY);
  144. /* create refiner */
  145. refiner = Far::TopologyRefinerFactory<Mesh>::Create(
  146. *mesh, Far::TopologyRefinerFactory<Mesh>::Options(type, options));
  147. /* adaptive refinement */
  148. int max_isolation = calculate_max_isolation();
  149. refiner->RefineAdaptive(Far::TopologyRefiner::AdaptiveOptions(max_isolation));
  150. /* create patch table */
  151. Far::PatchTableFactory::Options patch_options;
  152. patch_options.endCapType = Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS;
  153. patch_table = Far::PatchTableFactory::Create(*refiner, patch_options);
  154. /* interpolate verts */
  155. int num_refiner_verts = refiner->GetNumVerticesTotal();
  156. int num_local_points = patch_table->GetNumLocalPoints();
  157. verts.resize(num_refiner_verts + num_local_points);
  158. for (int i = 0; i < mesh->verts.size(); i++) {
  159. verts[i].value = mesh->verts[i];
  160. }
  161. OsdValue<float3> *src = verts.data();
  162. for (int i = 0; i < refiner->GetMaxLevel(); i++) {
  163. OsdValue<float3> *dest = src + refiner->GetLevel(i).GetNumVertices();
  164. Far::PrimvarRefiner(*refiner).Interpolate(i + 1, src, dest);
  165. src = dest;
  166. }
  167. if (num_local_points) {
  168. patch_table->ComputeLocalPointValues(&verts[0], &verts[num_refiner_verts]);
  169. }
  170. /* create patch map */
  171. patch_map = new Far::PatchMap(*patch_table);
  172. }
  173. void subdivide_attribute(Attribute &attr)
  174. {
  175. Far::PrimvarRefiner primvar_refiner(*refiner);
  176. if (attr.element == ATTR_ELEMENT_VERTEX) {
  177. int num_refiner_verts = refiner->GetNumVerticesTotal();
  178. int num_local_points = patch_table->GetNumLocalPoints();
  179. attr.resize(num_refiner_verts + num_local_points);
  180. attr.flags |= ATTR_FINAL_SIZE;
  181. char *src = attr.buffer.data();
  182. for (int i = 0; i < refiner->GetMaxLevel(); i++) {
  183. char *dest = src + refiner->GetLevel(i).GetNumVertices() * attr.data_sizeof();
  184. if (attr.same_storage(attr.type, TypeDesc::TypeFloat)) {
  185. primvar_refiner.Interpolate(i + 1, (OsdValue<float> *)src, (OsdValue<float> *&)dest);
  186. }
  187. else if (attr.same_storage(attr.type, TypeFloat2)) {
  188. primvar_refiner.Interpolate(i + 1, (OsdValue<float2> *)src, (OsdValue<float2> *&)dest);
  189. }
  190. else {
  191. primvar_refiner.Interpolate(i + 1, (OsdValue<float4> *)src, (OsdValue<float4> *&)dest);
  192. }
  193. src = dest;
  194. }
  195. if (num_local_points) {
  196. if (attr.same_storage(attr.type, TypeDesc::TypeFloat)) {
  197. patch_table->ComputeLocalPointValues(
  198. (OsdValue<float> *)&attr.buffer[0],
  199. (OsdValue<float> *)&attr.buffer[num_refiner_verts * attr.data_sizeof()]);
  200. }
  201. else if (attr.same_storage(attr.type, TypeFloat2)) {
  202. patch_table->ComputeLocalPointValues(
  203. (OsdValue<float2> *)&attr.buffer[0],
  204. (OsdValue<float2> *)&attr.buffer[num_refiner_verts * attr.data_sizeof()]);
  205. }
  206. else {
  207. patch_table->ComputeLocalPointValues(
  208. (OsdValue<float4> *)&attr.buffer[0],
  209. (OsdValue<float4> *)&attr.buffer[num_refiner_verts * attr.data_sizeof()]);
  210. }
  211. }
  212. }
  213. else if (attr.element == ATTR_ELEMENT_CORNER || attr.element == ATTR_ELEMENT_CORNER_BYTE) {
  214. // TODO(mai): fvar interpolation
  215. }
  216. }
  217. int calculate_max_isolation()
  218. {
  219. /* loop over all edges to find longest in screen space */
  220. const Far::TopologyLevel &level = refiner->GetLevel(0);
  221. Transform objecttoworld = mesh->subd_params->objecttoworld;
  222. Camera *cam = mesh->subd_params->camera;
  223. float longest_edge = 0.0f;
  224. for (size_t i = 0; i < level.GetNumEdges(); i++) {
  225. Far::ConstIndexArray verts = level.GetEdgeVertices(i);
  226. float3 a = mesh->verts[verts[0]];
  227. float3 b = mesh->verts[verts[1]];
  228. float edge_len;
  229. if (cam) {
  230. a = transform_point(&objecttoworld, a);
  231. b = transform_point(&objecttoworld, b);
  232. edge_len = len(a - b) / cam->world_to_raster_size((a + b) * 0.5f);
  233. }
  234. else {
  235. edge_len = len(a - b);
  236. }
  237. longest_edge = max(longest_edge, edge_len);
  238. }
  239. /* calculate isolation level */
  240. int isolation = (int)(log2f(max(longest_edge / mesh->subd_params->dicing_rate, 1.0f)) + 1.0f);
  241. return min(isolation, 10);
  242. }
  243. friend struct OsdPatch;
  244. friend class Mesh;
  245. };
  246. /* ccl::Patch implementation that uses OpenSubdiv for eval */
  247. struct OsdPatch : Patch {
  248. OsdData *osd_data;
  249. OsdPatch(OsdData *data) : osd_data(data)
  250. {
  251. }
  252. void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v)
  253. {
  254. const Far::PatchTable::PatchHandle *handle = osd_data->patch_map->FindPatch(patch_index, u, v);
  255. assert(handle);
  256. float p_weights[20], du_weights[20], dv_weights[20];
  257. osd_data->patch_table->EvaluateBasis(*handle, u, v, p_weights, du_weights, dv_weights);
  258. Far::ConstIndexArray cv = osd_data->patch_table->GetPatchVertices(*handle);
  259. float3 du, dv;
  260. if (P)
  261. *P = make_float3(0.0f, 0.0f, 0.0f);
  262. du = make_float3(0.0f, 0.0f, 0.0f);
  263. dv = make_float3(0.0f, 0.0f, 0.0f);
  264. for (int i = 0; i < cv.size(); i++) {
  265. float3 p = osd_data->verts[cv[i]].value;
  266. if (P)
  267. *P += p * p_weights[i];
  268. du += p * du_weights[i];
  269. dv += p * dv_weights[i];
  270. }
  271. if (dPdu)
  272. *dPdu = du;
  273. if (dPdv)
  274. *dPdv = dv;
  275. if (N) {
  276. *N = cross(du, dv);
  277. float t = len(*N);
  278. *N = (t != 0.0f) ? *N / t : make_float3(0.0f, 0.0f, 1.0f);
  279. }
  280. }
  281. BoundBox bound()
  282. {
  283. return BoundBox::empty;
  284. }
  285. };
  286. #endif
  287. void Mesh::tessellate(DiagSplit *split)
  288. {
  289. #ifdef WITH_OPENSUBDIV
  290. OsdData osd_data;
  291. bool need_packed_patch_table = false;
  292. if (subdivision_type == SUBDIVISION_CATMULL_CLARK) {
  293. if (subd_faces.size()) {
  294. osd_data.build_from_mesh(this);
  295. }
  296. }
  297. else
  298. #endif
  299. {
  300. /* force linear subdivision if OpenSubdiv is unavailable to avoid
  301. * falling into catmull-clark code paths by accident
  302. */
  303. subdivision_type = SUBDIVISION_LINEAR;
  304. /* force disable attribute subdivision for same reason as above */
  305. foreach (Attribute &attr, subd_attributes.attributes) {
  306. attr.flags &= ~ATTR_SUBDIVIDED;
  307. }
  308. }
  309. int num_faces = subd_faces.size();
  310. Attribute *attr_vN = subd_attributes.find(ATTR_STD_VERTEX_NORMAL);
  311. float3 *vN = attr_vN->data_float3();
  312. for (int f = 0; f < num_faces; f++) {
  313. SubdFace &face = subd_faces[f];
  314. if (face.is_quad()) {
  315. /* quad */
  316. QuadDice::SubPatch subpatch;
  317. LinearQuadPatch quad_patch;
  318. #ifdef WITH_OPENSUBDIV
  319. OsdPatch osd_patch(&osd_data);
  320. if (subdivision_type == SUBDIVISION_CATMULL_CLARK) {
  321. osd_patch.patch_index = face.ptex_offset;
  322. subpatch.patch = &osd_patch;
  323. }
  324. else
  325. #endif
  326. {
  327. float3 *hull = quad_patch.hull;
  328. float3 *normals = quad_patch.normals;
  329. quad_patch.patch_index = face.ptex_offset;
  330. for (int i = 0; i < 4; i++) {
  331. hull[i] = verts[subd_face_corners[face.start_corner + i]];
  332. }
  333. if (face.smooth) {
  334. for (int i = 0; i < 4; i++) {
  335. normals[i] = vN[subd_face_corners[face.start_corner + i]];
  336. }
  337. }
  338. else {
  339. float3 N = face.normal(this);
  340. for (int i = 0; i < 4; i++) {
  341. normals[i] = N;
  342. }
  343. }
  344. swap(hull[2], hull[3]);
  345. swap(normals[2], normals[3]);
  346. subpatch.patch = &quad_patch;
  347. }
  348. subpatch.patch->shader = face.shader;
  349. /* Quad faces need to be split at least once to line up with split ngons, we do this
  350. * here in this manner because if we do it later edge factors may end up slightly off.
  351. */
  352. subpatch.P00 = make_float2(0.0f, 0.0f);
  353. subpatch.P10 = make_float2(0.5f, 0.0f);
  354. subpatch.P01 = make_float2(0.0f, 0.5f);
  355. subpatch.P11 = make_float2(0.5f, 0.5f);
  356. split->split_quad(subpatch.patch, &subpatch);
  357. subpatch.P00 = make_float2(0.5f, 0.0f);
  358. subpatch.P10 = make_float2(1.0f, 0.0f);
  359. subpatch.P01 = make_float2(0.5f, 0.5f);
  360. subpatch.P11 = make_float2(1.0f, 0.5f);
  361. split->split_quad(subpatch.patch, &subpatch);
  362. subpatch.P00 = make_float2(0.0f, 0.5f);
  363. subpatch.P10 = make_float2(0.5f, 0.5f);
  364. subpatch.P01 = make_float2(0.0f, 1.0f);
  365. subpatch.P11 = make_float2(0.5f, 1.0f);
  366. split->split_quad(subpatch.patch, &subpatch);
  367. subpatch.P00 = make_float2(0.5f, 0.5f);
  368. subpatch.P10 = make_float2(1.0f, 0.5f);
  369. subpatch.P01 = make_float2(0.5f, 1.0f);
  370. subpatch.P11 = make_float2(1.0f, 1.0f);
  371. split->split_quad(subpatch.patch, &subpatch);
  372. }
  373. else {
  374. /* ngon */
  375. #ifdef WITH_OPENSUBDIV
  376. if (subdivision_type == SUBDIVISION_CATMULL_CLARK) {
  377. OsdPatch patch(&osd_data);
  378. patch.shader = face.shader;
  379. for (int corner = 0; corner < face.num_corners; corner++) {
  380. patch.patch_index = face.ptex_offset + corner;
  381. split->split_quad(&patch);
  382. }
  383. }
  384. else
  385. #endif
  386. {
  387. float3 center_vert = make_float3(0.0f, 0.0f, 0.0f);
  388. float3 center_normal = make_float3(0.0f, 0.0f, 0.0f);
  389. float inv_num_corners = 1.0f / float(face.num_corners);
  390. for (int corner = 0; corner < face.num_corners; corner++) {
  391. center_vert += verts[subd_face_corners[face.start_corner + corner]] * inv_num_corners;
  392. center_normal += vN[subd_face_corners[face.start_corner + corner]] * inv_num_corners;
  393. }
  394. for (int corner = 0; corner < face.num_corners; corner++) {
  395. LinearQuadPatch patch;
  396. float3 *hull = patch.hull;
  397. float3 *normals = patch.normals;
  398. patch.patch_index = face.ptex_offset + corner;
  399. patch.shader = face.shader;
  400. hull[0] =
  401. verts[subd_face_corners[face.start_corner + mod(corner + 0, face.num_corners)]];
  402. hull[1] =
  403. verts[subd_face_corners[face.start_corner + mod(corner + 1, face.num_corners)]];
  404. hull[2] =
  405. verts[subd_face_corners[face.start_corner + mod(corner - 1, face.num_corners)]];
  406. hull[3] = center_vert;
  407. hull[1] = (hull[1] + hull[0]) * 0.5;
  408. hull[2] = (hull[2] + hull[0]) * 0.5;
  409. if (face.smooth) {
  410. normals[0] =
  411. vN[subd_face_corners[face.start_corner + mod(corner + 0, face.num_corners)]];
  412. normals[1] =
  413. vN[subd_face_corners[face.start_corner + mod(corner + 1, face.num_corners)]];
  414. normals[2] =
  415. vN[subd_face_corners[face.start_corner + mod(corner - 1, face.num_corners)]];
  416. normals[3] = center_normal;
  417. normals[1] = (normals[1] + normals[0]) * 0.5;
  418. normals[2] = (normals[2] + normals[0]) * 0.5;
  419. }
  420. else {
  421. float3 N = face.normal(this);
  422. for (int i = 0; i < 4; i++) {
  423. normals[i] = N;
  424. }
  425. }
  426. split->split_quad(&patch);
  427. }
  428. }
  429. }
  430. }
  431. /* interpolate center points for attributes */
  432. foreach (Attribute &attr, subd_attributes.attributes) {
  433. #ifdef WITH_OPENSUBDIV
  434. if (subdivision_type == SUBDIVISION_CATMULL_CLARK && attr.flags & ATTR_SUBDIVIDED) {
  435. if (attr.element == ATTR_ELEMENT_CORNER || attr.element == ATTR_ELEMENT_CORNER_BYTE) {
  436. /* keep subdivision for corner attributes disabled for now */
  437. attr.flags &= ~ATTR_SUBDIVIDED;
  438. }
  439. else if (subd_faces.size()) {
  440. osd_data.subdivide_attribute(attr);
  441. need_packed_patch_table = true;
  442. continue;
  443. }
  444. }
  445. #endif
  446. char *data = attr.data();
  447. size_t stride = attr.data_sizeof();
  448. int ngons = 0;
  449. switch (attr.element) {
  450. case ATTR_ELEMENT_VERTEX: {
  451. for (int f = 0; f < num_faces; f++) {
  452. SubdFace &face = subd_faces[f];
  453. if (!face.is_quad()) {
  454. char *center = data + (verts.size() - num_subd_verts + ngons) * stride;
  455. attr.zero_data(center);
  456. float inv_num_corners = 1.0f / float(face.num_corners);
  457. for (int corner = 0; corner < face.num_corners; corner++) {
  458. attr.add_with_weight(center,
  459. data + subd_face_corners[face.start_corner + corner] * stride,
  460. inv_num_corners);
  461. }
  462. ngons++;
  463. }
  464. }
  465. } break;
  466. case ATTR_ELEMENT_VERTEX_MOTION: {
  467. // TODO(mai): implement
  468. } break;
  469. case ATTR_ELEMENT_CORNER: {
  470. for (int f = 0; f < num_faces; f++) {
  471. SubdFace &face = subd_faces[f];
  472. if (!face.is_quad()) {
  473. char *center = data + (subd_face_corners.size() + ngons) * stride;
  474. attr.zero_data(center);
  475. float inv_num_corners = 1.0f / float(face.num_corners);
  476. for (int corner = 0; corner < face.num_corners; corner++) {
  477. attr.add_with_weight(
  478. center, data + (face.start_corner + corner) * stride, inv_num_corners);
  479. }
  480. ngons++;
  481. }
  482. }
  483. } break;
  484. case ATTR_ELEMENT_CORNER_BYTE: {
  485. for (int f = 0; f < num_faces; f++) {
  486. SubdFace &face = subd_faces[f];
  487. if (!face.is_quad()) {
  488. uchar *center = (uchar *)data + (subd_face_corners.size() + ngons) * stride;
  489. float inv_num_corners = 1.0f / float(face.num_corners);
  490. float4 val = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
  491. for (int corner = 0; corner < face.num_corners; corner++) {
  492. for (int i = 0; i < 4; i++) {
  493. val[i] += float(*(data + (face.start_corner + corner) * stride + i)) *
  494. inv_num_corners;
  495. }
  496. }
  497. for (int i = 0; i < 4; i++) {
  498. center[i] = uchar(min(max(val[i], 0.0f), 255.0f));
  499. }
  500. ngons++;
  501. }
  502. }
  503. } break;
  504. default:
  505. break;
  506. }
  507. }
  508. #ifdef WITH_OPENSUBDIV
  509. /* pack patch tables */
  510. if (need_packed_patch_table) {
  511. delete patch_table;
  512. patch_table = new PackedPatchTable;
  513. patch_table->pack(osd_data.patch_table);
  514. }
  515. #endif
  516. }
  517. CCL_NAMESPACE_END