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:
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r--source/blender/blenkernel/intern/mesh.c58
1 files changed, 12 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 1632f57c66e..07a1a5c5f44 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -78,45 +78,6 @@
#include "BLI_editVert.h"
#include "BLI_arithb.h"
-int update_realtime_texture(MTFace *tface, double time)
-{
- Image *ima;
- int inc = 0;
- float diff;
- int newframe;
-
- ima = tface->tpage;
-
- if (!ima)
- return 0;
-
- if (ima->lastupdate<0)
- ima->lastupdate = 0;
-
- if (ima->lastupdate>time)
- ima->lastupdate=(float)time;
-
- if(ima->tpageflag & IMA_TWINANIM) {
- if(ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima->yrep-1;
-
- /* check: is the bindcode not in the array? Then free. (still to do) */
-
- diff = (float)(time-ima->lastupdate);
-
- inc = (int)(diff*(float)ima->animspeed);
-
- ima->lastupdate+=((float)inc/(float)ima->animspeed);
-
- newframe = ima->lastframe+inc;
-
- if (newframe > (int)ima->twend)
- newframe = (int)ima->twsta-1 + (newframe-ima->twend)%(ima->twend-ima->twsta);
-
- ima->lastframe = newframe;
- }
- return inc;
-}
-
void mesh_update_customdata_pointers(Mesh *me)
{
me->mvert = CustomData_get_layer(&me->vdata, CD_MVERT);
@@ -526,7 +487,7 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve
/* rotates the vertices of a face in case v[2] or v[3] (vertex index) is = 0.
this is necessary to make the if(mface->v4) check for quads work */
-void test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
+int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
{
/* first test if the face is legal */
if(mface->v3 && mface->v3==mface->v4) {
@@ -568,6 +529,8 @@ void test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
CustomData_swap(fdata, mfindex, corner_indices);
}
}
+
+ return nr;
}
Mesh *get_mesh(Object *ob)
@@ -764,8 +727,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
mface->v4= index[3];
mface->flag= ME_SMOOTH;
- if(mface->v3==mface->v4)
- mface->v4= 0;
+ test_index_face(mface, NULL, 0, (mface->v3==mface->v4)? 3: 4);
mface++;
index+= 4;
@@ -1104,9 +1066,13 @@ float (*mesh_getRefKeyCos(Mesh *me, int *numVerts_r))[3]
if(me->key && me->key->refkey) {
if(numVerts_r) *numVerts_r= me->totvert;
- cos= MEM_mallocN(sizeof(*cos)*me->totvert, "vertexcos1");
-
+
kb= me->key->refkey;
+
+ /* prevent accessing invalid memory */
+ if (me->totvert > kb->totelem) cos= MEM_callocN(sizeof(*cos)*me->totvert, "vertexcos1");
+ else cos= MEM_mallocN(sizeof(*cos)*me->totvert, "vertexcos1");
+
totvert= MIN2(kb->totelem, me->totvert);
memcpy(cos, kb->data, sizeof(*cos)*totvert);
@@ -1136,12 +1102,12 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned
if(totuv==0)
return NULL;
- vmap= (UvVertMap*)MEM_mallocN(sizeof(*vmap), "UvVertMap");
+ vmap= (UvVertMap*)MEM_callocN(sizeof(*vmap), "UvVertMap");
if (!vmap)
return NULL;
vmap->vert= (UvMapVert**)MEM_callocN(sizeof(*vmap->vert)*totvert, "UvMapVert*");
- buf= vmap->buf= (UvMapVert*)MEM_mallocN(sizeof(*vmap->buf)*totuv, "UvMapVert");
+ buf= vmap->buf= (UvMapVert*)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvMapVert");
if (!vmap->vert || !vmap->buf) {
free_uv_vert_map(vmap);