* Feature-complete isometric mode fork. * Dithered transparency condition tweaks. * Dithered transparency for non-corpse monsters only (and missiles). * SpectatorCamera vertical shift. * Including math.h in hw_sprites.cpp to keep visual studio happy (it couldn't find M_SQRT2 definition). * Defining MY_SQRT2 in hw_sprites.cpp to keep visual studio happy (it couldn't find M_SQRT2 definition). * Defining MY_SQRT2 in r_utility.cpp also to keep visual studio happy. * retrigger checks * Have correct sprite angle-frame face the camera with orthographic projection enabled. * Dithered Transparency now works properly on 3D floors. Moved that dither-trans flag setting code within hw_bsp.cpp to handle double-processing of linedefs. Added helper functions to FRenderViewpoint class 'bool IsOrtho()' and 'bool IsAllowedOoB()' to clean up checks everywhere in the code. * Fixed indents. Added bbox property to subsector struct and use it instead of BSP nodes and Clippers (creating a bbox around viewpoint and checking for overlap) in orthographic mode when no fog of war is active. Turns out to be much faster. Though you need really big maps (Winter's Fury MAP01) to see a difference in fps. * Non-linux checks don't like uint. Changed to unsigned int. * Small change of a float to camera.zs. Ignore for testing. Should make no difference. * Update actor.h to remain mergeable RF2_NOMIPMAP was introduced, so I had to displace RF_ISOMETRICSPRITES to next bit.
94 lines
2.1 KiB
C++
94 lines
2.1 KiB
C++
|
|
#ifndef __M_BBOX_H__
|
|
#define __M_BBOX_H__
|
|
|
|
#include <float.h>
|
|
#include "vectors.h"
|
|
|
|
enum
|
|
{
|
|
BOXTOP,
|
|
BOXBOTTOM,
|
|
BOXLEFT,
|
|
BOXRIGHT
|
|
}; // bbox coordinates
|
|
|
|
|
|
class FBoundingBox
|
|
{
|
|
public:
|
|
FBoundingBox()
|
|
{
|
|
ClearBox();
|
|
}
|
|
|
|
FBoundingBox(double left, double bottom, double right, double top)
|
|
{
|
|
m_Box[BOXTOP] = top;
|
|
m_Box[BOXLEFT] = left;
|
|
m_Box[BOXRIGHT] = right;
|
|
m_Box[BOXBOTTOM] = bottom;
|
|
}
|
|
|
|
FBoundingBox(double x, double y, double radius)
|
|
{
|
|
setBox(x, y, radius);
|
|
}
|
|
|
|
|
|
void setBox(double x, double y, double radius)
|
|
{
|
|
m_Box[BOXTOP] = y + radius;
|
|
m_Box[BOXLEFT] = x - radius;
|
|
m_Box[BOXRIGHT] = x + radius;
|
|
m_Box[BOXBOTTOM] = y - radius;
|
|
}
|
|
|
|
void ClearBox ()
|
|
{
|
|
m_Box[BOXTOP] = m_Box[BOXRIGHT] = -FLT_MAX;
|
|
m_Box[BOXBOTTOM] = m_Box[BOXLEFT] = FLT_MAX;
|
|
}
|
|
|
|
// Returns a bounding box that encloses both bounding boxes
|
|
FBoundingBox operator | (const FBoundingBox &box2) const
|
|
{
|
|
return FBoundingBox(m_Box[BOXLEFT] < box2.m_Box[BOXLEFT] ? m_Box[BOXLEFT] : box2.m_Box[BOXLEFT],
|
|
m_Box[BOXBOTTOM] < box2.m_Box[BOXBOTTOM] ? m_Box[BOXBOTTOM] : box2.m_Box[BOXBOTTOM],
|
|
m_Box[BOXRIGHT] > box2.m_Box[BOXRIGHT] ? m_Box[BOXRIGHT] : box2.m_Box[BOXRIGHT],
|
|
m_Box[BOXTOP] > box2.m_Box[BOXTOP] ? m_Box[BOXTOP] : box2.m_Box[BOXTOP]);
|
|
}
|
|
|
|
void AddToBox(const DVector2 &pos)
|
|
{
|
|
if (pos.X < m_Box[BOXLEFT])
|
|
m_Box[BOXLEFT] = pos.X;
|
|
if (pos.X > m_Box[BOXRIGHT])
|
|
m_Box[BOXRIGHT] = pos.X;
|
|
|
|
if (pos.Y < m_Box[BOXBOTTOM])
|
|
m_Box[BOXBOTTOM] = pos.Y;
|
|
if (pos.Y > m_Box[BOXTOP])
|
|
m_Box[BOXTOP] = pos.Y;
|
|
}
|
|
|
|
bool CheckOverlap(const FBoundingBox &box2)
|
|
{
|
|
bool hori = (Left() > box2.Right()) || (Right() < box2.Left());
|
|
bool vert = (Bottom() > box2.Top()) || (Top() < box2.Bottom());
|
|
return !(hori || vert); // [DVR] For alternative space partition
|
|
}
|
|
|
|
inline double Top () const { return m_Box[BOXTOP]; }
|
|
inline double Bottom () const { return m_Box[BOXBOTTOM]; }
|
|
inline double Left () const { return m_Box[BOXLEFT]; }
|
|
inline double Right () const { return m_Box[BOXRIGHT]; }
|
|
|
|
void Set(int index, double value) {m_Box[index] = value;}
|
|
|
|
protected:
|
|
double m_Box[4];
|
|
};
|
|
|
|
|
|
#endif //__M_BBOX_H__
|