Game Development Community

BUG FIX: GFXDevice::drawWireCube()

by David Wyand · in Torque Game Engine Advanced · 09/28/2004 (8:05 pm) · 0 replies

Greetings!

I've already sent this one in to the boys, but thought I'd post it here in case it's biting someone.

The GFXDevice::drawWireCube() method is quite handy for drawing cubes for debugging. In fact it's so useful, the ShapeBase class' renderObject() method makes use of it. Unfortunately there's a minor bug that creates a disaster.

Go to gfxDevice.cpp and find the GFXDevice::drawWireCube() method. Change the code as follows (changes in bold):

// setup 6 line loops
   U32 vertexIndex = 0;
   for(int i = 0; i < 6; i++)
   {
      for(int j = 0; j < 5; j++)
      {
         int idx = cubeFaces[i][j%4];
 
         verts[vertexIndex].point = cubePoints[idx] * size + pos;
         verts[vertexIndex].color = color;
         [b]++vertexIndex[/b];
      }
   }

In case it's not obvious, there's two little '++' added to the vertIndex variable. Without that, your cube will draw in random lines all over the place, making you think there's something wrong with your own code. Not that that happened to me or anything. No way! :o)

- LightWave Dave

About the author

A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!