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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-05-15 16:18:35 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-05-15 16:20:22 +0400
commit3889483b1fa23911e58cff4d7d195d16e83760b0 (patch)
tree0a65f317bd979863e14ebe2431b577b0c8e9527d /source/blender/modifiers
parent4725941f2338e1b2a919f1dafd00ff283a47766a (diff)
Fix T40053: Cloth simulation, rest shape key does not function
It was a regression since 5d49eff. Not really sure about proper solution here, so used a bit workaround-ish way for now. Hopefully new cloth will be landed after this GSoC anyway.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 6bda8210f81..1561fd1a981 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -32,8 +32,10 @@
* \ingroup modifiers
*/
+#include <string.h>
#include "DNA_cloth_types.h"
+#include "DNA_key_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -45,6 +47,7 @@
#include "BKE_cloth.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
+#include "BKE_key.h"
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
@@ -68,7 +71,7 @@ static void initData(ModifierData *md)
}
static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
- int UNUSED(numVerts), ModifierApplyFlag UNUSED(flag))
+ int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm;
ClothModifierData *clmd = (ClothModifierData *) md;
@@ -85,6 +88,26 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
if (dm == derivedData)
dm = CDDM_copy(dm);
+ /* TODO(sergey): For now it actually duplicates logic from DerivedMesh.c
+ * and needs some more generic solution. But starting experimenting with
+ * this so close to the release is not that nice..
+ *
+ * Also hopefully new cloth system will arrive soon..
+ */
+ if (derivedData == NULL && clmd->sim_parms->shapekey_rest) {
+ KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ob),
+ clmd->sim_parms->shapekey_rest);
+ if (kb->data != NULL) {
+ float (*layerorco)[3];
+ if (!(layerorco = DM_get_vert_data_layer(dm, CD_CLOTH_ORCO))) {
+ DM_add_vert_layer(dm, CD_CLOTH_ORCO, CD_CALLOC, NULL);
+ layerorco = DM_get_vert_data_layer(dm, CD_CLOTH_ORCO);
+ }
+
+ memcpy(layerorco, kb->data, sizeof(float) * 3 * numVerts);
+ }
+ }
+
CDDM_apply_vert_coords(dm, vertexCos);
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */