[pythian] Cal3D

  • From: mike@xxxxxxxxxxxxx
  • To: pythian@xxxxxxxxxxxxx
  • Date: Fri, 12 Jul 2002 06:54:21 -0500

OK, well I was just investigating what's up with Cal3D. In desperation (this 
isn't an easy one), I poked around inside Cal3D using the CPU 
window/disassembler. Anyway, I found something a bit strange, and need help to 
figure out what it is. In the CreateInstance method, where it calls 
Renderer.GetVertices(), the code it jumps to does not appear to resemble the 
original C++.

For instance, it makes calls to methods that are not referenced in the 
original. Looking at the method above it (in memory) which is 
GetVerticeCount(), I see it has only 2 instructions, one of which jumps to an 
apparently unrelated method.

Firstly, could somebody try and dupe this please? In the 
TSkeletalModel.CreateInstance method, you'll see some assertions, one of which 
is testing that Rendere.GetVertices returns > 0. Oh, one thing, I haven't 
committed this as I've played around with the code a bit, but you need to add a 
call to Renderer_BeginRendering() and then the equivalent EndRendering() call 
to get Cal3D ready for the call (it was missed out of the original in cvs). 
Then set a breakpoint on this line (remove the assertion first) and step into 
it with the CPU window, and see if you can see what I see.

There could be a number of reasons for this:

1) I didn't compile cal3d.dll, another guy did. He may have used a different 
version of the C++ than I am referring to. Below is the relevant part of the 
source.

2) The disassembler is getting it wrong. Is this possible? I assume that if the 
disassembler says "this is where the method starts" it is correct, but as these 
methods are late-bound could it be that somehow the method pointers are getting 
corrupted and no longer pointing to the right method (but the disassembler has 
no way of knowing)

3) I'm not understanding what I'm reading - I'm no expert is mental reverse 
compilation.

Any ideas?
thanks -mike

----------------------------

int CalRenderer::getVertexCount()
{
  return m_pSelectedSubmesh->getVertexCount();
}

int CalRenderer::getVertices(float *pVertexBuffer)
{
  // check if the submesh handles vertex data internally
  if(m_pSelectedSubmesh->hasInternalData())
  {
    // get the vertex vector of the submesh
    std::vector<CalVector>& vectorVertex = 
m_pSelectedSubmesh->getVectorVertex();


    // get the number of vertices in the submesh
    int vertexCount;
    vertexCount = m_pSelectedSubmesh->getVertexCount();

    // copy the internal vertex data to the provided vertex buffer
    memcpy(pVertexBuffer, &vectorVertex[0], vertexCount * sizeof(CalVector));

    return vertexCount;
  }



  // submesh does not handle the vertex data internally, so let the physique 
calculate it now
  return m_pModel->getPhysique()->calculateVertices(m_pSelectedSubmesh, 
pVertexBuffer);
}


Other related posts: