Skip to content

Commit

Permalink
libdeng1: Added a couple of new 2D vector box methods
Browse files Browse the repository at this point in the history
To keep things a little tidier when updating using libdeng2's
de::VectorN<> classes.
  • Loading branch information
danij-deng committed Apr 22, 2013
1 parent 4b9b44e commit 8ca93ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doomsday/libdeng1/include/de/vector1.h
Expand Up @@ -332,8 +332,10 @@ DENG_PUBLIC void V2d_Lerp(pvec2d_t dest, const_pvec2d_t a, const_pvec2d_t b, dou
* Left/top is the min-point. Right/bottom is the max-point.
*/
DENG_PUBLIC void V2d_InitBox(arvec2d_t box, const_pvec2d_t point);
DENG_PUBLIC void V2d_InitBoxXY(arvec2d_t box, double x, double y);

DENG_PUBLIC void V2d_AddToBox(arvec2d_t box, const_pvec2d_t point);
DENG_PUBLIC void V2d_AddToBoxXY(arvec2d_t box, double x, double y);

DENG_PUBLIC void V2d_UniteBox(arvec2d_t box, const_arvec2d_t other);

Expand Down
12 changes: 12 additions & 0 deletions doomsday/libdeng1/src/vector1.c
Expand Up @@ -627,6 +627,12 @@ void V2d_InitBox(arvec2d_t box, const_pvec2d_t point)
V2d_Copy(box[1], point);
}

void V2d_InitBoxXY(arvec2d_t box, double x, double y)
{
vec2d_t point; V2d_Set(point, x, y);
V2d_InitBox(box, point);
}

void V2d_AddToBox(arvec2d_t box, const_pvec2d_t point)
{
if(point[VX] < box[0][VX])
Expand All @@ -640,6 +646,12 @@ void V2d_AddToBox(arvec2d_t box, const_pvec2d_t point)
box[1][VY] = point[VY];
}

void V2d_AddToBoxXY(arvec2d_t box, double x, double y)
{
vec2d_t point; V2d_Set(point, x, y);
V2d_AddToBox(box, point);
}

void V2d_UniteBox(arvec2d_t box, const_arvec2d_t other)
{
if(other[0][VX] < box[0][VX])
Expand Down

0 comments on commit 8ca93ef

Please sign in to comment.