Game Development Community

dev|Pro Game Development Curriculum

small bugfix for ShapeBase::wireCube

by Orion Elenzil · 07/07/2008 (9:52 am) · 3 comments

the first face drawn by ShapeBase::wireCube() has opposite winding than the other five faces.

ordinarily this doesn't matter, since face-culling is disabled in ShapeBase::wireCube,
but if you should happen to enable it, one of your faces will be backwards.

the fix.

shapeBase.cc
change this:
static U32 cubeFaces[6][4] = {
   { 0, 2, 6, 4 }, { 0, 2, 3, 1 }, { 0, 1, 5, 4 },
   { 3, 2, 6, 7 }, { 7, 6, 4, 5 }, { 3, 7, 5, 1 }
};
to this:
static U32 cubeFaces[6][4] = {
   [b]{ 0, 4, 6, 2 }[/b], { 0, 2, 3, 1 }, { 0, 1, 5, 4 },
   { 3, 2, 6, 7 }, { 7, 6, 4, 5 }, { 3, 7, 5, 1 }
};

#1
07/11/2008 (2:01 pm)
Huh. Good catch... how did you even notice this? =)
#2
07/11/2008 (2:25 pm)
heh.
i was looking at some ways to indicate object selection,
so was using this routine to draw some wire cubes with frontface-culling enabled.
#3
07/14/2008 (8:29 pm)
Ah, got it.