I opted for similar method that is used by other open source libraries such as Bullet Physics or Box 2D. I initially wanted to use an interface which would be passed to each of the allocation functions, but the implementation became really ugly and confusing for those who don't care about it.
If you have a strong case why it should not be handled that way and have good example how to do it better (or pointer to some lib which does it great) let me know.
Thanks to Cameron Hart for initial patch and discussion.
I really don't like how C++ handles memory allocation. It is so half heartedly build into the language. Even the standard library has its' own way of circumventing it.
I'm planning to give the same treatment to Recast too soon.
[EDIT] Added similar support for Recast in R177.
NOTE: From now on the Recast objects (i.e. rcHeightField, rcPolyMesh etc) are required to be allocated and freed using special functions (rcAllocHeightfield() and rcFreeHeightField() respectively). The samples are up to date, in case of confusion check them out.
google 3481
ReplyDeletegoogle 3482
google 3483
google 3484