1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-08-14 10:30:08 +00:00

Remove commented-out code

This commit is contained in:
Nicolas Braud-Santoni 2016-05-05 19:40:28 +02:00
parent 0f39b825e1
commit eb128e65a4
162 changed files with 2092 additions and 6594 deletions

View file

@ -41,44 +41,17 @@ CollisionShape::Type CollisionShape::getType()
return type;
}
/*
bool CollisionShape::compareMask(CollisionShape &c)
{
for (CollisionLayerMask::iterator i = c.colliderMask.begin(); i != c.colliderMask.end(); i++)
{
for (CollisionLayerMask::iterator j = c.collideeMask.begin(); j != c.collideeMask.end(); j++)
{
if ((*i)) && (*j))
{
return true;
}
}
}
return false;
}
*/
bool CollisionShape::compareLayer(CollisionShape &c)
{
{
return (this->layer <= c.layer);
}
void CollisionShape::updatePosition(const Vector &position)
{
this->position = position + offsetPosition;
/*
switch (getType())
{
case AABB:
{
corners[0] = position + Vector( - xw, - yw);
corners[1] = position + Vector(xw, - yw);
corners[2] = position + Vector(xw, yw);
corners[3] = position + Vector(-xw ,yw);
}
break;
}
*/
}
CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
@ -97,21 +70,21 @@ CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
break;
case AABB:
{
float txw = collisionShape.xw;
float tyw = collisionShape.yw;
Vector d = position - collisionShape.position;//tile->obj delta
int px = (txw + radius) - fabsf(d.x);//penetration depth in x
if(0 < px)
{
int py = (tyw + radius) - fabsf(d.y);//pen depth in y
if(0 < py)
{
//object may be colliding with tile
//determine grid/voronoi region of circle center
float oH = 0;
float oV = 0;
@ -125,7 +98,7 @@ CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
//circle is on right side of tile
oH = 1;
}
if(d.y < -tyw)
{
//circle is on top side of tile
@ -135,14 +108,14 @@ CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
{
//circle is on bottom side of tile
oV = 1;
}
}
c = collideCircleWithAABB(collisionShape, px, py, oH, oV);
//ResolveCircleTile(px,py,oH,oV,this,c);
}
}
//return collideCircleWithAABB(collisionShape);
}
break;
case TOP_HALF_CIRCLE:
@ -158,20 +131,16 @@ CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
CollisionResult CollisionShape::collideCircleWithCircle(CollisionShape &collisionShape)
{
CollisionResult c;
Vector dist = position - collisionShape.position;// - position;
Vector dist = position - collisionShape.position;
float fastLen = dist.getSquaredLength2D();
float totalDist = (radius + collisionShape.radius);
if (fastLen < (totalDist*totalDist))
{
/*
std::ostringstream os;
os << "len " << len << " totalDist " << totalDist;
msg(os.str());
*/
float len = dist.getLength2D();
c.collided = true;
dist.setLength2D(totalDist - len);
//dist |= totalDist;
c.overlap = dist;
}
else
@ -210,11 +179,9 @@ void CollisionShape::render()
drawCircle(radius);
break;
case AABB:
//case CIRCLE:
//glColor3f(1,1,1);
//glLineWidth(2);
glBegin(GL_QUADS);
{
glVertex2f(-xw,yw);
@ -222,21 +189,7 @@ void CollisionShape::render()
glVertex2f(xw,-yw);
glVertex2f(-xw,-yw);
/*
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glVertex2f(topLeft.x, topLeft.y);
glVertex2f(bottomRight.x, topLeft.y);
glVertex2f(bottomRight.x, topLeft.y);
glVertex2f(bottomRight.x, bottomRight.y);
glVertex2f(bottomRight.x, bottomRight.y);
glVertex2f(topLeft.x, bottomRight.y);
glVertex2f(topLeft.x, bottomRight.y);
glVertex2f(topLeft.x, topLeft.y);
*/
}
glEnd();
@ -244,47 +197,11 @@ void CollisionShape::render()
}
glTranslatef(-offsetPosition.x, -offsetPosition.y,0);
//glDisable(GL_BLEND);
}
/*
// FOR EDGES
if (position.y > collisionShape.getY1() - radius && position.y < collisionShape.getY2() + radius)
{
float dist = collisionShape.getX1() - position.x;
if (dist > 0 && dist < radius)
{
c.collided = true;
c.overlap = Vector(radius - dist,0);
}
else if (dist < 0 && -dist < radius)
{
c.collided = true;
c.overlap = -Vector(radius - (-dist),0);
}
}
if (!c.collided)
{
if (position.y > collisionShape.getY1() - radius && position.y < collisionShape.getY2() + radius)
{
float dist = collisionShape.getX2() - position.x;
if (dist > 0 && dist < radius)
{
c.collided = true;
c.overlap += Vector(radius - dist,0);
}
else if (dist < 0 && -dist < radius)
{
c.collided = true;
c.overlap += -Vector(radius - (-dist),0);
}
}
}
*/
CollisionResult CollisionShape::collideCircleWithAABB(CollisionShape &collisionShape, float x, float y, int oH, int oV)
{
@ -296,12 +213,12 @@ CollisionResult CollisionShape::collideCircleWithAABB(CollisionShape &collisionS
//collision with current cell
if(x < y)
{
{
//penetration in x is smaller; project in x
float dx = position.x - collisionShape.position.x;//get sign for projection along x-axis
// msg("oH==0, oV ==0, x <y");
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
if(dx < 0)
@ -316,48 +233,48 @@ CollisionResult CollisionShape::collideCircleWithAABB(CollisionShape &collisionS
}
}
else
{
{
// msg("oH==0, oV ==0, x >= y");
//penetration in y is smaller; project in y
//penetration in y is smaller; project in y
float dy = position.y - collisionShape.position.y;//get sign for projection along y-axis
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
if(dy < 0)
{
c.reportCollision(Vector(0, -y));
return c;
}
else
{
{
c.reportCollision(Vector(0, y));
return c;
}
}
}
}
}
else
{
// msg ("oH == 0, oV != 0");
c.reportCollision(Vector(0, y*oV));
return c;
}
}
else if(oV == 0)
{
// msg ("oV == 0");
c.reportCollision(Vector(x*oH,0));
return c;
}
else
{
{
//diagonal collision
//get diag vertex position
float vx = collisionShape.position.x + (oH*collisionShape.xw);
float vy = collisionShape.position.y + (oV*collisionShape.yw);
float dx = position.x - vx - 1;//calc vert->circle vector
float dx = position.x - vx - 1;//calc vert->circle vector
float dy = position.y - vy - 1;
float len = sqrtf(dx*dx + dy*dy);
float pen = radius - len;
if(0 < pen)
@ -374,16 +291,16 @@ CollisionResult CollisionShape::collideCircleWithAABB(CollisionShape &collisionS
dx /= len;
dy /= len;
}
c.reportCollision(Vector(dx*pen, dy*pen));
//obj.ReportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t);
return c;
}
}
return c;
}
bool CollisionShape::isPointWithin(Vector point)