Skip to main content
GameDev.net gamedev.net
🔒 Locked

Chaos...

Started by Zeblar Nagrim Dec 4, 2001 at 6:06 AM 0 replies 350+ views
Original Post
Zeblar Nagrim
Zeblar Nagrim
In my dungeon editor I have a bunch of floor plate. When a new floor plate are created, either a new texture list are being made or a already created list get another floor plate...

//
// Create a new texture list if...
//
if(CRenderScene::TextureExist(p_pTexName)==false)
{
   CTexture l_tNewTex(p_pTexName);
   m_Textures.push_back(l_tNewTex);
}

//
// Get texture list from mesh...
//
CTextureList* l_pTextureList = &m_Meshes[wMeshNr].m_TextureList;
	
//
// Get a pointer to current start index from wallpart...
//
WORD *l_pwCurrStartIndex;
switch(m_Meshes[wMeshNr].GetID())
{
case MESHID_FLOOR:
  l_pwCurrStartIndex = &CApp::m_wCurrentFloorStartPoly;
  break;

case MESHID_ROOF:
  l_pwCurrStartIndex = &CApp::m_wCurrentRoofStartPoly;
  break;

case MESHID_WALL:
  l_pwCurrStartIndex = &CApp::m_wCurrentWallStartPoly;
  break;
}
		
//
// Add new data to texture list...
//
l_pTextureList->Insert(l_iTextureArrayNr, p_iStartVertex, p_iNumFaces, l_pwCurrStartIndex);

 
This works fine, this is not the problem. The problem is to remove dungeon squares and rebuild texture lists. I can´t figure out how to solve this problem. When the user use the eraser tool to remove squares inside a selection rectangle I remove those squares from a vector list, but then I must update my texture list also. The texture list holds information about how many faces to render with a texture and a offsetvalue into that vertexbuffer. I dont know... Maybe it´s better to have a big offset vector with integer numbers that represent every face connected to a texture and use DrawPrimitveIndexed? Zeblar Nagrim, Lord of Chaos
Fruny
Fruny
If you have a pointer from the plate back to the texture entry in the list, you can use it to decrement the reference count (how many plates use a given texture) and delete the entry when the texture count reaches zero.

Alternatively, you can move the entry to a "free" list for fast reallocation and possible reuse (undo?).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.