1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-01-24 09:16:48 +00:00

add support for Bone to inherit renderpass from parent

This commit is contained in:
fgenesis 2025-01-22 05:36:21 +01:00
parent 6bffa3a3f9
commit 51cf2f75f5
3 changed files with 49 additions and 23 deletions

View file

@ -952,6 +952,7 @@ void AnimationEditor::update(float dt)
Vector ebdata;
int pass = 0;
int origpass = 0;
bool ihp = false;
if (editingBone)
{
@ -961,12 +962,23 @@ void AnimationEditor::update(float dt)
ebdata.z = editingBone->rotation.z;
pass = editingBone->getRenderPass();
origpass = editingBone->originalRenderPass;
ihp = editingBone->inheritPass;
}
text->setText(os.str());
char t2buf[128];
sprintf(t2buf, "Bone x: %.3f, y: %.3f, rot: %.3f strip: %u pass: %d (%d)", ebdata.x, ebdata.y, ebdata.z, (unsigned)selectedStripPoint, pass, origpass);
text2->setText(t2buf);
sprintf(t2buf, "Bone x: %.3f, y: %.3f, rot: %.3f pass: %d", ebdata.x, ebdata.y, ebdata.z, pass);
std::ostringstream os2;
os2 << t2buf;
if(ihp)
os2 << " (from bone " << editingBone->pidx << ")";
else
os2 << " (" << origpass << ")";
if(editMode == AE_STRIP)
os2 << " strip: " << selectedStripPoint;
text2->setText(os2.str());
const float t = getAnimTime();

View file

@ -94,6 +94,7 @@ Bone::Bone() : CollideQuad()
selectable = true;
originalRenderPass = 0;
stripVert = false;
inheritPass = false;
}
Bone::~Bone()
@ -315,6 +316,29 @@ Vector Bone::getCollisionMaskNormal(Vector pos, float dist) const
return sum;
}
void Bone::onUpdate(float dt)
{
if (!collisionMask.empty())
{
if (collisionMask.size() != transformedCollisionMask.size())
{
transformedCollisionMask.resize(collisionMask.size());
}
for (size_t i = 0; i < collisionMask.size(); i++)
{
transformedCollisionMask[i] = getWorldCollidePosition(collisionMask[i]);
}
}
// Do this BEFORE updating children
if(inheritPass)
{
setRenderPass(parent->getRenderPass());
}
CollideQuad::onUpdate(dt);
}
bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
{
@ -818,30 +842,11 @@ void SkeletalSprite::onUpdate(float dt)
if (frozen) return;
RenderObject::onUpdate(dt);
size_t i = 0;
for (i = 0; i < bones.size(); i++)
{
Bone *b = bones[i];
if (b && !b->collisionMask.empty())
{
if (b->collisionMask.size() != b->transformedCollisionMask.size())
{
b->transformedCollisionMask.resize(b->collisionMask.size());
}
for (size_t i = 0; i < b->collisionMask.size(); i++)
{
b->transformedCollisionMask[i] = b->getWorldCollidePosition(b->collisionMask[i]);
}
}
}
for (i = 0; i < animLayers.size(); i++)
for (size_t i = 0; i < animLayers.size(); i++)
{
animLayers[i].update(dt);
}
}
void AnimationLayer::update(float dt)
@ -1003,6 +1008,9 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
bone->SetAttribute("gridDrawOrder", (int)grid->getDrawOrder());
}
if(this->bones[i]->inheritPass)
bone->SetAttribute("ihp", 1);
for(size_t j = 0; j < this->bones[i]->framegfx.size(); ++j)
{
@ -1554,6 +1562,9 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
grid->setDrawOrder((GridDrawOrder)ord);
}
}
if(bone->Attribute("ihp"))
newb->inheritPass = bone->BoolAttribute("ihp");
if(XMLElement *fr = bone->FirstChildElement("Frame"))
{
int frc = 0;

View file

@ -93,8 +93,10 @@ public:
bool stripVert;
bool fileRenderQuad;
bool selectable;
int originalRenderPass; // stores the render pass originally set in the XML file. For AC_RESET_PASS.
bool originalFH;
bool inheritPass;
int originalRenderPass; // stores the render pass originally set in the XML file. For AC_RESET_PASS.
void spawnParticlesFromCollisionMask(const char *p, unsigned intv, int layer, float rotz = 0);
Vector getCollisionMaskNormal(Vector pos, float dist) const;
@ -105,6 +107,7 @@ protected:
std::vector<ParticleEffect*> emitters;
int minDist, maxDist, reverse;
std::vector<Bone*> segments;
void onUpdate(float dt);
public:
std::vector<Vector> collisionMask;
std::vector<Vector> transformedCollisionMask;