diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-01-27 01:31:14 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-01-27 01:31:14 +0300 |
commit | 5270280a65ccf06a8cbe72b79edf8c8621b059f7 (patch) | |
tree | 48589ec2d848c32581cabe4005e8da72ece812c6 /source/blender/makesrna/intern/rna_mesh.c | |
parent | e46895811e4c9a4206090bccadd9cd1fd98971aa (diff) |
Bullet-proofing mesh vertex group RNA wrapping, after double checking
on whether vertexgroup weight animation worked
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 08065b90530..6760000c702 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -961,10 +961,29 @@ static char *rna_VertexGroupElement_path(PointerRNA *ptr) MDeformVert *dvert; int a, b; - for(a=0, dvert=me->dvert; a<me->totvert; a++, dvert++) - for(b=0; b<dvert->totweight; b++) + /* sanity check: make sure that mesh pointer is valid */ + if (me == NULL) + return NULL; + else if (GS(me->id.name) != ID_ME) { + /* if object pointer, try to resolve the object's data to mesh pointer */ + if (GS(me->id.name) == ID_OB) { + Object *ob = (Object *)me; + + if (ob->type == OB_MESH) + me = (Mesh *)ob->data; + else + return NULL; /* nothing can be done */ + } + else + return NULL; /* nothing can be done */ + } + + for(a=0, dvert=me->dvert; a<me->totvert; a++, dvert++) { + for(b=0; b<dvert->totweight; b++) { if(dw == &dvert->dw[b]) return BLI_sprintfN("vertices[%d].groups[%d]", a, b); + } + } return NULL; } |