1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 17:53:47 +00:00

Remove RenderObject::collisionRects.

Another vector that was always empty, optionally filled when specified
by a skeletal file, but none actually did this. Should be safe to remove.

Also small related optimization in Game::collideSkeletalVsCircle().
This commit is contained in:
fgenesis 2016-05-07 01:00:16 +02:00
parent 35a3888c94
commit e7791c5ddc
4 changed files with 4 additions and 82 deletions

View file

@ -8395,21 +8395,15 @@ Bone *Game::collideSkeletalVsCircle(Entity *skeletal, Vector pos, float radius)
{
Bone *b = skeletal->skeletalSprite.bones[i];
if (b->alpha.x == 1 && b->renderQuad)
if (b->alpha.x == 1 && b->renderQuad &&
(!b->collisionMask.empty() || b->collideRadius) // check this here to avoid calculating getWorldCollidePosition() if not necessary
)
{
float checkRadius = sqr(radius+b->collisionMaskRadius);
Vector bonePos = b->getWorldCollidePosition();
float dist = (bonePos - pos).getSquaredLength2D();
// BOUND RECT METHOD
if (!b->collisionRects.empty())
{
for (int i = 0; i < b->collisionRects.size(); i++)
{
b->collisionRects[i].isCoordinateInside(pos, radius);
}
}
// MULTIPLE CIRCLES METHOD
else if (!b->collisionMask.empty())
if (!b->collisionMask.empty())
{
if (dist < checkRadius)
{

View file

@ -937,46 +937,6 @@ void RenderObject::renderCall()
void RenderObject::renderCollision()
{
if (!collisionRects.empty())
{
#ifdef BBGE_BUILD_OPENGL
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, 0);
//glLoadIdentity();
//core->setupRenderPositionAndScale();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1.0f, 0.5f, 1.0f, 0.5f);
glPointSize(5);
for (int i = 0; i < collisionRects.size(); i++)
{
RectShape *r = &collisionRects[i];
glBegin(GL_QUADS);
glVertex3f(r->x1, r->y1, 0);
glVertex3f(r->x1, r->y2, 0);
glVertex3f(r->x2, r->y2, 0);
glVertex3f(r->x2, r->y1, 0);
glEnd();
glBegin(GL_POINTS);
glVertex3f(r->x1, r->y1, 0);
glVertex3f(r->x1, r->y2, 0);
glVertex3f(r->x2, r->y2, 0);
glVertex3f(r->x2, r->y1, 0);
glEnd();
}
glPopMatrix();
glDisable(GL_BLEND);
glPopAttrib();
#endif
}
if (!collisionMask.empty())
{
#ifdef BBGE_BUILD_OPENGL

View file

@ -68,8 +68,6 @@ struct MotionBlurFrame
float rotz;
};
typedef std::vector<RectShape> CollideRects;
class RenderObjectLayer;
class RenderObject : public ScriptObject
@ -285,7 +283,6 @@ public:
std::vector<Vector> collisionMask;
std::vector<Vector> transformedCollisionMask;
CollideRects collisionRects;
float collisionMaskRadius;
float alphaMod;

View file

@ -956,19 +956,6 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
{
bone->SetAttribute("sel", this->bones[i]->selectable);
}
if (!this->bones[i]->collisionRects.empty())
{
std::ostringstream os;
os << this->bones[i]->collisionRects.size() << " ";
for (int j = 0; j < this->bones[i]->collisionRects.size(); j++)
{
RectShape *r = &this->bones[i]->collisionRects[j];
int x, y, w, h;
r->getCWH(&x, &y, &w, &h);
os << x << " " << y << " " << w << " " << h << " ";
}
bone->SetAttribute("crects", os.str().c_str());
}
if (this->bones[i]->rbp)
bone->SetAttribute("rbp", this->bones[i]->rbp);
if (this->bones[i]->originalRenderPass)
@ -1398,22 +1385,6 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
if (bone->Attribute("offy"))
newb->offset.y = atoi(bone->Attribute("offy"));
if (bone->Attribute("crects"))
{
SimpleIStringStream is(bone->Attribute("crects"));
int num = 0;
is >> num;
for (int i = 0; i < num; i++)
{
RectShape r;
int x, y, w, h;
is >> x >> y >> w >> h;
r.setCWH(x, y, w, h);
newb->collisionRects.push_back(r);
}
}
if (bone->Attribute("prt"))
{
newb->prt = bone->Attribute("prt");