Rectangle -> Rectangle2D

This commit is contained in:
UnknownShadow200 2017-08-08 22:18:07 +10:00
parent 211c8e810b
commit fa570cb1a0
7 changed files with 22 additions and 21 deletions

View File

@ -186,7 +186,7 @@ namespace ClassicalSharp.Network.Protocols {
string name = reader.ReadString();
string skin = name;
net.CheckName(id, ref name, ref skin);
net.AddEntity(id, name, skin, true);
net.AddEntity(id, name, skin, true);
if (!net.addEntityHack) return;
// Workaround for some servers that declare they support ExtPlayerList,

View File

@ -1,11 +1,11 @@
#include "2DStructs.h"
Rectangle Rectangle_Make(Int32 x, Int32 y, Int32 width, Int32 height) {
Rectangle r;
Rectangle2D Rectangle2D_Make(Int32 x, Int32 y, Int32 width, Int32 height) {
Rectangle2D r;
r.X = x; r.Y = y; r.Width = width; r.Height = height;
return r;
}
bool Rectangle_Contains(Rectangle a, Int32 x, Int32 y) {
bool Rectangle2D_Contains(Rectangle2D a, Int32 x, Int32 y) {
return x >= a.X && y >= a.Y && x < (a.X + a.Width) && y < (a.Y + a.Height);
}

View File

@ -6,17 +6,17 @@
*/
/* Stores location and dimensions of a 2D rectangle. */
typedef struct Rectangle_ {
typedef struct Rectangle2D_ {
/* Coordinates of top left corner of rectangle.*/
Int32 X, Y;
/* Size of rectangle. */
Int32 Width, Height;
} Rectangle;
} Rectangle2D;
/* Creates a new rectangle. */
Rectangle Rectangle_Make(Int32 x, Int32 y, Int32 width, Int32 height);
Rectangle2D Rectangle2D_Make(Int32 x, Int32 y, Int32 width, Int32 height);
/* Returns whether the given rectangle contains the given point. */
bool Rectangle_Contains(Rectangle a, Int32 x, Int32 y);
bool Rectangle2D_Contains(Rectangle2D a, Int32 x, Int32 y);
#endif

View File

@ -23,4 +23,5 @@ static BlockID AutoRotate_RotateOther(BlockID block, String* name, Vector3 offse
static BlockID AutoRotate_RotateDirection(BlockID block, String* name, Vector3 offset);
static BlockID AutoRotate_Find(BlockID block, String* name, const UInt8* suffix);
#endif
#endif

View File

@ -19,7 +19,7 @@ GfxResourceID borders_sidesVb = -1, borders_edgesVb = -1;
GfxResourceID borders_edgeTexId, borders_sideTexId;
Int32 borders_sidesVertices, borders_edgesVertices;
bool borders_fullBrightSides, borders_fullBrightEdge;
Rectangle borders_rects[4];
Rectangle2D borders_rects[4];
TextureLoc borders_lastEdgeTexLoc, borders_lastSideTexLoc;
/* Creates game component implementation. */
@ -165,7 +165,7 @@ void BordersRenderer_RebuildSides(Int32 y, Int32 axisSize) {
Int32 i;
for (i = 0; i < 4; i++) {
Rectangle r = borders_rects[i];
Rectangle2D r = borders_rects[i];
borders_sidesVertices += Math_CountVertices(r.Width, r.Height, axisSize); /* YQuads outside */
}
borders_sidesVertices += Math_CountVertices(World_Width, World_Length, axisSize); /* YQuads beneath map */
@ -185,7 +185,7 @@ void BordersRenderer_RebuildSides(Int32 y, Int32 axisSize) {
Block_Tint(col, block)
for (i = 0; i < 4; i++) {
Rectangle r = borders_rects[i];
Rectangle2D r = borders_rects[i];
BordersRenderer_DrawY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, (Real32)y, axisSize, col,
0, borders_YOffset(block), &temp);
}
@ -210,7 +210,7 @@ void BordersRenderer_RebuildEdges(Int32 y, Int32 axisSize) {
Int32 i;
for (i = 0; i < 4; i++) {
Rectangle r = borders_rects[i];
Rectangle2D r = borders_rects[i];
borders_edgesVertices += Math_CountVertices(r.Width, r.Height, axisSize); /* YPlanes outside */
}
@ -227,7 +227,7 @@ void BordersRenderer_RebuildEdges(Int32 y, Int32 axisSize) {
Block_Tint(col, block)
for (i = 0; i < 4; i++) {
Rectangle r = borders_rects[i];
Rectangle2D r = borders_rects[i];
BordersRenderer_DrawY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, (Real32)y, axisSize, col,
borders_HorOffset(block), borders_YOffset(block), &temp);
}
@ -305,11 +305,11 @@ void BordersRenderer_DrawY(Int32 x1, Int32 z1, Int32 x2, Int32 z2, Real32 y, Int
void BordersRenderer_CalculateRects(Int32 extent) {
extent = Math_AdjViewDist(extent);
borders_rects[0] = Rectangle_Make(-extent, -extent, extent + World_Width + extent, extent);
borders_rects[1] = Rectangle_Make(-extent, World_Length, extent + World_Width + extent, extent);
borders_rects[0] = Rectangle2D_Make(-extent, -extent, extent + World_Width + extent, extent);
borders_rects[1] = Rectangle2D_Make(-extent, World_Length, extent + World_Width + extent, extent);
borders_rects[2] = Rectangle_Make(-extent, 0, extent, World_Length);
borders_rects[3] = Rectangle_Make(World_Width, 0, extent, World_Length);
borders_rects[2] = Rectangle2D_Make(-extent, 0, extent, World_Length);
borders_rects[3] = Rectangle2D_Make(World_Width, 0, extent, World_Length);
}
void BordersRenderer_MakeTexture(GfxResourceID* texId, TextureLoc* lastTexLoc, BlockID block) {

View File

@ -10,12 +10,12 @@ DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPe
DisplayDevice DisplayDevice_Make(DisplayResolution* curResolution) {
DisplayDevice device;
device.CurResolution = *curResolution;
device.Bounds = Rectangle_Make(0, 0, curResolution->Width, curResolution->Height);
device.Bounds = Rectangle2D_Make(0, 0, curResolution->Width, curResolution->Height);
device.Metadata = NULL;
return device;
}
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle* bounds) {
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle2D* bounds) {
device->Bounds = *bounds;
device->CurResolution.Width = bounds->Width;
device->CurResolution.Height = bounds->Height;

View File

@ -38,7 +38,7 @@ typedef struct DisplayDevice_ {
DisplayResolution CurResolution;
/* The bounds of the display device.*/
Rectangle Bounds;
Rectangle2D Bounds;
/* Metadata unique to this display device instance. */
void* Metadata;
@ -48,7 +48,7 @@ typedef struct DisplayDevice_ {
DisplayDevice DisplayDevice_Make(DisplayResolution* curResolution);
/* Updates the bounds of the display device to the given bounds. */
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle* bounds);
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle2D* bounds);
/* The primary / default / main display device. */
DisplayDevice DisplayDevice_Default;