[Bf-blender-cvs] [3889483] master: Fix T40053: Cloth simulation, rest shape key does not function
Sergey Sharybin
noreply at git.blender.org
Thu May 15 14:20:44 CEST 2014
Commit: 3889483b1fa23911e58cff4d7d195d16e83760b0
Author: Sergey Sharybin
Date: Thu May 15 14:18:35 2014 +0200
https://developer.blender.org/rB3889483b1fa23911e58cff4d7d195d16e83760b0
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.
===================================================================
M source/blender/modifiers/intern/MOD_cloth.c
===================================================================
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 6bda821..1561fd1 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 */
More information about the Bf-blender-cvs
mailing list