a place to cache draw data in DerivedMesh
DerivedMesh owns this cache and cleans up as part of DM cleanup. DM has no idea what is stored in this cache. Loose coupling FTW
This commit is contained in:
@@ -258,6 +258,12 @@ static CustomData *dm_getPolyCData(DerivedMesh *dm)
|
||||
return &dm->polyData;
|
||||
}
|
||||
|
||||
static DMCleanupBatchCache cleanupBatchCache = NULL;
|
||||
void DM_set_batch_cleanup_callback(DMCleanupBatchCache func)
|
||||
{
|
||||
cleanupBatchCache = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to initialize a DerivedMesh's function pointers to
|
||||
* the default implementation (for those functions which have a default)
|
||||
@@ -315,7 +321,9 @@ void DM_init(
|
||||
dm->numPolyData = numPolys;
|
||||
|
||||
DM_init_funcs(dm);
|
||||
|
||||
|
||||
dm->batchCache = NULL; /* necessary? dm->drawObject is not set to NULL yet it works fine */
|
||||
|
||||
dm->needsFree = 1;
|
||||
dm->auto_bump_scale = -1.0f;
|
||||
dm->dirty = 0;
|
||||
@@ -375,6 +383,10 @@ int DM_release(DerivedMesh *dm)
|
||||
if (dm->needsFree) {
|
||||
bvhcache_free(&dm->bvhCache);
|
||||
GPU_drawobject_free(dm);
|
||||
if (dm->batchCache && cleanupBatchCache) {
|
||||
cleanupBatchCache(dm->batchCache);
|
||||
dm->batchCache = NULL;
|
||||
}
|
||||
CustomData_free(&dm->vertData, dm->numVertData);
|
||||
CustomData_free(&dm->edgeData, dm->numEdgeData);
|
||||
CustomData_free(&dm->faceData, dm->numTessFaceData);
|
||||
|
||||
Reference in New Issue
Block a user