mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-03 18:14:01 +00:00
Add Lua func bone_getCollisionMaskNormal()
This repurposes the (now, after the prev commit) unused Bone::getCollisionMaskNormal()
This commit is contained in:
parent
640f08af13
commit
d2c0e3e241
3 changed files with 16 additions and 21 deletions
|
@ -6498,6 +6498,15 @@ luaFunc(bone_getName)
|
||||||
luaReturnStr(n);
|
luaReturnStr(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(bone_getCollisionMaskNormal)
|
||||||
|
{
|
||||||
|
Vector n;
|
||||||
|
Bone *b = bone(L);
|
||||||
|
if(b)
|
||||||
|
n = b->getCollisionMaskNormal(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3)), lua_tonumber(L, 4));
|
||||||
|
luaReturnVec2(n.x, n.y);
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(bone_isName)
|
luaFunc(bone_isName)
|
||||||
{
|
{
|
||||||
Bone *b = bone(L);
|
Bone *b = bone(L);
|
||||||
|
@ -10799,6 +10808,7 @@ static const struct {
|
||||||
luaRegister(bone_getName),
|
luaRegister(bone_getName),
|
||||||
luaRegister(bone_isName),
|
luaRegister(bone_isName),
|
||||||
luaRegister(bone_getIndex),
|
luaRegister(bone_getIndex),
|
||||||
|
luaRegister(bone_getCollisionMaskNormal),
|
||||||
luaRegister(node_x),
|
luaRegister(node_x),
|
||||||
luaRegister(node_y),
|
luaRegister(node_y),
|
||||||
luaRegister(node_isEntityPast),
|
luaRegister(node_isEntityPast),
|
||||||
|
|
|
@ -340,31 +340,16 @@ void Bone::renderCollision(const RenderState& rs) const
|
||||||
CollideQuad::renderCollision(rs);
|
CollideQuad::renderCollision(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Bone::getCollisionMaskNormal(size_t index)
|
Vector Bone::getCollisionMaskNormal(Vector pos, float dist) const
|
||||||
{
|
{
|
||||||
Vector sum;
|
Vector sum;
|
||||||
size_t num=0;
|
|
||||||
for (size_t i = 0; i < this->transformedCollisionMask.size(); i++)
|
for (size_t i = 0; i < this->transformedCollisionMask.size(); i++)
|
||||||
{
|
{
|
||||||
if (i != index)
|
Vector diff = pos - transformedCollisionMask[i];
|
||||||
{
|
if (diff.isLength2DIn(dist))
|
||||||
Vector diff = transformedCollisionMask[index] - transformedCollisionMask[i];
|
sum += diff;
|
||||||
if (diff.isLength2DIn(128))
|
|
||||||
{
|
|
||||||
sum += diff;
|
|
||||||
num++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!sum.isZero())
|
sum.normalize2D();
|
||||||
{
|
|
||||||
sum /= num;
|
|
||||||
|
|
||||||
sum.normalize2D();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
int originalRenderPass; // stores the render pass originally set in the XML file. For AC_RESET_PASS.
|
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);
|
void spawnParticlesFromCollisionMask(const char *p, unsigned intv, int layer, float rotz = 0);
|
||||||
Vector getCollisionMaskNormal(size_t index);
|
Vector getCollisionMaskNormal(Vector pos, float dist) const;
|
||||||
|
|
||||||
virtual void renderCollision(const RenderState& rs) const OVERRIDE;
|
virtual void renderCollision(const RenderState& rs) const OVERRIDE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue