mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-05-10 19:13:44 +00:00
Move members related to collision mask from RenderObject to Bone
This commit is contained in:
parent
e33bde0a89
commit
111cd43805
8 changed files with 81 additions and 87 deletions
|
@ -2923,9 +2923,9 @@ void DSQ::doSaveSlotMenu(SaveSlotMode ssm, const Vector &position)
|
||||||
|
|
||||||
std::string DSQ::getEntityFlagName(Entity *e)
|
std::string DSQ::getEntityFlagName(Entity *e)
|
||||||
{
|
{
|
||||||
if (!dsq->game) return "";
|
if (!game) return "";
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << dsq->game->sceneName << e->startPos.x << e->startPos.y;
|
os << game->sceneName << e->startPos.x << e->startPos.y;
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2947,13 +2947,6 @@ void doAlphabetInputKey(int d, char c, char map[], std::string *text, char upper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSQ::generateCollisionMask(RenderObject *r)
|
|
||||||
{
|
|
||||||
Quad *q = dynamic_cast<Quad*>(r);
|
|
||||||
if (q)
|
|
||||||
game->generateCollisionMask(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSQ::onConfirmYes()
|
void DSQ::onConfirmYes()
|
||||||
{
|
{
|
||||||
dsq->confirmDone = 1;
|
dsq->confirmDone = 1;
|
||||||
|
|
|
@ -258,7 +258,6 @@ public:
|
||||||
|
|
||||||
void takeScreenshotKey();
|
void takeScreenshotKey();
|
||||||
|
|
||||||
void generateCollisionMask(RenderObject *r);
|
|
||||||
void toggleRenderCollisionShapes();
|
void toggleRenderCollisionShapes();
|
||||||
|
|
||||||
void voice(const std::string &file, float volMod = -1);
|
void voice(const std::string &file, float volMod = -1);
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ void Game::setTimerText(float time)
|
||||||
timerText->setText(os.str());
|
timerText->setText(os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::generateCollisionMask(Quad *q, float overrideCollideRadius /* = 0 */)
|
void Game::generateCollisionMask(Bone *q, float overrideCollideRadius /* = 0 */)
|
||||||
{
|
{
|
||||||
if (q->texture)
|
if (q->texture)
|
||||||
{
|
{
|
||||||
|
|
|
@ -304,7 +304,7 @@ public:
|
||||||
void setTimerTextAlpha(float a, float t);
|
void setTimerTextAlpha(float a, float t);
|
||||||
void setTimerText(float time);
|
void setTimerText(float time);
|
||||||
|
|
||||||
void generateCollisionMask(Quad *q, float overrideCollideRadius=0);
|
void generateCollisionMask(Bone *q, float overrideCollideRadius=0);
|
||||||
std::string fromScene, toNode;
|
std::string fromScene, toNode;
|
||||||
int toFlip;
|
int toFlip;
|
||||||
char fromWarpType;
|
char fromWarpType;
|
||||||
|
|
|
@ -136,7 +136,6 @@ RenderObject::RenderObject()
|
||||||
overrideCullRadiusSqr = 0;
|
overrideCullRadiusSqr = 0;
|
||||||
repeatTexture = false;
|
repeatTexture = false;
|
||||||
alphaMod = 1;
|
alphaMod = 1;
|
||||||
collisionMaskRadius = 0;
|
|
||||||
collideRadius = 0;
|
collideRadius = 0;
|
||||||
motionBlurTransition = false;
|
motionBlurTransition = false;
|
||||||
motionBlurFrameOffsetCounter = 0;
|
motionBlurFrameOffsetCounter = 0;
|
||||||
|
@ -770,44 +769,7 @@ void RenderObject::renderCall()
|
||||||
|
|
||||||
void RenderObject::renderCollision()
|
void RenderObject::renderCollision()
|
||||||
{
|
{
|
||||||
if (!collisionMask.empty())
|
if (collideRadius > 0)
|
||||||
{
|
|
||||||
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,1,0,0.5);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < transformedCollisionMask.size(); i++)
|
|
||||||
{
|
|
||||||
Vector collide = this->transformedCollisionMask[i];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glTranslatef(collide.x, collide.y, 0);
|
|
||||||
RenderObject *parent = this->getTopParent();
|
|
||||||
if (parent)
|
|
||||||
drawCircle(collideRadius*parent->scale.x, 45);
|
|
||||||
glTranslatef(-collide.x, -collide.y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glPopMatrix();
|
|
||||||
glPopAttrib();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (collideRadius > 0)
|
|
||||||
{
|
{
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -818,8 +780,6 @@ void RenderObject::renderCollision()
|
||||||
glTranslatef(internalOffset.x, internalOffset.y, 0);
|
glTranslatef(internalOffset.x, internalOffset.y, 0);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glColor4f(1,0,0,0.5);
|
glColor4f(1,0,0,0.5);
|
||||||
drawCircle(collideRadius, 8);
|
drawCircle(collideRadius, 8);
|
||||||
|
@ -840,34 +800,6 @@ void RenderObject::deathNotify(RenderObject *r)
|
||||||
deathNotifications.remove(r);
|
deathNotifications.remove(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector RenderObject::getCollisionMaskNormal(size_t index)
|
|
||||||
{
|
|
||||||
Vector sum;
|
|
||||||
size_t num=0;
|
|
||||||
for (size_t i = 0; i < this->transformedCollisionMask.size(); i++)
|
|
||||||
{
|
|
||||||
if (i != index)
|
|
||||||
{
|
|
||||||
Vector diff = transformedCollisionMask[index] - transformedCollisionMask[i];
|
|
||||||
if (diff.isLength2DIn(128))
|
|
||||||
{
|
|
||||||
sum += diff;
|
|
||||||
num++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sum.isZero())
|
|
||||||
{
|
|
||||||
sum /= num;
|
|
||||||
|
|
||||||
sum.normalize2D();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxAngle, float offset)
|
void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxAngle, float offset)
|
||||||
{
|
{
|
||||||
Vector myPos = this->getWorldPosition();
|
Vector myPos = this->getWorldPosition();
|
||||||
|
|
|
@ -217,8 +217,6 @@ public:
|
||||||
virtual void unloadDevice();
|
virtual void unloadDevice();
|
||||||
virtual void reloadDevice();
|
virtual void reloadDevice();
|
||||||
|
|
||||||
Vector getCollisionMaskNormal(size_t index);
|
|
||||||
|
|
||||||
//-------------------------------- Methods above, fields below
|
//-------------------------------- Methods above, fields below
|
||||||
|
|
||||||
static bool renderCollisionShape;
|
static bool renderCollisionShape;
|
||||||
|
@ -271,10 +269,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
float collideRadius;
|
float collideRadius;
|
||||||
std::vector<Vector> collisionMask;
|
|
||||||
std::vector<Vector> transformedCollisionMask;
|
|
||||||
|
|
||||||
float collisionMaskRadius;
|
|
||||||
|
|
||||||
float alphaMod;
|
float alphaMod;
|
||||||
|
|
||||||
|
@ -311,7 +306,7 @@ protected:
|
||||||
bool hasRenderPass(const int pass);
|
bool hasRenderPass(const int pass);
|
||||||
|
|
||||||
inline void renderCall();
|
inline void renderCall();
|
||||||
void renderCollision();
|
virtual void renderCollision();
|
||||||
|
|
||||||
bool repeatTexture;
|
bool repeatTexture;
|
||||||
unsigned char pm; // unsigned char to save space
|
unsigned char pm; // unsigned char to save space
|
||||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "MathFunctions.h"
|
#include "MathFunctions.h"
|
||||||
#include "SimpleIStringStream.h"
|
#include "SimpleIStringStream.h"
|
||||||
#include "ReadXML.h"
|
#include "ReadXML.h"
|
||||||
|
#include "RenderBase.h"
|
||||||
|
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
@ -77,6 +78,7 @@ Bone::Bone() : Quad()
|
||||||
boneIdx = pidx = -1;
|
boneIdx = pidx = -1;
|
||||||
rbp = false;
|
rbp = false;
|
||||||
segmentChain = 0;
|
segmentChain = 0;
|
||||||
|
collisionMaskRadius = 0;
|
||||||
|
|
||||||
minDist = maxDist = 128;
|
minDist = maxDist = 128;
|
||||||
reverse = false;
|
reverse = false;
|
||||||
|
@ -295,6 +297,72 @@ void Bone::spawnParticlesFromCollisionMask(const char *p, unsigned intv, int lay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bone::renderCollision()
|
||||||
|
{
|
||||||
|
if (!collisionMask.empty())
|
||||||
|
{
|
||||||
|
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,1,0,0.5);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < transformedCollisionMask.size(); i++)
|
||||||
|
{
|
||||||
|
Vector collide = this->transformedCollisionMask[i];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glTranslatef(collide.x, collide.y, 0);
|
||||||
|
RenderObject *parent = this->getTopParent();
|
||||||
|
if (parent)
|
||||||
|
drawCircle(collideRadius*parent->scale.x, 45);
|
||||||
|
glTranslatef(-collide.x, -collide.y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
glPopMatrix();
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Quad::renderCollision();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector Bone::getCollisionMaskNormal(size_t index)
|
||||||
|
{
|
||||||
|
Vector sum;
|
||||||
|
size_t num=0;
|
||||||
|
for (size_t i = 0; i < this->transformedCollisionMask.size(); i++)
|
||||||
|
{
|
||||||
|
if (i != index)
|
||||||
|
{
|
||||||
|
Vector diff = transformedCollisionMask[index] - transformedCollisionMask[i];
|
||||||
|
if (diff.isLength2DIn(128))
|
||||||
|
{
|
||||||
|
sum += diff;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!sum.isZero())
|
||||||
|
{
|
||||||
|
sum /= num;
|
||||||
|
|
||||||
|
sum.normalize2D();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,11 +92,18 @@ 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);
|
||||||
|
|
||||||
|
virtual void renderCollision();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<ParticleEffect*> emitters;
|
std::vector<ParticleEffect*> emitters;
|
||||||
int minDist, maxDist, reverse;
|
int minDist, maxDist, reverse;
|
||||||
std::vector<Bone*> segments;
|
std::vector<Bone*> segments;
|
||||||
|
public:
|
||||||
|
std::vector<Vector> collisionMask;
|
||||||
|
std::vector<Vector> transformedCollisionMask;
|
||||||
|
float collisionMaskRadius;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BoneCommand
|
class BoneCommand
|
||||||
|
|
Loading…
Add table
Reference in a new issue