1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/**
* BKE_shrinkwrap.h
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BKE_SHRINKWRAP_H
#define BKE_SHRINKWRAP_H
/* mesh util */
//TODO move this somewhere else
#include "BKE_customdata.h"
struct DerivedMesh;
struct Object;
struct DerivedMesh *object_get_derived_final(struct Object *ob, CustomDataMask dataMask);
/* bitset stuff */
//TODO: should move this to other generic lib files?
typedef char* BitSet;
#define bitset_memsize(size) (sizeof(char)*((size+7)>>3))
#define bitset_new(size,name) ((BitSet)MEM_callocN( bitset_memsize(size) , name))
#define bitset_free(set) (MEM_freeN((void*)set))
#define bitset_get(set,index) ((set)[(index)>>3] & (1 << ((index)&0x7)))
#define bitset_set(set,index) ((set)[(index)>>3] |= (1 << ((index)&0x7)))
#define bitset_unset(set,index) ((set)[(index)>>3] &= ~(1 << ((index)&0x7)))
/* SpaceTransform stuff */
//TODO: should move to other generic space?
struct Object;
typedef struct SpaceTransform
{
float local2target[4][4];
float target2local[4][4];
} SpaceTransform;
void space_transform_from_matrixs(SpaceTransform *data, float local[][4], float target[][4]);
#define space_transform_setup(data, local, target) space_transform_from_matrixs(data, (local)->obmat, (target)->obmat)
void space_transform_apply (const SpaceTransform *data, float *co);
void space_transform_invert(const SpaceTransform *data, float *co);
void space_transform_apply_normal (const SpaceTransform *data, float *co);
void space_transform_invert_normal(const SpaceTransform *data, float *co);
/* Shrinkwrap stuff */
#include "BKE_bvhutils.h"
struct Object;
struct DerivedMesh;
struct ShrinkwrapModifierData;
struct BVHTree;
/* maybe move to bvh util */
int normal_projection_project_vertex(char options, const float *vert, const float *dir, const SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
typedef struct ShrinkwrapCalcData
{
ShrinkwrapModifierData *smd; //shrinkwrap modifier data
struct Object *ob; //object we are applying shrinkwrap to
struct DerivedMesh *original; //mesh before shrinkwrap
float (*vertexCos)[3]; //vertexs being shrinkwraped
int numVerts;
struct DerivedMesh *target; //mesh we are shrinking to
SpaceTransform local2target; //transform to move bettwem local and target space
float keptDist; //Distance to kept from target (units are in local space)
BitSet moved; //BitSet indicating if vertex has moved
} ShrinkwrapCalcData;
void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *data);
void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *data);
void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *data);
struct DerivedMesh *shrinkwrapModifier_do(struct ShrinkwrapModifierData *smd, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc);
void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts);
#define NULL_ShrinkwrapCalcData {NULL, }
#define NULL_BVHTreeFromMesh {NULL, }
#define NULL_BVHTreeRayHit {NULL, }
#define NULL_BVHTreeNearest {NULL, }
#endif
|