[Bf-blender-cvs] [c7e85ca] gooseberry: Merge branch 'master' into gooseberry
Lukas Tönne
noreply at git.blender.org
Wed Oct 22 11:25:50 CEST 2014
Commit: c7e85ca92ce4d4966039ebf41ce7400b0326f86e
Author: Lukas Tönne
Date: Wed Oct 22 11:20:43 2014 +0200
Branches: gooseberry
https://developer.blender.org/rBc7e85ca92ce4d4966039ebf41ce7400b0326f86e
Merge branch 'master' into gooseberry
Conflicts:
source/blender/blenkernel/intern/key.c
source/blender/blenloader/intern/versioning_270.c
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_key.h
index 4b3d582,892c42b..142245b
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@@ -107,9 -96,11 +107,13 @@@ void BKE_key_convert_from_curve(stru
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);
+ /* other management */
+ bool BKE_keyblock_move(struct Object *ob, int org_index, int new_index);
+
+
/* key.c */
extern int slurph_opt;
diff --cc source/blender/blenkernel/intern/key.c
index 62310c3,69b375f..ee27108
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@@ -2256,44 -2056,90 +2256,132 @@@ void BKE_key_convert_from_offset(Objec
}
}
+/************************* Mesh ************************/
+
+void BKE_key_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)
+{
+ 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,
+ * the object's active shape index, the 'frame' value in case of absolute keys, etc.
+ * Note indices are expected in real values (not 'fake' shapenr +1 ones).
+ *
+ * \param org_index if < 0, current object's active shape will be used as skey to move.
+ * \return true if something was done, else false.
+ */
+ bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
+ {
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb;
+ const int act_index = ob->shapenr - 1;
+ const int totkey = key->totkey;
+ int i;
+ bool rev, in_range = false;
+
+ if (org_index < 0) {
+ org_index = act_index;
+ }
+
+ CLAMP(new_index, 0, key->totkey - 1);
+ CLAMP(org_index, 0, key->totkey - 1);
+
+ if (new_index == org_index) {
+ return false;
+ }
+
+ rev = ((new_index - org_index) < 0) ? true : false;
+
+ /* We swap 'org' element with its previous/next neighbor (depending on direction of the move) repeatedly,
+ * until we reach final position.
+ * This allows us to only loop on the list once! */
+ for (kb = (rev ? key->block.last : key->block.first), i = (rev ? totkey - 1 : 0);
+ kb;
+ kb = (rev ? kb->prev : kb->next), rev ? i-- : i++)
+ {
+ if (i == org_index) {
+ in_range = true; /* Start list items swapping... */
+ }
+ else if (i == new_index) {
+ in_range = false; /* End list items swapping. */
+ }
+
+ if (in_range) {
+ KeyBlock *other_kb = rev ? kb->prev : kb->next;
+
+ /* Swap with previous/next list item. */
+ BLI_listbase_swaplinks(&key->block, kb, other_kb);
+
+ /* Swap absolute positions. */
+ SWAP(float, kb->pos, other_kb->pos);
+
+ kb = other_kb;
+ }
+
+ /* Adjust relative indices, this has to be done on the whole list! */
+ if (kb->relative == org_index) {
+ kb->relative = new_index;
+ }
+ else if (kb->relative < org_index && kb->relative >= new_index) {
+ /* remove after, insert before this index */
+ kb->relative++;
+ }
+ else if (kb->relative > org_index && kb->relative <= new_index) {
+ /* remove before, insert after this index */
+ kb->relative--;
+ }
+ }
+
+ /* Need to update active shape number if it's affected, same principle as for relative indices above. */
+ if (org_index == act_index) {
+ ob->shapenr = new_index + 1;
+ }
+ else if (act_index < org_index && act_index >= new_index) {
+ ob->shapenr++;
+ }
+ else if (act_index > org_index && act_index <= new_index) {
+ ob->shapenr--;
+ }
+
+ /* First key is always refkey, matches interface and BKE_key_sort */
+ key->refkey = key->block.first;
+
+ return true;
+ }
diff --cc source/blender/blenloader/intern/versioning_270.c
index 6e7ebe8,bd1b5f2..57649f5
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@@ -408,50 -419,20 +421,67 @@@ void blo_do_versions_270(FileData *fd,
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
+ Object *ob;
+
+ /* Update Transform constraint (again :|). */
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ do_version_constraints_stretch_to_limits(&ob->constraints);
+
+ if (ob->pose) {
+ /* Bones constraints! */
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_stretch_to_limits(&pchan->constraints);
+ }
+ }
+ }
+ }
++
+ if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "int", "voxel_res")) {
+ Object *ob;
+ ModifierData *md;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData*) md;
+ clmd->sim_parms->voxel_res = 32;
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *pmd = (ParticleSystemModifierData*) md;
+ if (pmd->psys->clmd) {
+ pmd->psys->clmd->sim_parms->voxel_res = 32;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
+ Object *ob;
+ ModifierData *md;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData*) md;
+ clmd->sim_parms->bending_damping = 0.5f;
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *pmd = (ParticleSystemModifierData*) md;
+ if (pmd->psys->clmd) {
+ pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ParticleSystem", "float", "hair_preview_factor")) {
+ Object *ob;
+ ParticleSystem *psys;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ for(psys = ob->particlesystem.first; psys; psys = psys->next)
+ psys->hair_preview_factor = 100.0f;
+ }
+ }
}
More information about the Bf-blender-cvs
mailing list