Rename rect members from pos, size to min, max

This commit is contained in:
Doyle Thai 2016-11-16 16:57:24 +11:00
parent 21bf650298
commit b75d700dd6
6 changed files with 108 additions and 122 deletions

View File

@ -666,7 +666,7 @@ INTERNAL void parseXmlTreeToGame(AssetManager *assetManager, MemoryArena_ *arena
i32 valueLen = common_strlen(value); i32 valueLen = common_strlen(value);
i32 intValue = common_atoi(value, valueLen); i32 intValue = common_atoi(value, valueLen);
subTex.rect.pos.x = CAST(f32) intValue; subTex.rect.min.x = CAST(f32) intValue;
} }
else if (common_strcmp(subTexAttrib->name, "y") == else if (common_strcmp(subTexAttrib->name, "y") ==
0) 0)
@ -675,7 +675,7 @@ INTERNAL void parseXmlTreeToGame(AssetManager *assetManager, MemoryArena_ *arena
i32 valueLen = common_strlen(value); i32 valueLen = common_strlen(value);
i32 intValue = common_atoi(value, valueLen); i32 intValue = common_atoi(value, valueLen);
subTex.rect.pos.y = CAST(f32) intValue; subTex.rect.min.y = CAST(f32) intValue;
} }
else if (common_strcmp(subTexAttrib->name, else if (common_strcmp(subTexAttrib->name,
"width") == 0) "width") == 0)
@ -684,7 +684,7 @@ INTERNAL void parseXmlTreeToGame(AssetManager *assetManager, MemoryArena_ *arena
i32 valueLen = common_strlen(value); i32 valueLen = common_strlen(value);
i32 intValue = common_atoi(value, valueLen); i32 intValue = common_atoi(value, valueLen);
subTex.rect.size.w = CAST(f32) intValue; subTex.rect.max.w = CAST(f32) intValue;
} }
else if (common_strcmp(subTexAttrib->name, else if (common_strcmp(subTexAttrib->name,
"height") == 0) "height") == 0)
@ -693,7 +693,7 @@ INTERNAL void parseXmlTreeToGame(AssetManager *assetManager, MemoryArena_ *arena
i32 valueLen = common_strlen(value); i32 valueLen = common_strlen(value);
i32 intValue = common_atoi(value, valueLen); i32 intValue = common_atoi(value, valueLen);
subTex.rect.size.h = CAST(f32) intValue; subTex.rect.max.h = CAST(f32) intValue;
} }
else if (common_strcmp(subTexAttrib->name, else if (common_strcmp(subTexAttrib->name,
"hand_offset_x") == 0) "hand_offset_x") == 0)
@ -726,9 +726,9 @@ INTERNAL void parseXmlTreeToGame(AssetManager *assetManager, MemoryArena_ *arena
// TODO(doyle): XML specifies 0,0 top left, we // TODO(doyle): XML specifies 0,0 top left, we
// prefer 0,0 bottom right, so offset by size since 0,0 // prefer 0,0 bottom right, so offset by size since 0,0
// is top left and size creates a bounding box below it // is top left and size creates a bounding box below it
subTex.rect.pos.y = 1024 - subTex.rect.pos.y; subTex.rect.min.y = 1024 - subTex.rect.min.y;
subTex.rect.pos.y -= subTex.rect.size.h; subTex.rect.min.y -= subTex.rect.max.h;
subTex.offset.y = subTex.rect.size.h - subTex.offset.y; subTex.offset.y = subTex.rect.max.h - subTex.offset.y;
#ifdef DENGINE_DEBUG #ifdef DENGINE_DEBUG
ASSERT(key); ASSERT(key);

View File

@ -180,7 +180,7 @@ void asteroid_gameUpdateAndRender(GameState *state, Memory *memory,
{ // Init ship entity { // Init ship entity
Entity *ship = &state->entityList[state->entityIndex++]; Entity *ship = &state->entityList[state->entityIndex++];
ship->id = 0; ship->id = 0;
ship->pos = V2(100, 100); ship->pos = V2(0, 0);
ship->size = V2(25.0f, 50.0f); ship->size = V2(25.0f, 50.0f);
ship->hitbox = ship->size; ship->hitbox = ship->size;
ship->offset = v2_scale(ship->size, 0.5f); ship->offset = v2_scale(ship->size, 0.5f);
@ -192,9 +192,9 @@ void asteroid_gameUpdateAndRender(GameState *state, Memory *memory,
ship->collides = FALSE; ship->collides = FALSE;
} }
state->camera.pos = V2(0, 0); state->camera.min = V2(0, 0);
state->camera.size = state->renderer.size; state->camera.max = state->renderer.size;
state->init = TRUE; state->init = TRUE;
state->worldSize = windowSize; state->worldSize = windowSize;
@ -247,8 +247,7 @@ void asteroid_gameUpdateAndRender(GameState *state, Memory *memory,
// is right facing for trig to work // is right facing for trig to work
Radians rotation = DEGREES_TO_RADIANS((entity->rotation + 90.0f)); Radians rotation = DEGREES_TO_RADIANS((entity->rotation + 90.0f));
v2 direction = V2(math_cosf(rotation), math_sinf(rotation)); v2 direction = V2(math_cosf(rotation), math_sinf(rotation));
ddP = direction;
ddP = v2_normalise(direction);
} }
if (getKeyStatus(&state->input.keys[keycode_left], if (getKeyStatus(&state->input.keys[keycode_left],
@ -322,14 +321,16 @@ void asteroid_gameUpdateAndRender(GameState *state, Memory *memory,
renderer_entity(&state->renderer, state->camera, entity, pivotPoint, 0, renderer_entity(&state->renderer, state->camera, entity, pivotPoint, 0,
V4(0.4f, 0.8f, 1.0f, 1.0f), flags); V4(0.4f, 0.8f, 1.0f, 1.0f), flags);
v2 rightAlignedP = v2_add(entity->pos, entity->hitbox); v2 leftAlignedP = v2_sub(entity->pos, entity->offset);
renderer_rect(&state->renderer, state->camera, rightAlignedP, V2(10, 10), renderer_rect(&state->renderer, state->camera, leftAlignedP,
V2(0, 0), DEGREES_TO_RADIANS(entity->rotation), NULL, entity->size, v2_scale(entity->size, 0.5f),
V4(0.4f, 0.8f, 1.0f, 1.0f), flags); DEGREES_TO_RADIANS(entity->rotation), NULL,
V4(1.0f, 0.8f, 1.0f, 1.0f), flags);
v2 leftAlignedP = entity->pos; v2 rightAlignedP = v2_add(leftAlignedP, entity->size);
renderer_rect(&state->renderer, state->camera, leftAlignedP, V2(10, 10), renderer_rect(&state->renderer, state->camera, rightAlignedP, V2(4, 4),
V2(0, 0), DEGREES_TO_RADIANS(entity->rotation), NULL, v2_scale(pivotPoint, -1.0f),
DEGREES_TO_RADIANS(entity->rotation), NULL,
V4(0.4f, 0.8f, 1.0f, 1.0f), flags); V4(0.4f, 0.8f, 1.0f, 1.0f), flags);
} }

View File

@ -65,7 +65,7 @@ void entity_updateAnim(Entity *const entity, const f32 dt)
char *frameName = anim->frameList[currEntityAnim->currFrame]; char *frameName = anim->frameList[currEntityAnim->currFrame];
SubTexture texRect = asset_getAtlasSubTex(anim->atlas, frameName); SubTexture texRect = asset_getAtlasSubTex(anim->atlas, frameName);
entity->size = v2_scale(texRect.rect.size, entity->scale); entity->size = v2_scale(texRect.rect.max, entity->scale);
} }
void entity_addAnim(AssetManager *const assetManager, Entity *const entity, void entity_addAnim(AssetManager *const assetManager, Entity *const entity,

View File

@ -339,7 +339,7 @@ void renderer_rect(Renderer *const renderer, Rect camera, v2 pos, v2 size,
RenderFlags flags) RenderFlags flags)
{ {
// NOTE(doyle): Bottom left and top right position of quad in world space // NOTE(doyle): Bottom left and top right position of quad in world space
v2 posInCameraSpace = v2_sub(pos, camera.pos); v2 posInCameraSpace = v2_sub(pos, camera.min);
RenderTex emptyRenderTex = {0}; RenderTex emptyRenderTex = {0};
if (!renderTex) renderTex = &emptyRenderTex; if (!renderTex) renderTex = &emptyRenderTex;
@ -385,7 +385,7 @@ void renderer_triangle(Renderer *const renderer, Rect camera,
ARRAY_COUNT(triangleInCamSpace.points)); ARRAY_COUNT(triangleInCamSpace.points));
for (i32 i = 0; i < ARRAY_COUNT(triangleInCamSpace.points); i++) for (i32 i = 0; i < ARRAY_COUNT(triangleInCamSpace.points); i++)
triangleInCamSpace.points[i] = v2_sub(triangle.points[i], camera.pos); triangleInCamSpace.points[i] = v2_sub(triangle.points[i], camera.min);
RenderTex emptyRenderTex = {0}; RenderTex emptyRenderTex = {0};
if (!renderTex) renderTex = &emptyRenderTex; if (!renderTex) renderTex = &emptyRenderTex;
@ -425,7 +425,7 @@ void renderer_string(Renderer *const renderer, MemoryArena_ *arena, Rect camera,
Vertex *vertexList = Vertex *vertexList =
memory_pushBytes(arena, numVertexesToAlloc * sizeof(Vertex)); memory_pushBytes(arena, numVertexesToAlloc * sizeof(Vertex));
v2 posInCameraSpace = v2_sub(pos, camera.pos); v2 posInCameraSpace = v2_sub(pos, camera.min);
pos = posInCameraSpace; pos = posInCameraSpace;
// TODO(doyle): Find why font is 1px off, might be arial font semantics // TODO(doyle): Find why font is 1px off, might be arial font semantics
@ -443,9 +443,9 @@ void renderer_string(Renderer *const renderer, MemoryArena_ *arena, Rect camera,
asset_getAtlasSubTex(font->atlas, &CAST(char)codepoint); asset_getAtlasSubTex(font->atlas, &CAST(char)codepoint);
v4 charTexRect = {0}; v4 charTexRect = {0};
charTexRect.vec2[0] = subTexture.rect.pos; charTexRect.vec2[0] = subTexture.rect.min;
charTexRect.vec2[1] = charTexRect.vec2[1] =
v2_add(subTexture.rect.pos, subTexture.rect.size); v2_add(subTexture.rect.min, subTexture.rect.max);
flipTexCoord(&charTexRect, FALSE, TRUE); flipTexCoord(&charTexRect, FALSE, TRUE);
RenderTex renderTex = {tex, charTexRect}; RenderTex renderTex = {tex, charTexRect};
@ -472,78 +472,63 @@ void renderer_string(Renderer *const renderer, MemoryArena_ *arena, Rect camera,
void renderer_entity(Renderer *renderer, Rect camera, Entity *entity, void renderer_entity(Renderer *renderer, Rect camera, Entity *entity,
v2 pivotPoint, Degrees rotate, v4 color, RenderFlags flags) v2 pivotPoint, Degrees rotate, v4 color, RenderFlags flags)
{ {
// TODO(doyle): Batch into render groups Radians totalRotation = DEGREES_TO_RADIANS((entity->rotation + rotate));
RenderTex renderTex = {0};
// NOTE(doyle): Pos + Size since the origin of an entity is it's bottom left if (entity->tex)
// corner. Add the two together so that the clipping point is the far right
// side of the entity
v2 rightAlignedP = v2_add(entity->pos, entity->hitbox);
v2 leftAlignedP = entity->pos;
if (math_pointInRect(camera, leftAlignedP) ||
math_pointInRect(camera, rightAlignedP))
{ {
EntityAnim *entityAnim = &entity->animList[entity->animListIndex];
RenderTex renderTex = {0}; v4 texRect = {0};
if (entity->tex) if (entityAnim->anim)
{ {
EntityAnim *entityAnim = &entity->animList[entity->animListIndex]; Animation *anim = entityAnim->anim;
v4 texRect = {0}; char *frameName = anim->frameList[entityAnim->currFrame];
if (entityAnim->anim) SubTexture subTex = asset_getAtlasSubTex(anim->atlas, frameName);
{
Animation *anim = entityAnim->anim;
char *frameName = anim->frameList[entityAnim->currFrame];
SubTexture subTex =
asset_getAtlasSubTex(anim->atlas, frameName);
texRect.vec2[0] = subTex.rect.pos; texRect.vec2[0] = subTex.rect.min;
texRect.vec2[1] = v2_add(subTex.rect.pos, subTex.rect.size); texRect.vec2[1] = v2_add(subTex.rect.min, subTex.rect.max);
flipTexCoord(&texRect, entity->flipX, entity->flipY); flipTexCoord(&texRect, entity->flipX, entity->flipY);
}
else
{
texRect = V4(0.0f, 0.0f, (f32)entity->tex->width,
(f32)entity->tex->height);
}
if (entity->direction == direction_east)
{
flipTexCoord(&texRect, TRUE, FALSE);
}
renderTex.tex = entity->tex;
renderTex.texRect = texRect;
}
Radians totalRotation = DEGREES_TO_RADIANS((entity->rotation + rotate));
if (entity->renderMode == rendermode_quad)
{
renderer_rect(renderer, camera, entity->pos, entity->size,
pivotPoint, totalRotation, &renderTex,
color, flags);
}
else if (entity->renderMode == rendermode_triangle)
{
TrianglePoints triangle = {0};
v2 entityPWithOffset = v2_add(entity->pos, entity->offset);
v2 triangleTopPoint =
V2(entityPWithOffset.x + (entity->size.w * 0.5f),
entityPWithOffset.y + entity->size.h);
v2 triangleRightSide =
V2(entityPWithOffset.x + entity->size.w, entityPWithOffset.y);
triangle.points[0] = entityPWithOffset;
triangle.points[1] = triangleRightSide;
triangle.points[2] = triangleTopPoint;
renderer_triangle(renderer, camera, triangle, pivotPoint,
totalRotation, &renderTex, color, flags);
} }
else else
{ {
ASSERT(INVALID_CODE_PATH); texRect = V4(0.0f, 0.0f, (f32)entity->tex->width,
(f32)entity->tex->height);
} }
if (entity->direction == direction_east)
{
flipTexCoord(&texRect, TRUE, FALSE);
}
renderTex.tex = entity->tex;
renderTex.texRect = texRect;
}
if (entity->renderMode == rendermode_quad)
{
renderer_rect(renderer, camera, entity->pos, entity->size, pivotPoint,
totalRotation, &renderTex, color, flags);
}
else if (entity->renderMode == rendermode_triangle)
{
TrianglePoints triangle = {0};
v2 entityPWithOffset = v2_sub(entity->pos, entity->offset);
v2 triangleTopPoint = V2(entityPWithOffset.x + (entity->size.w * 0.5f),
entityPWithOffset.y + entity->size.h);
v2 triangleRightSide =
V2(entityPWithOffset.x + entity->size.w, entityPWithOffset.y);
triangle.points[0] = entityPWithOffset;
triangle.points[1] = triangleRightSide;
triangle.points[2] = triangleTopPoint;
renderer_triangle(renderer, camera, triangle, pivotPoint, totalRotation,
&renderTex, color, flags);
}
else
{
ASSERT(INVALID_CODE_PATH);
} }
} }

View File

@ -35,7 +35,7 @@ i32 userInterface_button(UiState *const uiState, MemoryArena_ *const arena,
#if 0 #if 0
// Draw shadow // Draw shadow
renderer_staticRect(renderer, v2_add(V2(1, 1), rect.pos), rect.size, renderer_staticRect(renderer, v2_add(V2(1, 1), rect.min), rect.size,
V2(0, 0), 0, renderTex, V4(0, 0, 0, 1)); V2(0, 0), 0, renderTex, V4(0, 0, 0, 1));
#endif #endif
@ -68,29 +68,29 @@ i32 userInterface_button(UiState *const uiState, MemoryArena_ *const arena,
{ {
// Draw outline // Draw outline
renderer_staticRect(renderer, renderer_staticRect(renderer,
v2_add(V2(-2, -2), v2_add(buttonOffset, rect.pos)), v2_add(V2(-2, -2), v2_add(buttonOffset, rect.min)),
v2_add(V2(4, 4), rect.size), V2(0, 0), 0, &renderTex, v2_add(V2(4, 4), rect.max), V2(0, 0), 0, &renderTex,
buttonColor, 0); buttonColor, 0);
} }
renderer_staticRect(renderer, v2_add(buttonOffset, rect.pos), rect.size, renderer_staticRect(renderer, v2_add(buttonOffset, rect.min), rect.max,
V2(0, 0), 0, &renderTex, buttonColor, 0); V2(0, 0), 0, &renderTex, buttonColor, 0);
if (label) if (label)
{ {
v2 labelDim = asset_stringDimInPixels(font, label); v2 labelDim = asset_stringDimInPixels(font, label);
v2 labelPos = rect.pos; v2 labelPos = rect.min;
// Initially position the label to half the width of the button // Initially position the label to half the width of the button
labelPos.x += (rect.size.w * 0.5f); labelPos.x += (rect.max.w * 0.5f);
// Move the label pos back half the length of the string (i.e. // Move the label pos back half the length of the string (i.e.
// center it) // center it)
labelPos.x -= (CAST(f32) labelDim.w * 0.5f); labelPos.x -= (CAST(f32) labelDim.w * 0.5f);
if (labelDim.h < rect.size.h) if (labelDim.h < rect.max.h)
{ {
labelPos.y += (rect.size.h * 0.5f); labelPos.y += (rect.max.h * 0.5f);
labelPos.y -= (CAST(f32)labelDim.h * 0.5f); labelPos.y -= (CAST(f32)labelDim.h * 0.5f);
} }
@ -168,13 +168,13 @@ i32 userInterface_scrollbar(UiState *const uiState,
if (uiState->kbdItem == id) if (uiState->kbdItem == id)
{ {
// Draw outline // Draw outline
renderer_staticRect(renderer, v2_add(V2(-2, -2), scrollBarRect.pos), renderer_staticRect(renderer, v2_add(V2(-2, -2), scrollBarRect.min),
v2_add(V2(4, 4), scrollBarRect.size), V2(0, 0), 0, v2_add(V2(4, 4), scrollBarRect.max), V2(0, 0), 0,
&renderTex, V4(1, 0, 0, 1), 0); &renderTex, V4(1, 0, 0, 1), 0);
} }
// Render scroll bar background // Render scroll bar background
renderer_staticRect(renderer, scrollBarRect.pos, scrollBarRect.size, renderer_staticRect(renderer, scrollBarRect.min, scrollBarRect.max,
V2(0, 0), 0, &renderTex, V4(0.75f, 0.5f, 0.5f, 1), 0); V2(0, 0), 0, &renderTex, V4(0.75f, 0.5f, 0.5f, 1), 0);
// Render scroll bar slider // Render scroll bar slider
@ -183,8 +183,8 @@ i32 userInterface_scrollbar(UiState *const uiState,
f32 sliderPercentageOffset = (CAST(f32) *value / CAST(f32) maxValue); f32 sliderPercentageOffset = (CAST(f32) *value / CAST(f32) maxValue);
f32 sliderYOffsetToBar = f32 sliderYOffsetToBar =
(scrollBarRect.size.h - sliderSize.h) * sliderPercentageOffset; (scrollBarRect.max.h - sliderSize.h) * sliderPercentageOffset;
v2 sliderPos = v2_add(scrollBarRect.pos, V2(0, sliderYOffsetToBar)); v2 sliderPos = v2_add(scrollBarRect.min, V2(0, sliderYOffsetToBar));
if (uiState->hotItem == id || uiState->activeItem == id) if (uiState->hotItem == id || uiState->activeItem == id)
sliderColor = V4(1.0f, 0, 0, 1); sliderColor = V4(1.0f, 0, 0, 1);
@ -228,16 +228,16 @@ i32 userInterface_scrollbar(UiState *const uiState,
if (uiState->activeItem == id) if (uiState->activeItem == id)
{ {
f32 mouseYRelToRect = input.mouseP.y - scrollBarRect.pos.y; f32 mouseYRelToRect = input.mouseP.y - scrollBarRect.min.y;
// Bounds check // Bounds check
if (mouseYRelToRect < 0) if (mouseYRelToRect < 0)
mouseYRelToRect = 0; mouseYRelToRect = 0;
else if (mouseYRelToRect > scrollBarRect.size.h) else if (mouseYRelToRect > scrollBarRect.max.h)
mouseYRelToRect = scrollBarRect.size.h; mouseYRelToRect = scrollBarRect.max.h;
f32 newSliderPercentOffset = f32 newSliderPercentOffset =
(CAST(f32) mouseYRelToRect / scrollBarRect.size.h); (CAST(f32) mouseYRelToRect / scrollBarRect.max.h);
i32 newValue = CAST(i32)(newSliderPercentOffset * CAST(f32)maxValue); i32 newValue = CAST(i32)(newSliderPercentOffset * CAST(f32)maxValue);
if (newValue != *value) if (newValue != *value)
@ -282,27 +282,27 @@ i32 userInterface_textField(UiState *const uiState, MemoryArena_ *const arena,
if (uiState->kbdItem == id) if (uiState->kbdItem == id)
{ {
// Draw outline // Draw outline
renderer_staticRect(renderer, v2_add(V2(-2, -2), rect.pos), renderer_staticRect(renderer, v2_add(V2(-2, -2), rect.min),
v2_add(V2(4, 4), rect.size), V2(0, 0), 0, v2_add(V2(4, 4), rect.max), V2(0, 0), 0,
&renderTex, V4(1.0f, 0, 0, 1), 0); &renderTex, V4(1.0f, 0, 0, 1), 0);
} }
// Render text field // Render text field
renderer_staticRect(renderer, rect.pos, rect.size, V2(0, 0), 0, renderer_staticRect(renderer, rect.min, rect.max, V2(0, 0), 0,
&renderTex, V4(0.75f, 0.5f, 0.5f, 1), 0); &renderTex, V4(0.75f, 0.5f, 0.5f, 1), 0);
if (uiState->activeItem == id || uiState->hotItem == id) if (uiState->activeItem == id || uiState->hotItem == id)
{ {
renderer_staticRect(renderer, rect.pos, rect.size, V2(0, 0), 0, renderer_staticRect(renderer, rect.min, rect.max, V2(0, 0), 0,
&renderTex, V4(0.75f, 0.75f, 0.0f, 1), 0); &renderTex, V4(0.75f, 0.75f, 0.0f, 1), 0);
} }
else else
{ {
renderer_staticRect(renderer, rect.pos, rect.size, V2(0, 0), 0, renderer_staticRect(renderer, rect.min, rect.max, V2(0, 0), 0,
&renderTex, V4(0.5f, 0.5f, 0.5f, 1), 0); &renderTex, V4(0.5f, 0.5f, 0.5f, 1), 0);
} }
v2 strPos = rect.pos; v2 strPos = rect.min;
renderer_staticString(renderer, arena, font, string, strPos, V2(0, 0), 0, renderer_staticString(renderer, arena, font, string, strPos, V2(0, 0), 0,
V4(0, 0, 0, 1), 0); V4(0, 0, 0, 1), 0);
@ -365,10 +365,10 @@ i32 userInterface_window(UiState *const uiState, MemoryArena_ *const arena,
Rect rect = window->rect; Rect rect = window->rect;
RenderTex nullRenderTex = renderer_createNullRenderTex(assetManager); RenderTex nullRenderTex = renderer_createNullRenderTex(assetManager);
renderer_staticRect(renderer, rect.pos, rect.size, V2(0, 0), 0, renderer_staticRect(renderer, rect.min, rect.max, V2(0, 0), 0,
&nullRenderTex, V4(0.25f, 0.25f, 0.5f, 0.5f), 0); &nullRenderTex, V4(0.25f, 0.25f, 0.5f, 0.5f), 0);
v2 menuTitleP = v2_add(rect.pos, V2(0, rect.size.h - 10)); v2 menuTitleP = v2_add(rect.min, V2(0, rect.max.h - 10));
renderer_staticString(renderer, arena, font, window->title, menuTitleP, renderer_staticString(renderer, arena, font, window->title, menuTitleP,
V2(0, 0), 0, V4(0, 0, 0, 1), 0); V2(0, 0), 0, V4(0, 0, 0, 1), 0);
@ -444,11 +444,11 @@ i32 userInterface_window(UiState *const uiState, MemoryArena_ *const arena,
for (i32 i = 0; i < window->numChildUiItems; i++) for (i32 i = 0; i < window->numChildUiItems; i++)
{ {
UiItem *childUi = &window->childUiItems[i]; UiItem *childUi = &window->childUiItems[i];
childUi->rect.pos = v2_add(deltaP, childUi->rect.pos); childUi->rect.min = v2_add(deltaP, childUi->rect.min);
} }
DEBUG_PUSH_VAR("Delta Pos %4.2f, %4.2f", deltaP, "v2"); DEBUG_PUSH_VAR("Delta Pos %4.2f, %4.2f", deltaP, "v2");
window->rect.pos = v2_add(deltaP, window->rect.pos); window->rect.min = v2_add(deltaP, window->rect.min);
} }
else else
{ {

View File

@ -70,8 +70,8 @@ typedef union v4
typedef struct Rect typedef struct Rect
{ {
v2 pos; v2 min;
v2 size; v2 max;
} Rect; } Rect;
INTERNAL inline v2 V2i(const i32 x, const i32 y) INTERNAL inline v2 V2i(const i32 x, const i32 y)
@ -319,11 +319,11 @@ INTERNAL inline v4 mat4_mul_v4(const mat4 a, const v4 b)
INTERNAL inline b32 math_pointInRect(Rect rect, v2 point) INTERNAL inline b32 math_pointInRect(Rect rect, v2 point)
{ {
b32 outsideOfRectX = FALSE; b32 outsideOfRectX = FALSE;
if (point.x < rect.pos.x || point.x > (rect.pos.x + rect.size.w)) if (point.x < rect.min.x || point.x > (rect.min.x + rect.max.w))
outsideOfRectX = TRUE; outsideOfRectX = TRUE;
b32 outsideOfRectY = FALSE; b32 outsideOfRectY = FALSE;
if (point.y < rect.pos.y || point.y > (rect.pos.y + rect.size.h)) if (point.y < rect.min.y || point.y > (rect.min.y + rect.max.h))
outsideOfRectY = TRUE; outsideOfRectY = TRUE;
if (outsideOfRectX || outsideOfRectY) return FALSE; if (outsideOfRectX || outsideOfRectY) return FALSE;