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

BKE_groom.h « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e88513b548033b2c04086bc0c0e2ef405528fe9b (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) Blender Foundation
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): Lukas Toenne
 *
 * ***** END GPL LICENSE BLOCK *****
 */

#ifndef __BKE_GROOM_H__
#define __BKE_GROOM_H__

/** \file BKE_groom.h
 *  \ingroup bke
 */

struct EvaluationContext;
struct Groom;
struct GroomBundle;
struct Main;
struct Object;
struct Scene;

void BKE_groom_init(struct Groom *groom);
void *BKE_groom_add(struct Main *bmain, const char *name);

void BKE_groom_free(struct Groom *groom);
void BKE_groom_bundle_curve_cache_clear(struct GroomBundle *bundle);

void BKE_groom_copy_data(struct Main *bmain, struct Groom *groom_dst, const struct Groom *groom_src, const int flag);
struct Groom *BKE_groom_copy(struct Main *bmain, const struct Groom *groom);

void BKE_groom_make_local(struct Main *bmain, struct Groom *groom, const bool lib_local);

bool BKE_groom_minmax(struct Groom *groom, float min[3], float max[3]);
void BKE_groom_boundbox_calc(struct Groom *groom, float r_loc[3], float r_size[3]);


/* === Curve cache === */

void BKE_groom_curve_cache_update(struct Groom *groom);
void BKE_groom_curve_cache_clear(struct Groom *groom);


/* === Scalp regions === */

/* Try to bind bundles to their scalp regions */
void BKE_groom_bind_scalp_regions(struct Groom *groom, bool force_rebind);

bool BKE_groom_bundle_bind(struct Groom *groom, struct GroomBundle *bundle, bool force_rebind);
void BKE_groom_bundle_unbind(struct GroomBundle *bundle);


/* === Hair System === */

/* Create follicles and guide curve origins on the scalp surface for hair fiber rendering */
void BKE_groom_hair_distribute(struct Groom *groom, unsigned int seed, int hair_count, int guide_curve_count);

/* Calculate guide curve shapes based on groom bundle deformation */
void BKE_groom_hair_update_guide_curves(struct Groom *groom);


/* === Depsgraph evaluation === */

void BKE_groom_eval_geometry(const struct EvaluationContext *eval_ctx, struct Groom *groom);


/* === Draw Cache === */

enum {
	BKE_GROOM_BATCH_DIRTY_ALL = 0,
	BKE_GROOM_BATCH_DIRTY_SELECT,
};
void BKE_groom_batch_cache_dirty(struct Groom *groom, int mode);
void BKE_groom_batch_cache_free(struct Groom *groom);

/* === Iterators === */

/* Utility class for iterating over groom elements */
typedef struct GroomIterator
{
	int isection;                       /* section index */
	struct GroomSection *section;       /* section data pointer */
	
	int ivertex;                        /* vertex index */
	int isectionvertex;                 /* vertex index for the inner loop */
	struct GroomSectionVertex *vertex;  /* vertex data pointer */
} GroomIterator;

#define GROOM_ITER_SECTIONS(iter, bundle) \
	for (iter.isection = 0, iter.section = (bundle)->sections; \
	     iter.isection < (bundle)->totsections; \
	     ++iter.isection, ++iter.section)

#define GROOM_ITER_SECTION_LOOPS(iter, sectionvar, vertexvar, bundle) \
	for (iter.isection = 0, iter.section = (bundle)->sections, iter.ivertex = 0, iter.vertex = (bundle)->verts; \
	     iter.isection < (bundle)->totsections; \
	     ++iter.isection, ++iter.section) \
		for (iter.isectionvertex = 0; \
		     iter.isectionvertex < (bundle)->numloopverts; \
		     ++iter.isectionvertex, ++iter.vertex)

/* === Utility functions (DerivedMesh SOON TO BE DEPRECATED!) === */
struct DerivedMesh;
struct DerivedMesh* BKE_groom_get_scalp(struct Groom *groom);

#endif /*  __BKE_GROOM_H__ */