There's no array initializing in that code. There's some pointers and pointers to pointers passed as args that are being stored in members, and there's cleanup code to delete the arrays, but at least in that code they are never being created.
If it's created outside of the code, what's the lifetime? Passing in the face and vertex count as pointers to size_t then storing the pointers instead of dereferencing them to get the current values sounds dangerous (depending on the lifetime of the memory you are pointing to).
TerrainGroupData* terrainGroupData;
terrainGroupData = new TerrainGroupData(totalMeshes, 513)[totalMeshes];
That's is not how you initialize elements in C++. That's why. To fix your issue, and assuming that TerrainGroupData doesn't have a default constructor, you'll have to modify that piece of code like this:
TerrainGroupData** terrainGroupData; // Pointer-to-pointer of TerrainGroupData
terrainGroupData = new (TerrainGroupData*)[totalMeshes]; // Array of pointers to TerrainGroupData
for (size_t i = 0; i < totalMeshes; ++i)
{
terrainGroupData[i] = new TerrainGroupData(totalMeshes, 513);
}
This is if you don't like using STL containers. WIth STL containers and Ogre::SharedPtr classes you can make it something like:
typedef Ogre::SharedPtr<TerrainGroupData> TerrainGroupDataPtr;
typedef std::vector<TerrainGroupDataPtr> TerrainGroupDataArray;
TerrainGroupDataArray terrainGroupData;
terrainGroupData.resize(totalMeshes]; // This step can save you a lot of time and memory if totalMeshes is too big
for (size_t i = 0; i < totalMeshes; ++i)
{
terrainGroupData[i].bind(new TerrainGroupData(totalMeshes, 513));
}
// Access elements in terrainGroupData like so: terrainGroupData[i]->someFunction(arg1, arg2, arg3);
With the code above, you don't need to work about memory allocations or memory-leak.
Awesome, thanks. I ran into another problem with Havok crashing, so I need to review if I did something wrong with the data I'm giving. Thanks for your help though.