diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-10 11:21:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-10 11:21:42 +0400 |
commit | 2de1bd7dc568d30edd8656cb221720dc0d881f4f (patch) | |
tree | bf6a1d8c4fbeeae07a3a938dcb7bdfd80d3b76cb /source/blender/blenkernel | |
parent | 70cd4b77bb3ed0fc3f2498421f9452eb1408d8c2 (diff) |
updates to navmesh
- 2 new navmesh operators, reset and clear navmesh data.
- rename operators to be more consistent with existing names.
- some minor edits to draw function, was getting the custom data for every index when it already had the array.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 53973608cd6..bc6492f92ae 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2970,7 +2970,7 @@ BM_INLINE int navmesh_bit(int a, int b) return (a & (1 << b)) >> b; } -static void navmesh_intToCol(int i, float* col) +BM_INLINE void navmesh_intToCol(int i, float col[3]) { int r = navmesh_bit(i, 0) + navmesh_bit(i, 3) * 2 + 1; int g = navmesh_bit(i, 1) + navmesh_bit(i, 4) * 2 + 1; @@ -2985,8 +2985,7 @@ static void navmesh_drawColored(DerivedMesh *dm) int a, glmode; MVert *mvert = (MVert *)CustomData_get_layer(&dm->vertData, CD_MVERT); MFace *mface = (MFace *)CustomData_get_layer(&dm->faceData, CD_MFACE); - int* polygonIdx = (int*)CustomData_get_layer(&dm->faceData, CD_RECAST); - const float BLACK_COLOR[3] = {0.f, 0.f, 0.f}; + int *polygonIdx = (int *)CustomData_get_layer(&dm->faceData, CD_RECAST); float col[3]; if (!polygonIdx) @@ -3007,11 +3006,13 @@ static void navmesh_drawColored(DerivedMesh *dm) glBegin(glmode = GL_QUADS); for(a = 0; a < dm->numFaceData; a++, mface++) { int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; - int polygonIdx = *(int*)CustomData_get(&dm->faceData, a, CD_RECAST); - if (polygonIdx<=0) - memcpy(col, BLACK_COLOR, 3*sizeof(float)); - else - navmesh_intToCol(polygonIdx, col); + int pi = polygonIdx[a]; + if (pi <= 0) { + zero_v3(col); + } + else { + navmesh_intToCol(pi, col); + } if(new_glmode != glmode) { glEnd(); |