示例#1
0
static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
						DerivedMesh *dm,
						int UNUSED(useRenderParams),
						int UNUSED(isFinalCalc))
{
	ClothModifierData *clmd = (ClothModifierData*) md;
	DerivedMesh *result=NULL;
	
	/* check for alloc failing */
	if(!clmd->sim_parms || !clmd->coll_parms)
	{
		initData(md);
		
		if(!clmd->sim_parms || !clmd->coll_parms)
			return dm;
	}

	result = clothModifier_do(clmd, md->scene, ob, dm);

	if(result)
	{
		CDDM_calc_normals(result);
		return result;
	}
	return dm;
}
示例#2
0
static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
                        int UNUSED(numVerts), ModifierApplyFlag UNUSED(flag))
{
	DerivedMesh *dm;
	ClothModifierData *clmd = (ClothModifierData *) md;
	DerivedMesh *result = NULL;
	
	/* check for alloc failing */
	if (!clmd->sim_parms || !clmd->coll_parms) {
		initData(md);

		if (!clmd->sim_parms || !clmd->coll_parms)
			return;
	}

	dm = get_dm(ob, NULL, derivedData, NULL, 0);
	if (dm == derivedData)
		dm = CDDM_copy(dm);

	CDDM_apply_vert_coords(dm, vertexCos);

	DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */

	clothModifier_do(clmd, md->scene, ob, dm, vertexCos);

	if (result) {
		result->getVertCos(result, vertexCos);
		result->release(result);
	}

	dm->release(dm);
}
示例#3
0
static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
                        int numVerts, ModifierApplyFlag UNUSED(flag))
{
	DerivedMesh *dm;
	ClothModifierData *clmd = (ClothModifierData *) md;
	
	/* check for alloc failing */
	if (!clmd->sim_parms || !clmd->coll_parms) {
		initData(md);

		if (!clmd->sim_parms || !clmd->coll_parms)
			return;
	}

	dm = get_dm(ob, NULL, derivedData, NULL, false, false);
	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 && 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 */

	clothModifier_do(clmd, md->scene, ob, dm, vertexCos);

	dm->release(dm);
}