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:
authorover0219 <over0219@umn.edu>2020-06-16 04:26:26 +0300
committerover0219 <over0219@umn.edu>2020-06-16 04:26:26 +0300
commit8cb56c1d745dd7efe042db22fd5f8da15da9087d (patch)
tree396cd58a319cdb08534ae67f11b08b9398899e75
parent5b09a54b41084857af4fc00426df9d1e0539e0bd (diff)
lattice appears working but will want to remove lattice cubes that do not contain mesh volume
-rw-r--r--intern/softbody/admmpd_api.cpp19
-rw-r--r--source/blender/blenkernel/intern/softbody.c18
2 files changed, 21 insertions, 16 deletions
diff --git a/intern/softbody/admmpd_api.cpp b/intern/softbody/admmpd_api.cpp
index f60097666c5..41bde09ee5f 100644
--- a/intern/softbody/admmpd_api.cpp
+++ b/intern/softbody/admmpd_api.cpp
@@ -165,7 +165,7 @@ int admmpd_init(ADMMPDInterfaceData *iface, float *in_verts, unsigned int *in_fa
gen_success = admmpd_init_with_lattice(iface,in_verts,in_faces,&V,&T);
break;
}
- if (!gen_success)
+ if (!gen_success || iface->totverts==0)
{
printf("**ADMMPD Failed to generate tets\n");
return 0;
@@ -224,6 +224,8 @@ void admmpd_copy_to_bodypoint_and_object(ADMMPDInterfaceData *iface, BodyPoint *
}
}
+ // If we're using TetGen, then we know the first
+ // n vertices of the tet mesh are the input surface mesh.
if (vertexCos != NULL && iface->init_mode==0 && i<iface->mesh_totverts)
{
vertexCos[i][0] = iface->data->data->x(i,0);
@@ -232,13 +234,18 @@ void admmpd_copy_to_bodypoint_and_object(ADMMPDInterfaceData *iface, BodyPoint *
}
} // end loop all verts
+ // If using lattice, get the embedded vertex position
+ // from the deformed lattice.
if (vertexCos != NULL && iface->init_mode==1)
{
-// Eigen::Vector3d xi = iface->data->lattice->get_mapped_vertex(
-// i, &iface->data->data->x, &iface->data->data->tets);
-// vertexCos[i][0] = xi[0];
-// vertexCos[i][1] = xi[1];
-// vertexCos[i][2] = xi[2];
+ for (int i=0; i<iface->mesh_totverts; ++i)
+ {
+ Eigen::Vector3d xi = iface->data->lattice->get_mapped_vertex(
+ i, &iface->data->data->x, &iface->data->data->tets);
+ vertexCos[i][0] = xi[0];
+ vertexCos[i][1] = xi[1];
+ vertexCos[i][2] = xi[2];
+ }
}
} // end map ADMMPD to bodypoint and object
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 38cb9f0db08..5d94e9014f3 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -940,7 +940,6 @@ static void free_softbody_intern(SoftBody *sb)
MEM_freeN(sb->bpoint);
sb->bpoint = NULL;
}
-
if (sb->bspring) {
MEM_freeN(sb->bspring);
}
@@ -3089,10 +3088,6 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
SoftBody *sb = ob->soft;
if (sb) {
int sb_totpt = sb->totpoint;
- if(sb_totpt < numVerts)
- {
- printf("\n\n\n\nsoftbody_to_object ERROR: BAD SIZE TOTPOINT\n\n\n\n\n");
- }
BodyPoint *bp = sb->bpoint;
int a;
@@ -3589,8 +3584,8 @@ static void init_admmpd_interface(Object *ob, float (*vertexCos)[3])
// Resize data
int totfaces = poly_to_tri_count(me->totpoly, me->totloop);
- unsigned int *in_faces = (unsigned int*)MEM_mallocN(sizeof(unsigned int)*totfaces*3, __func__);
- float *in_verts = (float*)MEM_mallocN(sizeof(float)*me->totvert*3, __func__);
+ unsigned int *in_faces = (unsigned int*)MEM_callocN(sizeof(unsigned int)*totfaces*3, __func__);
+ float *in_verts = (float*)MEM_callocN(sizeof(float)*me->totvert*3, __func__);
sb->admmpd->mesh_totverts = me->totvert;
sb->admmpd->mesh_totfaces = totfaces;
@@ -3609,7 +3604,7 @@ static void init_admmpd_interface(Object *ob, float (*vertexCos)[3])
// Initialize input faces
MLoopTri *looptri, *lt;
- looptri = lt = (MLoopTri *)MEM_mallocN(sizeof(*looptri)*totfaces, __func__);
+ looptri = lt = (MLoopTri *)MEM_callocN(sizeof(*looptri)*totfaces, __func__);
BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri);
for (int i=0; i<totfaces; ++i, ++lt)
{
@@ -3635,7 +3630,7 @@ static void init_admmpd_interface(Object *ob, float (*vertexCos)[3])
}
sb->totpoint = sb->admmpd->totverts;
sb->totspring = 0;
- sb->bpoint = MEM_mallocN(sb->totpoint * sizeof(BodyPoint), "bodypoint");
+ sb->bpoint = MEM_callocN(sb->totpoint * sizeof(BodyPoint), "bodypoint");
}
admmpd_copy_to_bodypoint_and_object(sb->admmpd,sb->bpoint,NULL);
@@ -3714,7 +3709,10 @@ void sbObjectStep_admmpd(
if (cache_result == PTCACHE_READ_EXACT ||
cache_result == PTCACHE_READ_INTERPOLATED ||
(!can_simulate && cache_result == PTCACHE_READ_OLD)) {
- softbody_to_object(ob, vertexCos, numVerts, sb->local);
+
+ admmpd_copy_from_bodypoint(sb->admmpd,sb->bpoint);
+ admmpd_copy_to_bodypoint_and_object(sb->admmpd,NULL,vertexCos);
+
BKE_ptcache_validate(cache, framenr);
if (cache_result == PTCACHE_READ_INTERPOLATED &&
cache->flag & PTCACHE_REDO_NEEDED &&