mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 14:34:34 +00:00
Small extension to bone:
+ attrib c="0" in the anim XML to turn off all collision for a bone even if collide radius or collision mask is set + Lua func: bone_toggleCollision() to change the above setting at runtime + Lua func: bone_spawnParticlesFromCollisionMask() - Fix int truncation in entity_collideSkeletalVsLine()
This commit is contained in:
parent
bdd422bd59
commit
e33bde0a89
6 changed files with 72 additions and 25 deletions
|
@ -71,6 +71,7 @@ Bone::Bone() : Quad()
|
|||
fileRenderQuad = true;
|
||||
skeleton = 0;
|
||||
generateCollisionMask = true;
|
||||
enableCollision = true;
|
||||
animated = ANIM_ALL;
|
||||
originalScale = Vector(1,1);
|
||||
boneIdx = pidx = -1;
|
||||
|
@ -101,6 +102,11 @@ void Bone::destroy()
|
|||
segments.clear();
|
||||
}
|
||||
|
||||
bool Bone::canCollide() const
|
||||
{
|
||||
return this->enableCollision && this->alpha.x == 1 && this->renderQuad && (!this->collisionMask.empty() || this->collideRadius);
|
||||
}
|
||||
|
||||
void Bone::addSegment(Bone *b)
|
||||
{
|
||||
segments.push_back(b);
|
||||
|
@ -280,6 +286,16 @@ void Bone::updateSegments()
|
|||
}
|
||||
}
|
||||
|
||||
void Bone::spawnParticlesFromCollisionMask(const char *p, unsigned intv, int layer, float rotz)
|
||||
{
|
||||
for (size_t j = 0; j < this->collisionMask.size(); j+=intv)
|
||||
{
|
||||
Vector pos = this->getWorldCollidePosition(this->collisionMask[j]);
|
||||
core->createParticleEffect(p, pos, layer, rotz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||
{
|
||||
std::string type;
|
||||
|
@ -895,6 +911,8 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
|
|||
bone->SetAttribute("fv", this->bones[i]->isfv());
|
||||
bone->SetAttribute("gc", this->bones[i]->generateCollisionMask);
|
||||
bone->SetAttribute("cr", this->bones[i]->collideRadius);
|
||||
if(!this->bones[i]->enableCollision)
|
||||
bone->SetAttribute("c", this->bones[i]->enableCollision);
|
||||
if (!this->bones[i]->fileRenderQuad)
|
||||
{
|
||||
bone->SetAttribute("rq", this->bones[i]->fileRenderQuad);
|
||||
|
@ -1368,6 +1386,10 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
{
|
||||
newb->generateCollisionMask = atoi(bone->Attribute("gc"));
|
||||
}
|
||||
if (bone->Attribute("c"))
|
||||
{
|
||||
newb->enableCollision = atoi(bone->Attribute("c"));
|
||||
}
|
||||
if (bone->Attribute("rq"))
|
||||
{
|
||||
newb->renderQuad = newb->fileRenderQuad = atoi(bone->Attribute("rq"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue