- fixed: overflow checks for dynamic light buffer were not correct.

This commit is contained in:
Christoph Oelckers 2014-10-23 12:06:00 +02:00
parent 066e53ae4c
commit 36b35e85f3
1 changed files with 8 additions and 1 deletions

View File

@ -132,7 +132,7 @@ int FLightBuffer::UploadLights(FDynLightData &data)
if (totalsize <= 1) return -1; if (totalsize <= 1) return -1;
if (mIndex + totalsize > mBufferSize) if (mIndex + totalsize > mBufferSize/4)
{ {
// reallocate the buffer with twice the size // reallocate the buffer with twice the size
unsigned int newbuffer; unsigned int newbuffer;
@ -173,6 +173,13 @@ int FLightBuffer::UploadLights(FDynLightData &data)
if (mBufferPointer == NULL) return -1; if (mBufferPointer == NULL) return -1;
copyptr = mBufferPointer + mIndex * 4; copyptr = mBufferPointer + mIndex * 4;
static unsigned int lastindex = 0;
if (mIndex > lastindex)
{
Printf("Light index: %d, size: %d\n", mIndex, totalsize);
lastindex = mIndex;
}
float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) };
memcpy(&copyptr[0], parmcnt, 4 * sizeof(float)); memcpy(&copyptr[0], parmcnt, 4 * sizeof(float));