swordlegend / recastnavigation

Automatically exported from code.google.com/p/recastnavigation
zlib License
0 stars 0 forks source link

RecastMeshDetail.cpp:buildPolyDetail: Uneeded line of code. #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This issue does not impact functionality.  It appears to just be an extra
unneeded calculation.

File: RecastMeshDetail.cpp (Revision: 76)
Operation: buildPolyDetail

Note that in the below code pos[1] is assigned twice with the second
assignment overwriting the first assignment.  

I checked the getHeight() operation and it does not use the value at
pos[1].  So it does not build on the previously assigned value.

for (int k = 0; k <= nn; ++k)
{
    float u = (float)k/(float)nn;
    float* pos = &edge[k*3];
    pos[0] = vj[0] + dx*u;
    pos[1] = vj[1] + dy*u;   <- Line can just be removed?
    pos[2] = vj[2] + dz*u;
    pos[1] = chf.bmin[1] + getHeight(pos, chf.bmin, cs, ics, hp)*chf.ch;
}

Original issue reported on code.google.com by steve...@gmail.com on 26 Nov 2009 at 7:13

GoogleCodeExporter commented 9 years ago
Sorry, the pasted code was from an earlier revision.  Revision 76 code is 
actually:

for (int k = 0; k <= nn; ++k)
{
    float u = (float)k/(float)nn;
    float* pos = &edge[k*3];
    pos[0] = vj[0] + dx*u;
    pos[1] = vj[1] + dy*u;
    pos[2] = vj[2] + dz*u;
    pos[1] = getHeight(pos, cs, ics, hp)*chf.ch;
}

Original comment by steve...@gmail.com on 26 Nov 2009 at 7:20

GoogleCodeExporter commented 9 years ago
Another note.

If the "pos[1] = vj[1] + dy*u;" line of code is removed, then the dy variable 
can
also be removed since it is only used in this single location.

Original comment by steve...@gmail.com on 26 Nov 2009 at 7:30

GoogleCodeExporter commented 9 years ago
Fixed in R82. I also changed the function so that only the required components 
are
passed.

Original comment by memono...@gmail.com on 7 Dec 2009 at 9:48