Core: Replace StackAllocation by StackArray

This will cleanup alloca usage a little bit
This commit is contained in:
Lynix
2017-10-14 18:04:16 +02:00
parent 333a7903ff
commit 683b09144d
6 changed files with 236 additions and 51 deletions

View File

@@ -44,12 +44,11 @@ namespace Nz
{
//TODO: constexpr if to prevent copy/cast if sizeof(cpVect) == sizeof(Vector2f)
StackAllocation stackAlloc = NazaraStackAllocation(vertexCount * sizeof(Vector2f));
Vector2f* vec = static_cast<Vector2f*>(stackAlloc.GetPtr());
StackArray<Vector2f> vertices = NazaraStackAllocation(Vector2f, vertexCount);
for (int i = 0; i < vertexCount; ++i)
vec[i].Set(float(vertices[i].x), float(vertices[i].y));
vertices[i].Set(float(vertices[i].x), float(vertices[i].y));
drawOptions->polygonCallback(vec, vertexCount, float(radius), CpDebugColorToColor(outlineColor), CpDebugColorToColor(fillColor), drawOptions->userdata);
drawOptions->polygonCallback(vertices.data(), vertexCount, float(radius), CpDebugColorToColor(outlineColor), CpDebugColorToColor(fillColor), drawOptions->userdata);
}
};