BKE_subsurf.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. #ifndef __BKE_SUBSURF_H__
  28. #define __BKE_SUBSURF_H__
  29. /** \file BKE_subsurf.h
  30. * \ingroup bke
  31. */
  32. /* struct DerivedMesh is used directly */
  33. #include "BKE_DerivedMesh.h"
  34. /* Thread sync primitives used directly. */
  35. #include "BLI_threads.h"
  36. struct CCGElem;
  37. struct DMFlagMat;
  38. struct DMGridAdjacency;
  39. struct DerivedMesh;
  40. struct MeshElemMap;
  41. struct Mesh;
  42. struct MPoly;
  43. struct Object;
  44. struct PBVH;
  45. struct SubsurfModifierData;
  46. struct CCGEdge;
  47. struct CCGFace;
  48. struct CCGVert;
  49. struct EdgeHash;
  50. struct PBVH;
  51. /**************************** External *****************************/
  52. typedef enum {
  53. SUBSURF_USE_RENDER_PARAMS = 1,
  54. SUBSURF_IS_FINAL_CALC = 2,
  55. SUBSURF_FOR_EDIT_MODE = 4,
  56. SUBSURF_IN_EDIT_MODE = 8,
  57. SUBSURF_ALLOC_PAINT_MASK = 16,
  58. SUBSURF_USE_GPU_BACKEND = 32,
  59. } SubsurfFlags;
  60. struct DerivedMesh *subsurf_make_derived_from_derived(
  61. struct DerivedMesh *dm,
  62. struct SubsurfModifierData *smd,
  63. float (*vertCos)[3],
  64. SubsurfFlags flags);
  65. void subsurf_calculate_limit_positions(struct Mesh *me, float (*r_positions)[3]);
  66. /* get gridsize from 'level', level must be greater than zero */
  67. int BKE_ccg_gridsize(int level);
  68. /* x/y grid coordinates at 'low_level' can be multiplied by the result
  69. * of this function to convert to grid coordinates at 'high_level' */
  70. int BKE_ccg_factor(int low_level, int high_level);
  71. void subsurf_copy_grid_hidden(struct DerivedMesh *dm,
  72. const struct MPoly *mpoly,
  73. struct MVert *mvert,
  74. const struct MDisps *mdisps);
  75. void subsurf_copy_grid_paint_mask(struct DerivedMesh *dm,
  76. const struct MPoly *mpoly, float *paint_mask,
  77. const struct GridPaintMask *grid_paint_mask);
  78. bool subsurf_has_edges(struct DerivedMesh *dm);
  79. bool subsurf_has_faces(struct DerivedMesh *dm);
  80. typedef enum MultiresModifiedFlags {
  81. /* indicates the grids have been sculpted on, so MDisps
  82. * have to be updated */
  83. MULTIRES_COORDS_MODIFIED = 1,
  84. /* indicates elements have been hidden or unhidden */
  85. MULTIRES_HIDDEN_MODIFIED = 2
  86. } MultiresModifiedFlags;
  87. /**************************** Internal *****************************/
  88. typedef struct CCGDerivedMesh {
  89. DerivedMesh dm;
  90. struct CCGSubSurf *ss;
  91. int freeSS;
  92. int drawInteriorEdges, useSubsurfUv, useGpuBackend;
  93. struct {int startVert; struct CCGVert *vert; } *vertMap;
  94. struct {int startVert; int startEdge; struct CCGEdge *edge; } *edgeMap;
  95. struct {int startVert; int startEdge;
  96. int startFace; struct CCGFace *face; } *faceMap;
  97. short *edgeFlags;
  98. struct DMFlagMat *faceFlags;
  99. int *reverseFaceMap;
  100. struct PBVH *pbvh;
  101. struct MeshElemMap *pmap;
  102. int *pmap_mem;
  103. struct CCGElem **gridData;
  104. int *gridOffset;
  105. struct CCGFace **gridFaces;
  106. struct DMFlagMat *gridFlagMats;
  107. unsigned int **gridHidden;
  108. struct {
  109. struct MultiresModifierData *mmd;
  110. int local_mmd;
  111. int lvl, totlvl;
  112. float (*orco)[3];
  113. struct Object *ob;
  114. MultiresModifiedFlags modified_flags;
  115. } multires;
  116. struct EdgeHash *ehash;
  117. ThreadRWMutex loops_cache_rwlock;
  118. ThreadRWMutex origindex_cache_rwlock;
  119. } CCGDerivedMesh;
  120. #ifdef WITH_OPENSUBDIV
  121. /* TODO(sergey): Not really ideal place, but we don't currently have better one. */
  122. void BKE_subsurf_osd_init(void);
  123. void BKE_subsurf_free_unused_buffers(void);
  124. void BKE_subsurf_osd_cleanup(void);
  125. #endif
  126. #endif