1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/raycastlib.git synced 2024-11-23 20:49:57 +01:00

Add init functions

This commit is contained in:
Miloslav Číž 2018-09-15 14:35:21 +02:00
parent ff5ccd9feb
commit 2467bbbc62

View file

@ -330,6 +330,9 @@ void moveCameraWithCollision(Camera *camera, Vector2D planeOffset,
Unit heightOffset, ArrayFunction floorHeightFunc,
ArrayFunction ceilingHeightFunc, int8_t computeHeight, int8_t force);
void initCamera(Camera *camera);
void initRayConstraints(RayConstraints *constraints);
//=============================================================================
// privates
@ -1068,6 +1071,9 @@ void _columnFunctionSimple(HitResult *hits, uint16_t hitCount, uint16_t x,
int16_t wallHeightWorld = _floorFunction(hit.square.x,hit.square.y);
wallHeightWorld = wallHeightWorld != 0 ? wallHeightWorld : 1;
// ^ prevent division by zero
wallHeightScreen = perspectiveScale((wallHeightWorld *
_camera.resolution.y) / UNITS_PER_SQUARE,dist);
@ -1442,4 +1448,22 @@ void moveCameraWithCollision(Camera *camera, Vector2D planeOffset,
}
}
void initCamera(Camera *camera)
{
camera->position.x = 0;
camera->position.y = 0;
camera->direction = 0;
camera->resolution.x = 20;
camera->resolution.y = 15;
camera->shear = 0;
camera->height = UNITS_PER_SQUARE;
}
void initRayConstraints(RayConstraints *constraints)
{
constraints->maxHits = 1;
constraints->maxSteps = 20;
constraints->computeTextureCoords = 1;
}
#endif