[Bf-blender-cvs] [4e47239] strand_editmode: Store the hair key weight in edit mode.
Lukas Tönne
noreply at git.blender.org
Mon Apr 20 14:23:01 CEST 2015
Commit: 4e47239de21c1f150069d110a05f64c9029e32bc
Author: Lukas Tönne
Date: Fri Nov 28 10:42:07 2014 +0100
Branches: strand_editmode
https://developer.blender.org/rB4e47239de21c1f150069d110a05f64c9029e32bc
Store the hair key weight in edit mode.
Currently particles only have a single weight value, controlling
pinning in the simulation (for root and virtual root verts) and goal
force scaling. This will be replaced by a full vertex group weight
system eventually.
===================================================================
M source/blender/bmesh/intern/bmesh_strands_conv.c
M source/blender/bmesh/intern/bmesh_strands_conv.h
===================================================================
diff --git a/source/blender/bmesh/intern/bmesh_strands_conv.c b/source/blender/bmesh/intern/bmesh_strands_conv.c
index 61556ea..d9eabd9 100644
--- a/source/blender/bmesh/intern/bmesh_strands_conv.c
+++ b/source/blender/bmesh/intern/bmesh_strands_conv.c
@@ -45,6 +45,7 @@
#include "intern/bmesh_private.h" /* for element checking */
const char *CD_PSYS_MASS = "PSYS_MASS";
+const char *CD_PSYS_WEIGHT = "PSYS_WEIGHT";
int BM_strands_count_psys_keys(ParticleSystem *psys)
{
@@ -88,6 +89,9 @@ void BM_strands_cd_flag_apply(BMesh *bm, const char UNUSED(cd_flag))
if (CustomData_get_named_layer_index(&bm->vdata, CD_PROP_FLT, CD_PSYS_MASS) < 0) {
BM_data_layer_add_named(bm, &bm->vdata, CD_PROP_FLT, CD_PSYS_MASS);
}
+ if (CustomData_get_named_layer_index(&bm->vdata, CD_PROP_FLT, CD_PSYS_WEIGHT) < 0) {
+ BM_data_layer_add_named(bm, &bm->vdata, CD_PROP_FLT, CD_PSYS_WEIGHT);
+ }
}
char BM_strands_cd_flag_from_bmesh(BMesh *UNUSED(bm))
@@ -181,6 +185,7 @@ static void bm_make_particles(BMesh *bm, ParticleSystem *psys, float (*keyco)[3]
CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
BM_elem_float_data_named_set(&bm->vdata, v, CD_PROP_FLT, CD_PSYS_MASS, mass);
+ BM_elem_float_data_named_set(&bm->vdata, v, CD_PROP_FLT, CD_PSYS_WEIGHT, hkey->weight);
/* set shapekey data */
if (psys->key) {
@@ -418,7 +423,7 @@ static int bm_keys_count(BMVert *root)
return count;
}
-static void make_particle_hair(BMesh *UNUSED(bm), BMVert *root, ParticleSystem *psys, ParticleData *pa)
+static void make_particle_hair(BMesh *bm, BMVert *root, ParticleSystem *psys, ParticleData *pa)
{
int totkey = bm_keys_count(root);
HairKey *hair;
@@ -451,7 +456,7 @@ static void make_particle_hair(BMesh *UNUSED(bm), BMVert *root, ParticleSystem *
BM_ITER_STRANDS_ELEM(v, &iter, root, BM_VERTS_OF_STRAND) {
copy_v3_v3(hkey->co, v->co);
hkey->time = totkey > 0 ? (float)k / (float)(totkey - 1) : 0.0f;
- hkey->weight = 1.0f;
+ hkey->weight = BM_elem_float_data_named_get(&bm->vdata, v, CD_PROP_FLT, CD_PSYS_WEIGHT);
// TODO define other key stuff ...
++hkey;
diff --git a/source/blender/bmesh/intern/bmesh_strands_conv.h b/source/blender/bmesh/intern/bmesh_strands_conv.h
index 8766d18..a6d734e 100644
--- a/source/blender/bmesh/intern/bmesh_strands_conv.h
+++ b/source/blender/bmesh/intern/bmesh_strands_conv.h
@@ -37,6 +37,7 @@ struct Mesh;
struct ParticleSystem;
extern const char *CD_PSYS_MASS;
+extern const char *CD_PSYS_WEIGHT;
void BM_strands_cd_validate(struct BMesh *bm);
void BM_strands_cd_flag_ensure(struct BMesh *bm, struct ParticleSystem *psys, const char cd_flag);
More information about the Bf-blender-cvs
mailing list