2006-02-24 04:48:15 +00:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// Main loop menu stuff.
|
|
|
|
// Random number LUT.
|
|
|
|
// Default Config File.
|
|
|
|
// PCX Screenshots.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "m_bbox.h"
|
2008-04-06 17:33:43 +00:00
|
|
|
#include "p_local.h"
|
2016-02-15 01:14:34 +00:00
|
|
|
#include "p_maputl.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2015-03-14 08:34:55 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FBoundingBox::FBoundingBox(fixed_t x, fixed_t y, fixed_t radius)
|
|
|
|
{
|
|
|
|
m_Box[BOXTOP] = (fixed_t)MIN<SQWORD>((SQWORD)y + radius, FIXED_MAX);
|
|
|
|
m_Box[BOXLEFT] = (fixed_t)MAX<SQWORD>((SQWORD)x - radius, FIXED_MIN);
|
|
|
|
m_Box[BOXRIGHT] = (fixed_t)MIN<SQWORD>((SQWORD)x + radius, FIXED_MAX);
|
|
|
|
m_Box[BOXBOTTOM] = (fixed_t)MAX<SQWORD>((SQWORD)y - radius, FIXED_MIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
void FBoundingBox::AddToBox (fixed_t x, fixed_t y)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (x < m_Box[BOXLEFT])
|
|
|
|
m_Box[BOXLEFT] = x;
|
2006-04-11 08:36:23 +00:00
|
|
|
if (x > m_Box[BOXRIGHT])
|
2006-02-24 04:48:15 +00:00
|
|
|
m_Box[BOXRIGHT] = x;
|
|
|
|
|
|
|
|
if (y < m_Box[BOXBOTTOM])
|
|
|
|
m_Box[BOXBOTTOM] = y;
|
2006-04-11 08:36:23 +00:00
|
|
|
if (y > m_Box[BOXTOP])
|
2006-02-24 04:48:15 +00:00
|
|
|
m_Box[BOXTOP] = y;
|
|
|
|
}
|
|
|
|
|
2008-04-09 18:35:21 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBoundingBox :: BoxOnLineSide
|
|
|
|
//
|
|
|
|
// Considers the line to be infinite
|
|
|
|
// Returns side 0 or 1, -1 if box crosses the line.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-04-06 17:33:43 +00:00
|
|
|
int FBoundingBox::BoxOnLineSide (const line_t *ld) const
|
|
|
|
{
|
2008-04-09 18:35:21 +00:00
|
|
|
int p1;
|
|
|
|
int p2;
|
|
|
|
|
2014-08-01 00:15:08 +00:00
|
|
|
if (ld->dx == 0)
|
|
|
|
{ // ST_VERTICAL
|
|
|
|
p1 = m_Box[BOXRIGHT] < ld->v1->x;
|
|
|
|
p2 = m_Box[BOXLEFT] < ld->v1->x;
|
|
|
|
if (ld->dy < 0)
|
2008-04-09 18:35:21 +00:00
|
|
|
{
|
|
|
|
p1 ^= 1;
|
|
|
|
p2 ^= 1;
|
|
|
|
}
|
2014-08-01 00:15:08 +00:00
|
|
|
}
|
|
|
|
else if (ld->dy == 0)
|
|
|
|
{ // ST_HORIZONTAL:
|
|
|
|
p1 = m_Box[BOXTOP] > ld->v1->y;
|
|
|
|
p2 = m_Box[BOXBOTTOM] > ld->v1->y;
|
|
|
|
if (ld->dx < 0)
|
2008-04-09 18:35:21 +00:00
|
|
|
{
|
|
|
|
p1 ^= 1;
|
|
|
|
p2 ^= 1;
|
|
|
|
}
|
2014-08-01 00:15:08 +00:00
|
|
|
}
|
|
|
|
else if ((ld->dy ^ ld->dx) >= 0)
|
|
|
|
{ // ST_POSITIVE:
|
2008-04-09 18:35:21 +00:00
|
|
|
p1 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXTOP], ld);
|
|
|
|
p2 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXBOTTOM], ld);
|
2014-08-01 00:15:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // ST_NEGATIVE:
|
2008-04-09 18:35:21 +00:00
|
|
|
p1 = P_PointOnLineSide (m_Box[BOXRIGHT], m_Box[BOXTOP], ld);
|
|
|
|
p2 = P_PointOnLineSide (m_Box[BOXLEFT], m_Box[BOXBOTTOM], ld);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (p1 == p2) ? p1 : -1;
|
2008-04-06 17:33:43 +00:00
|
|
|
}
|
|
|
|
|