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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-04-14 21:06:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-14 21:06:55 +0400
commit3ac68d7975a963261bbd13687c31655f2ce72666 (patch)
treefb1af0ee63960ee7c330388baddb5ab62f2ed345 /source
parentd9c249785982475bc86cdcd3d61a3bfe5422338a (diff)
no functional change, avoid making stack arrays for the purpose of indexing.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 40365a2198f..4a33bbdcd4a 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2513,9 +2513,8 @@ static void GetPosition(const SMikkTSpaceContext * pContext, float fPos[], const
{
//assert(vert_index>=0 && vert_index<4);
SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
- unsigned int indices[] = { pMesh->mface[face_num].v1, pMesh->mface[face_num].v2,
- pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 };
- VECCOPY(fPos, pMesh->mvert[indices[vert_index]].co);
+ const float *co= pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].co;
+ VECCOPY(fPos, co);
}
static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[], const int face_num, const int vert_index)
@@ -2528,12 +2527,9 @@ static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[
float * uv = pMesh->mtface[face_num].uv[vert_index];
fUV[0]=uv[0]; fUV[1]=uv[1];
}
- else
- {
- unsigned int indices[] = { pMesh->mface[face_num].v1, pMesh->mface[face_num].v2,
- pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 };
-
- map_to_sphere( &fUV[0], &fUV[1],pMesh->orco[indices[vert_index]][0], pMesh->orco[indices[vert_index]][1], pMesh->orco[indices[vert_index]][2]);
+ else {
+ const float *orco= pMesh->orco[(&pMesh->mface[face_num].v1)[vert_index]];
+ map_to_sphere( &fUV[0], &fUV[1], orco[0], orco[1], orco[2]);
}
}
@@ -2541,36 +2537,30 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
{
//assert(vert_index>=0 && vert_index<4);
SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
- unsigned int indices[] = { pMesh->mface[face_num].v1, pMesh->mface[face_num].v2,
- pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 };
const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH);
if(!smoothnormal) // flat
{
- if(pMesh->precomputedFaceNormals)
- {
+ if(pMesh->precomputedFaceNormals) {
VECCOPY(fNorm, &pMesh->precomputedFaceNormals[3*face_num]);
}
- else
- {
- float nor[3];
- float * p0, * p1, * p2;
- const int iGetNrVerts = pMesh->mface[face_num].v4!=0 ? 4 : 3;
- p0 = pMesh->mvert[indices[0]].co; p1 = pMesh->mvert[indices[1]].co; p2 = pMesh->mvert[indices[2]].co;
- if(iGetNrVerts==4)
- {
- float * p3 = pMesh->mvert[indices[3]].co;
- normal_quad_v3( nor, p0, p1, p2, p3);
+ else {
+ MFace *mf= &pMesh->mface[face_num];
+ float *p0= pMesh->mvert[mf->v1].co;
+ float *p1= pMesh->mvert[mf->v2].co;
+ float *p2= pMesh->mvert[mf->v3].co;
+
+ if(mf->v4) {
+ float *p3 = pMesh->mvert[mf->v4].co;
+ normal_quad_v3(fNorm, p0, p1, p2, p3);
}
else {
- normal_tri_v3(nor, p0, p1, p2);
+ normal_tri_v3(fNorm, p0, p1, p2);
}
- VECCOPY(fNorm, nor);
}
}
- else
- {
- short *no = pMesh->mvert[indices[vert_index]].no;
+ else {
+ const short *no= pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].no;
normal_short_to_float_v3(fNorm, no);
normalize_v3(fNorm); /* XXX, is this needed */
}