Commit: 54ae1e90d72a8fb46e55672697a0a570143b6cb3
Author: Lukas Tönne
Date: Mon Nov 17 14:52:53 2014 +0100
Branches: gooseberry
https://developer.blender.org/rB54ae1e90d72a8fb46e55672697a0a570143b6cb3
Merge branch 'master' into gooseberry
Conflicts:
source/blender/blenkernel/BKE_key.h
source/blender/editors/transform/transform_manipulator.c
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_key.h
index 142245b,31b2c7d..0a92bb9
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@@ -91,25 -81,31 +91,35 @@@ typedef struct WeightsArrayCache
float **defgroup_weights;
} WeightsArrayCache;
- float **BKE_key_get_per_block_object_weights(struct Object *ob, struct Key
*key, struct WeightsArrayCache *cache);
- float **BKE_key_get_per_block_particle_weights(struct ParticleSystem *psys,
struct Key *key, struct WeightsArrayCache *cache);
-float **BKE_keyblock_get_per_block_weights(struct Object *ob, struct Key
*key, struct WeightsArrayCache *cache);
++float **BKE_keyblock_get_per_block_object_weights(struct Object *ob, struct
Key *key, struct WeightsArrayCache *cache);
++float **BKE_keyblock_get_per_block_particle_weights(struct ParticleSystem
*psys, struct Key *key, struct WeightsArrayCache *cache);
void BKE_keyblock_free_per_block_weights(struct Key *key, float
**per_keyblock_weights, struct WeightsArrayCache *cache);
void BKE_key_evaluate_relative(const int start, int end, const int tot, char
*basispoin, struct Key *key, struct KeyBlock *actkb,
float **per_keyblock_weights, const int mode);
/* conversion functions */
- void BKE_key_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me);
- void BKE_key_convert_from_mesh(struct Mesh *me, struct KeyBlock *kb);
- void BKE_key_convert_to_lattice(struct KeyBlock *kb, struct Lattice *lt);
- void BKE_key_convert_from_lattice(struct Lattice *lt, struct KeyBlock *kb);
- void BKE_key_convert_to_curve(struct KeyBlock *kb, struct Curve *cu,
struct ListBase *nurb);
- void BKE_key_convert_from_curve(struct Curve *cu, struct KeyBlock *kb,
struct ListBase *nurb);
- float (*BKE_key_convert_to_vertcos(struct Object *ob, struct KeyBlock
*kb))[3];
- void BKE_key_convert_from_vertcos(struct Object *ob, struct KeyBlock *kb,
float (*vertCos)[3]);
- void BKE_key_convert_from_offset(struct Object *ob, struct KeyBlock *kb,
float (*ofs)[3]);
- void BKE_key_convert_to_hair_keys(struct KeyBlock *kb, struct Object *ob,
struct ParticleSystem *psys);
- void BKE_key_convert_from_hair_keys(struct Object *ob, struct
ParticleSystem *psys, struct KeyBlock *kb);
+ /* Note: 'update_from' versions do not (re)allocate mem in kb, while
'convert_from' do. */
+ void BKE_keyblock_update_from_lattice(struct Lattice *lt, struct KeyBlock
*kb);
+ void BKE_keyblock_convert_from_lattice(struct Lattice *lt, struct KeyBlock
*kb);
+ void BKE_keyblock_convert_to_lattice(struct KeyBlock *kb, struct Lattice
*lt);
+
+ void BKE_keyblock_update_from_curve(struct Curve *cu, struct KeyBlock *kb,
struct ListBase *nurb);
+ void BKE_keyblock_convert_from_curve(struct Curve *cu, struct KeyBlock
*kb, struct ListBase *nurb);
+ void BKE_keyblock_convert_to_curve(struct KeyBlock *kb, struct Curve *cu,
struct ListBase *nurb);
+
+ void BKE_keyblock_update_from_mesh(struct Mesh *me, struct KeyBlock *kb);
+ void BKE_keyblock_convert_from_mesh(struct Mesh *me, struct KeyBlock *kb);
+ void BKE_keyblock_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me);
+
+ void BKE_keyblock_update_from_vertcos(struct Object *ob, struct KeyBlock
*kb, float (*vertCos)[3]);
+ void BKE_keyblock_convert_from_vertcos(struct Object *ob, struct KeyBlock
*kb, float (*vertCos)[3]);
+ float (*BKE_keyblock_convert_to_vertcos(struct Object *ob, struct KeyBlock
*kb))[3];
+
+ void BKE_keyblock_update_from_offset(struct Object *ob, struct KeyBlock
*kb, float (*ofs)[3]);
+
++void BKE_keyblock_convert_to_hair_keys(struct KeyBlock *kb, struct Object
*ob, struct ParticleSystem *psys);
++void BKE_keyblock_convert_from_hair_keys(struct Object *ob, struct
ParticleSystem *psys, struct KeyBlock *kb);
+
/* other management */
bool BKE_keyblock_move(struct Object *ob, int org_index, int new_index);
diff --cc source/blender/blenkernel/intern/key.c
index 479444c,3ba0c6e..5b1aa63
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@@ -1168,7 -1122,7 +1168,7 @@@ static float *get_object_weights_array(
return NULL;
}
- float **BKE_key_get_per_block_object_weights(Object *ob, Key *key,
WeightsArrayCache *cache)
-float **BKE_keyblock_get_per_block_weights(Object *ob, Key *key,
WeightsArrayCache *cache)
++float **BKE_keyblock_get_per_block_object_weights(Object *ob, Key *key,
WeightsArrayCache *cache)
{
KeyBlock *keyblock;
float **per_keyblock_weights;
@@@ -1182,40 -1136,7 +1182,40 @@@
keyblock;
keyblock = keyblock->next, keyblock_index++)
{
- per_keyblock_weights[keyblock_index] = get_weights_array(ob,
keyblock->vgroup, cache);
+ per_keyblock_weights[keyblock_index] =
get_object_weights_array(ob, keyblock->vgroup, cache);
+ }
+
+ return per_keyblock_weights;
+}
+
+static float *get_particle_weights_array(ParticleSystem *UNUSED(psys), char
*vgroup, WeightsArrayCache *UNUSED(cache))
+{
+// MDeformVert *dvert = NULL;
+// int totvert = 0, defgrp_index = 0;
+
+ /* no vgroup string set? */
+ if (vgroup[0] == 0) return NULL;
+
+ // XXX TODO
+
+ return NULL;
+}
+
- float **BKE_key_get_per_block_particle_weights(ParticleSystem *psys, Key
*key, WeightsArrayCache *cache)
++float **BKE_keyblock_get_per_block_particle_weights(ParticleSystem *psys, Key
*key, WeightsArrayCache *cache)
+{
+ KeyBlock *keyblock;
+ float **per_keyblock_weights;
+ int keyblock_index;
+
+ per_keyblock_weights =
+ MEM_mallocN(sizeof(*per_keyblock_weights) * key->totkey,
+ "per keyblock weights");
+
+ for (keyblock = key->block.first, keyblock_index = 0;
+ keyblock;
+ keyblock = keyblock->next, keyblock_index++)
+ {
+ per_keyblock_weights[keyblock_index] =
get_particle_weights_array(psys, keyblock->vgroup, cache);
}
return per_keyblock_weights;
@@@ -1281,7 -1202,7 +1281,7 @@@ static void do_mesh_key(Scene *scene, O
if (key->type == KEY_RELATIVE) {
WeightsArrayCache cache = {0, NULL};
float **per_keyblock_weights;
- per_keyblock_weights =
BKE_key_get_per_block_object_weights(ob, key, &cache);
- per_keyblock_weights =
BKE_keyblock_get_per_block_weights(ob, key, &cache);
++ per_keyblock_weights =
BKE_keyblock_get_per_block_object_weights(ob, key, &cache);
BKE_key_evaluate_relative(0, tot, tot, (char *)out,
key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
BKE_keyblock_free_per_block_weights(key,
per_keyblock_weights, &cache);
}
@@@ -1445,7 -1366,7 +1445,7 @@@ static void do_latt_key(Scene *scene, O
else {
if (key->type == KEY_RELATIVE) {
float **per_keyblock_weights;
- per_keyblock_weights =
BKE_key_get_per_block_object_weights(ob, key, NULL);
- per_keyblock_weights =
BKE_keyblock_get_per_block_weights(ob, key, NULL);
++ per_keyblock_weights =
BKE_keyblock_get_per_block_object_weights(ob, key, NULL);
BKE_key_evaluate_relative(0, tot, tot, (char *)out,
key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
BKE_keyblock_free_per_block_weights(key,
per_keyblock_weights, NULL);
}
@@@ -1464,32 -1385,6 +1464,32 @@@
if (lt->flag & LT_OUTSIDE) outside_lattice(lt);
}
+static void do_psys_key(ParticleSystem *psys, Key *key, char *out, const int
tot)
+{
+ KeyBlock *k[4], *actkb = BKE_keyblock_from_particles(psys);
+ float t[4];
+ int flag = 0;
+
+ if (key->type == KEY_RELATIVE) {
+ WeightsArrayCache cache = {0, NULL};
+ float **per_keyblock_weights;
+
- per_keyblock_weights =
BKE_key_get_per_block_particle_weights(psys, key, &cache);
++ per_keyblock_weights =
BKE_keyblock_get_per_block_particle_weights(psys, key, &cache);
+ BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb,
per_keyblock_weights, KEY_MODE_DUMMY);
+ BKE_keyblock_free_per_block_weights(key, per_keyblock_weights,
&cache);
+ }
+ else {
+ const float ctime_scaled = key->ctime / 100.0f;
+
+ flag = setkeys(ctime_scaled, &key->block, k, t, 0);
+
+ if (flag == 0)
+ do_key(0, tot, tot, (char *)out, key, actkb, k, t,
KEY_MODE_DUMMY);
+ else
+ cp_key(0, tot, tot, (char *)out, key, actkb, k[2],
NULL, KEY_MODE_DUMMY);
+ }
+}
+
/* returns key coordinates (+ tilt) when key applied, NULL otherwise */
float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
float *arr, size_t arr_size)
@@@ -2256,48 -2042,6 +2242,48 @@@ void BKE_keyblock_update_from_offset(Ob
}
}
+/************************* Mesh ************************/
+
- void BKE_key_convert_to_hair_keys(struct KeyBlock *kb, struct Object
*UNUSED(ob), struct ParticleSystem *psys)
++void BKE_keyblock_convert_to_hair_keys(struct KeyBlock *kb, struct Object
*UNUSED(ob), struct ParticleSystem *psys)
+{
+ ParticleData *pa;
+ HairKey *hkey;
+ float *fp;
+ int i, k;
+
+ fp = kb->data;
+ for (i = 0, pa = psys->particles; i < psys->totpart; ++i, ++pa) {
+ for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, ++hkey) {
+ copy_v3_v3(hkey->co, fp);
+ fp += 3;
+ }
+ }
+}
+
- void BKE_key_convert_from_hair_keys(struct Object *UNUSED(ob), struct
ParticleSystem *psys, struct KeyBlock *kb)
++void BKE_keyblock_convert_from_hair_keys(struct Object *UNUSED(ob), struct
ParticleSystem *psys, struct KeyBlock *kb)
+{
+ ParticleData *pa;
+ HairKey *hkey;
+ float *fp;
+ int i, k;
+
+ if (kb->data) MEM_freeN(kb->data);
+
+ kb->totelem = 0;
+ for (i = 0, pa = psys->particles; i < psys->totpart; ++i, ++pa) {
+ kb->totelem += pa->totkey;
+ }
+ kb->data = MEM_mallocN(psys->key->elemsize * kb->totelem, "kb->data");
+
+ fp = kb->data;
+ for (i = 0, pa = psys->particles; i < psys->totpart; ++i, ++pa) {
+ for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, ++hkey) {
+ copy_v3_v3(fp, hkey->co);
+ fp += 3;
+ }
+ }
+}
+
/* ==========================================================*/
/** Move shape key from org_index to new_index. Safe, clamps index to valid
range, updates reference keys,
diff --cc source/blender/blenkernel/intern/particle.c
index e3f4cf1,bfb7802..0b7aaf7
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@@ -359,34 -358,6 +359,3
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs