BKE_shrinkwrap.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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) Blender Foundation.
  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_SHRINKWRAP_H__
  28. #define __BKE_SHRINKWRAP_H__
  29. /** \file BKE_shrinkwrap.h
  30. * \ingroup bke
  31. */
  32. /* Shrinkwrap stuff */
  33. #include "BKE_bvhutils.h"
  34. /*
  35. * Shrinkwrap is composed by a set of functions and options that define the type of shrink.
  36. *
  37. * 3 modes are available:
  38. * - Nearest vertex
  39. * - Nearest surface
  40. * - Normal projection
  41. *
  42. * ShrinkwrapCalcData encapsulates all needed data for shrinkwrap functions.
  43. * (So that you don't have to pass an enormous amount of arguments to functions)
  44. */
  45. struct Object;
  46. struct DerivedMesh;
  47. struct MVert;
  48. struct MDeformVert;
  49. struct ShrinkwrapModifierData;
  50. struct MDeformVert;
  51. struct BVHTree;
  52. struct SpaceTransform;
  53. typedef struct ShrinkwrapCalcData {
  54. ShrinkwrapModifierData *smd; //shrinkwrap modifier data
  55. struct Object *ob; //object we are applying shrinkwrap to
  56. struct MVert *vert; //Array of verts being projected (to fetch normals or other data)
  57. float (*vertexCos)[3]; //vertexs being shrinkwraped
  58. int numVerts;
  59. struct MDeformVert *dvert; //Pointer to mdeform array
  60. int vgroup; //Vertex group num
  61. bool invert_vgroup; /* invert vertex group influence */
  62. struct DerivedMesh *target; //mesh we are shrinking to
  63. struct SpaceTransform local2target; //transform to move between local and target space
  64. float keepDist; //Distance to keep above target surface (units are in local space)
  65. } ShrinkwrapCalcData;
  66. void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object *ob, struct DerivedMesh *dm,
  67. float (*vertexCos)[3], int numVerts, bool for_render);
  68. /*
  69. * This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
  70. *
  71. * if transf was configured with "SPACE_TRANSFORM_SETUP( &transf, ob1, ob2 )"
  72. * then the input (vert, dir, BVHTreeRayHit) must be defined in ob1 coordinates space
  73. * and the BVHTree must be built in ob2 coordinate space.
  74. *
  75. * Thus it provides an easy way to cast the same ray across several trees
  76. * (where each tree was built on its own coords space)
  77. */
  78. bool BKE_shrinkwrap_project_normal(
  79. char options, const float vert[3], const float dir[3],
  80. const struct SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit,
  81. BVHTree_RayCastCallback callback, void *userdata);
  82. /*
  83. * NULL initializers to local data
  84. */
  85. #define NULL_ShrinkwrapCalcData {NULL, }
  86. #define NULL_BVHTreeFromMesh {NULL, }
  87. #define NULL_BVHTreeRayHit {NULL, }
  88. #define NULL_BVHTreeNearest {0, }
  89. #endif /* __BKE_SHRINKWRAP_H__ */