mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-20 20:19:57 +01:00
Update test
This commit is contained in:
parent
598618c9e5
commit
0d37d51bef
2 changed files with 111 additions and 4 deletions
|
@ -422,7 +422,7 @@ int16_t _RCL_cameraHeightScreen = 0;
|
|||
RCL_ArrayFunction _RCL_rollFunction = 0; // says door rolling
|
||||
RCL_Unit *_RCL_floorPixelDistances = 0;
|
||||
|
||||
#ifdef RAYCASTLIB_PROFILE
|
||||
#ifdef RCL_PROFILE
|
||||
// function call counters for profiling
|
||||
uint32_t profile_RCL_sqrtInt = 0;
|
||||
uint32_t profile_RCL_clamp = 0;
|
||||
|
@ -1270,7 +1270,8 @@ RCL_Unit coordStep = 1;
|
|||
|
||||
#if RCL_COMPUTE_WALL_TEXCOORDS == 1
|
||||
p.texCoords.x = p.hit.textureCoord;
|
||||
coordStep = RCL_UNITS_PER_SQUARE / wallHeightScreen;
|
||||
coordStep = RCL_UNITS_PER_SQUARE /
|
||||
(wallHeightScreen != 0 ? wallHeightScreen : 1);
|
||||
p.texCoords.y = coordStep * coordHelper;
|
||||
#endif
|
||||
|
||||
|
@ -1284,7 +1285,8 @@ RCL_Unit coordStep = 1;
|
|||
|
||||
p.position.y = y;
|
||||
#if RCL_COMPUTE_WALL_TEXCOORDS == 1
|
||||
p.texCoords.y = (RCL_UNITS_PER_SQUARE * coordHelper) / wallHeightScreen;
|
||||
p.texCoords.y = (RCL_UNITS_PER_SQUARE * coordHelper) /
|
||||
(wallHeightScreen != 0 ? wallHeightScreen : 1);
|
||||
#endif
|
||||
RCL_PIXEL_FUNCTION(&p);
|
||||
++coordHelper;
|
||||
|
|
107
test.c
107
test.c
|
@ -174,9 +174,77 @@ void benchmarkMapping()
|
|||
}
|
||||
}
|
||||
|
||||
int countPixels = 0;
|
||||
uint32_t *pixelCounts = 0;
|
||||
RCL_Camera countCamera;
|
||||
int countOK = 1;
|
||||
|
||||
void pixelFunc(RCL_PixelInfo *p)
|
||||
{
|
||||
}
|
||||
if (countPixels)
|
||||
{
|
||||
if (p->position.x >= countCamera.resolution.x || p->position.x < 0 ||
|
||||
p->position.y >= countCamera.resolution.y || p->position.y < 0)
|
||||
{
|
||||
printf("ERROR: writing pixel outside screen at %d %d!\n",
|
||||
p->position.x,p->position.y);
|
||||
|
||||
countOK = 0;
|
||||
}
|
||||
else
|
||||
pixelCounts[p->position.y * countCamera.resolution.x + p->position.x]++;
|
||||
}
|
||||
}
|
||||
|
||||
int testPixelCount(RCL_Unit camX, RCL_Unit camY, RCL_Unit camZ,
|
||||
RCL_Unit camDir, RCL_Unit camShear, uint16_t camResX, uint16_t camResY,
|
||||
int complexRender)
|
||||
{
|
||||
printf("Counting rendered pixels...\n");
|
||||
|
||||
RCL_RayConstraints constraints;
|
||||
RCL_Camera c;
|
||||
|
||||
RCL_initRayConstraints(&constraints);
|
||||
RCL_initCamera(&c);
|
||||
c.position.x = camX;
|
||||
c.position.y = camY;
|
||||
c.direction = camDir;
|
||||
c.shear = camShear;
|
||||
c.height = camZ;
|
||||
c.resolution.x = camResX;
|
||||
c.resolution.y = camResY;
|
||||
|
||||
uint32_t pixels[camResX * camResY];
|
||||
|
||||
for (uint32_t i = 0; i < camResX * camResY; ++i)
|
||||
pixels[i] = 0;
|
||||
|
||||
pixelCounts = pixels;
|
||||
countCamera = c;
|
||||
countPixels = 1;
|
||||
|
||||
countOK = 1;
|
||||
|
||||
if (complexRender)
|
||||
RCL_renderComplex(c,testArrayFunc,testArrayFunc2,0,constraints);
|
||||
else
|
||||
RCL_renderSimple(c,testArrayFunc,0,0,constraints);
|
||||
|
||||
for (uint32_t y = 0; y < camResY; ++y)
|
||||
for (uint32_t x = 0; x < camResX; ++x)
|
||||
{
|
||||
uint32_t index = y * camResX + x;
|
||||
|
||||
if (pixels[index] != 1)
|
||||
{
|
||||
printf("ERROR: pixel at %d %d written %d times!\n",x,y,pixels[index]);
|
||||
countOK = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return countOK;
|
||||
}
|
||||
|
||||
void benchmarkRender()
|
||||
{
|
||||
|
@ -194,6 +262,8 @@ void benchmarkRender()
|
|||
constraints.maxHits = 10;
|
||||
constraints.maxSteps = 12;
|
||||
|
||||
countPixels = 0;
|
||||
|
||||
for (int i = 0; i < 100; ++i)
|
||||
RCL_renderComplex(c,testArrayFunc,testArrayFunc2,0,constraints);
|
||||
}
|
||||
|
@ -254,6 +324,41 @@ int main()
|
|||
|
||||
printf("OK\n");
|
||||
|
||||
if (!testPixelCount(
|
||||
RCL_UNITS_PER_SQUARE / 2,
|
||||
RCL_UNITS_PER_SQUARE / 2,
|
||||
RCL_UNITS_PER_SQUARE / 2,
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
64,
|
||||
1))
|
||||
return 1;
|
||||
|
||||
if (!testPixelCount(
|
||||
3 * RCL_UNITS_PER_SQUARE + 100,
|
||||
4 * RCL_UNITS_PER_SQUARE + RCL_UNITS_PER_SQUARE / 3,
|
||||
RCL_UNITS_PER_SQUARE,
|
||||
312,
|
||||
0,
|
||||
200,
|
||||
63,
|
||||
0))
|
||||
return 1;
|
||||
|
||||
if (!testPixelCount(
|
||||
- RCL_UNITS_PER_SQUARE,
|
||||
0,
|
||||
300,
|
||||
-600,
|
||||
-120,
|
||||
64,
|
||||
68,
|
||||
1))
|
||||
return 1;
|
||||
|
||||
printf("OK\n");
|
||||
|
||||
/*
|
||||
if (!testSingleMapping(
|
||||
-RCL_UNITS_PER_SQUARE,
|
||||
|
|
Loading…
Reference in a new issue