mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-04 06:54:39 +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:
parent
35a3888c94
commit
e7791c5ddc
4 changed files with 4 additions and 82 deletions
|
@ -8395,21 +8395,15 @@ Bone *Game::collideSkeletalVsCircle(Entity *skeletal, Vector pos, float radius)
|
||||||
{
|
{
|
||||||
Bone *b = skeletal->skeletalSprite.bones[i];
|
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);
|
float checkRadius = sqr(radius+b->collisionMaskRadius);
|
||||||
Vector bonePos = b->getWorldCollidePosition();
|
Vector bonePos = b->getWorldCollidePosition();
|
||||||
float dist = (bonePos - pos).getSquaredLength2D();
|
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
|
// MULTIPLE CIRCLES METHOD
|
||||||
else if (!b->collisionMask.empty())
|
if (!b->collisionMask.empty())
|
||||||
{
|
{
|
||||||
if (dist < checkRadius)
|
if (dist < checkRadius)
|
||||||
{
|
{
|
||||||
|
|
|
@ -937,46 +937,6 @@ void RenderObject::renderCall()
|
||||||
|
|
||||||
void RenderObject::renderCollision()
|
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())
|
if (!collisionMask.empty())
|
||||||
{
|
{
|
||||||
#ifdef BBGE_BUILD_OPENGL
|
#ifdef BBGE_BUILD_OPENGL
|
||||||
|
|
|
@ -68,8 +68,6 @@ struct MotionBlurFrame
|
||||||
float rotz;
|
float rotz;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<RectShape> CollideRects;
|
|
||||||
|
|
||||||
class RenderObjectLayer;
|
class RenderObjectLayer;
|
||||||
|
|
||||||
class RenderObject : public ScriptObject
|
class RenderObject : public ScriptObject
|
||||||
|
@ -285,7 +283,6 @@ public:
|
||||||
std::vector<Vector> collisionMask;
|
std::vector<Vector> collisionMask;
|
||||||
std::vector<Vector> transformedCollisionMask;
|
std::vector<Vector> transformedCollisionMask;
|
||||||
|
|
||||||
CollideRects collisionRects;
|
|
||||||
float collisionMaskRadius;
|
float collisionMaskRadius;
|
||||||
|
|
||||||
float alphaMod;
|
float alphaMod;
|
||||||
|
|
|
@ -956,19 +956,6 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
|
||||||
{
|
{
|
||||||
bone->SetAttribute("sel", this->bones[i]->selectable);
|
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)
|
if (this->bones[i]->rbp)
|
||||||
bone->SetAttribute("rbp", this->bones[i]->rbp);
|
bone->SetAttribute("rbp", this->bones[i]->rbp);
|
||||||
if (this->bones[i]->originalRenderPass)
|
if (this->bones[i]->originalRenderPass)
|
||||||
|
@ -1398,22 +1385,6 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
||||||
if (bone->Attribute("offy"))
|
if (bone->Attribute("offy"))
|
||||||
newb->offset.y = atoi(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"))
|
if (bone->Attribute("prt"))
|
||||||
{
|
{
|
||||||
newb->prt = bone->Attribute("prt");
|
newb->prt = bone->Attribute("prt");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue