Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BKE_shrinkwrap.h « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 296bbbaf886d6388770efcce6e20cd8db320fcb9 (plain)
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
/**
 * 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

/* 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_setup(SpaceTransform *data, struct Object *local, struct Object *target);

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 */
struct Object;
struct DerivedMesh;
struct ShrinkwrapModifierData;



typedef struct ShrinkwrapCalcData
{
	ShrinkwrapModifierData *smd;	//shrinkwrap modifier data

	struct Object *ob;				//object we are applying shrinkwrap to
	struct DerivedMesh *original;	//mesh before shrinkwrap (TODO clean this variable.. we don't really need it)
	struct DerivedMesh *final;		//initially a copy of original mesh.. mesh thats going to be shrinkwrapped

	struct DerivedMesh *target;		//mesh we are shrinking to
	
	SpaceTransform local2target;

	float keptDist;					//Distance to kept from target (units are in local space)
	//float *weights;				//weights of vertexs
	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);


#endif