Add margin to the bounding box

This commit is contained in:
2014-06-28 19:58:17 +02:00
committed by Valeriano A.R
parent 4fd5af74bc
commit ef1f660f24
3 changed files with 5 additions and 5 deletions

View File

@@ -64,7 +64,6 @@ void Draw_SetOffset(DrawImg img,int x,int y);
void Draw_GetOffset(DrawImg img,int *x,int *y); void Draw_GetOffset(DrawImg img,int *x,int *y);
///////////////////////////// /////////////////////////////
// Draw_DrawImg // Draw_DrawImg
// //

View File

@@ -149,10 +149,11 @@ Entity Entity_Copy(Entity e){
// Entity_CalcBBox // Entity_CalcBBox
// //
// //
#define BBox_ExtraMargin 10
#define max(a,b) ((a)>(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b))
void Entity_CalcBBox(Entity e){ void Entity_CalcBBox(Entity e){
int hHeight=(max(e->height,e->radius)/2)+2; float hHeight=(max(e->height,e->radius)/2)+BBox_ExtraMargin;
int hWidth=(max(e->width,e->radius)/2)+2; float hWidth=(max(e->width,e->radius)/2)+BBox_ExtraMargin;
if(e->vel[0]>0){ if(e->vel[0]>0){
e->maxX=e->pos[0]+e->vel[0]+hWidth; e->maxX=e->pos[0]+e->vel[0]+hWidth;
e->minX=e->pos[0]-hWidth; e->minX=e->pos[0]-hWidth;

View File

@@ -63,8 +63,8 @@ struct TEntity {
int D; int D;
Entity child; Entity child;
int maxX,minX; float maxX,minX;
int maxY,minY; float maxY,minY;
Entity next; Entity next;
}; };