Updated win32 project.

Fixed allocation of rcRegions, use placement new per array object, not for the whole array.
This commit is contained in:
Mikko Mononen 2010-07-09 13:25:28 +00:00
parent cd3a351f40
commit 377315641e
3 changed files with 21 additions and 4 deletions

View File

@ -438,7 +438,7 @@ static unsigned short* expandRegions(int maxIter, unsigned short level,
struct rcRegion
{
inline rcRegion() : count(0), id(0), area(0), remap(false) {}
inline rcRegion(unsigned short i) : count(0), id(i), area(0), remap(false) {}
int count;
unsigned short id;
@ -697,16 +697,17 @@ static bool filterSmallRegions(int minRegionSize, int mergeRegionSize,
const int h = chf.height;
const int nreg = maxRegionId+1;
rcRegion* regions = new(rcAlloc(sizeof(rcRegion)*nreg, RC_ALLOC_TEMP)) rcRegion[nreg];
rcRegion* regions = (rcRegion*)rcAlloc(sizeof(rcRegion)*nreg, RC_ALLOC_TEMP);
if (!regions)
{
if (rcGetLog())
rcGetLog()->log(RC_LOG_ERROR, "filterSmallRegions: Out of memory 'regions' (%d).", nreg);
return false;
}
// Construct regions
for (int i = 0; i < nreg; ++i)
regions[i].id = (unsigned short)i;
new(&regions[i]) rcRegion((unsigned short)i);
// Find edge of a region and find connections around the contour.
for (int y = 0; y < h; ++y)

Binary file not shown.

View File

@ -187,6 +187,10 @@
RelativePath="..\..\..\Recast\Include\Recast.h"
>
</File>
<File
RelativePath="..\..\..\Recast\Include\RecastAlloc.h"
>
</File>
<File
RelativePath="..\..\..\Recast\Include\RecastLog.h"
>
@ -203,6 +207,10 @@
RelativePath="..\..\..\Recast\Source\Recast.cpp"
>
</File>
<File
RelativePath="..\..\..\Recast\Source\RecastAlloc.cpp"
>
</File>
<File
RelativePath="..\..\..\Recast\Source\RecastArea.cpp"
>
@ -247,6 +255,10 @@
<Filter
Name="Include"
>
<File
RelativePath="..\..\..\Detour\Include\DetourAlloc.h"
>
</File>
<File
RelativePath="..\..\..\Detour\Include\DetourCommon.h"
>
@ -267,6 +279,10 @@
<Filter
Name="Source"
>
<File
RelativePath="..\..\..\Detour\Source\DetourAlloc.cpp"
>
</File>
<File
RelativePath="..\..\..\Detour\Source\DetourCommon.cpp"
>