mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-27 16:44:00 +00:00
make RenderObject::position not modified during rendering; small cleanup
This commit is contained in:
parent
01295cda7a
commit
7a5a5feb39
3 changed files with 40 additions and 38 deletions
|
@ -462,28 +462,26 @@ void RenderObject::render(const RenderState& rs) const
|
||||||
if (MotionBlurData *mb = this->motionBlur)
|
if (MotionBlurData *mb = this->motionBlur)
|
||||||
{
|
{
|
||||||
RenderState rx(rs);
|
RenderState rx(rs);
|
||||||
const Vector oldPos = position;
|
|
||||||
const float oldRotZ = rotation.z;
|
const float oldRotZ = rotation.z;
|
||||||
const size_t sz = mb->positions.size();
|
const size_t sz = mb->positions.size();
|
||||||
const float m = 1.0f / float(sz);
|
const float m = 1.0f / float(sz);
|
||||||
const float m2 = alpha.x * 0.5f * (mb->transition ? mb->transitionTimer : 1.0f);
|
const float m2 = alpha.x * 0.5f * (mb->transition ? mb->transitionTimer : 1.0f);
|
||||||
for (size_t i = 0; i < sz; i++)
|
for (size_t i = 0; i < sz; i++)
|
||||||
{
|
{
|
||||||
position = mb->positions[i].position;
|
const Vector& renderAt = mb->positions[i].position;
|
||||||
rotation.z = mb->positions[i].rotz;
|
rotation.z = mb->positions[i].rotz;
|
||||||
rx.alpha = (1.0f-(float(i) * m)) * m2;
|
rx.alpha = (1.0f-(float(i) * m)) * m2;
|
||||||
renderCall(rx);
|
renderCall(rx, renderAt);
|
||||||
}
|
}
|
||||||
position = oldPos;
|
|
||||||
rotation.z = oldRotZ;
|
rotation.z = oldRotZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCall(rs);
|
renderCall(rs, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::renderCall(const RenderState& rs) const
|
void RenderObject::renderCall(const RenderState& rs, const Vector& renderAt) const
|
||||||
{
|
{
|
||||||
position += offset;
|
const Vector renderPos = renderAt + offset;
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
@ -502,7 +500,7 @@ void RenderObject::renderCall(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
|
glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(renderPos.x, renderPos.y, renderPos.z);
|
||||||
if (isfh())
|
if (isfh())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -527,34 +525,38 @@ void RenderObject::renderCall(const RenderState& rs) const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(renderPos.x, renderPos.y, renderPos.z);
|
||||||
|
|
||||||
if (RenderObject::renderPaths && position.data && position.data->path.getNumPathNodes() > 0)
|
// TODO: move this to debug render
|
||||||
{
|
if (RenderObject::renderPaths && position.data)
|
||||||
glLineWidth(4);
|
if(size_t N = position.data->path.getNumPathNodes())
|
||||||
glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
|
||||||
for (i = 0; i < position.data->path.getNumPathNodes()-1; i++)
|
|
||||||
{
|
{
|
||||||
glVertex2f(position.data->path.getPathNode(i)->value.x-position.x, position.data->path.getPathNode(i)->value.y-position.y);
|
glLineWidth(4);
|
||||||
glVertex2f(position.data->path.getPathNode(i+1)->value.x-position.x, position.data->path.getPathNode(i+1)->value.y-position.y);
|
glEnable(GL_BLEND);
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glPointSize(20);
|
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
glBegin(GL_POINTS);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glColor4f(0.5,0.5,1,1);
|
|
||||||
for (i = 0; i < position.data->path.getNumPathNodes(); i++)
|
glBegin(GL_LINES);
|
||||||
{
|
for (size_t i = 0; i < N-1; i++)
|
||||||
glVertex2f(position.data->path.getPathNode(i)->value.x-position.x, position.data->path.getPathNode(i)->value.y-position.y);
|
{
|
||||||
|
const VectorPathNode a = position.data->path[i];
|
||||||
|
const VectorPathNode b = position.data->path[i+1];
|
||||||
|
glVertex2f(a.value.x-position.x, a.value.y-position.y);
|
||||||
|
glVertex2f(b.value.x-position.x, b.value.y-position.y);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glPointSize(20);
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
glColor4f(0.5,0.5,1,1);
|
||||||
|
for (size_t i = 0; i < N; i++)
|
||||||
|
{
|
||||||
|
const VectorPathNode& a = position.data->path[i];
|
||||||
|
glVertex2f(a.value.x-position.x, a.value.y-position.y);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
}
|
}
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
|
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
|
||||||
if (isfh())
|
if (isfh())
|
||||||
|
@ -620,9 +622,6 @@ void RenderObject::renderCall(const RenderState& rs) const
|
||||||
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
position -= offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::renderCollision(const RenderState& rs) const
|
void RenderObject::renderCollision(const RenderState& rs) const
|
||||||
|
|
|
@ -252,7 +252,8 @@ public:
|
||||||
char _blendType;
|
char _blendType;
|
||||||
|
|
||||||
|
|
||||||
mutable InterpolatedVector position, scale;
|
InterpolatedVector position;
|
||||||
|
mutable InterpolatedVector scale;
|
||||||
InterpolatedVector color, alpha;
|
InterpolatedVector color, alpha;
|
||||||
mutable InterpolatedVector rotation;
|
mutable InterpolatedVector rotation;
|
||||||
InterpolatedVector offset, rotationOffset, internalOffset, beforeScaleOffset;
|
InterpolatedVector offset, rotationOffset, internalOffset, beforeScaleOffset;
|
||||||
|
@ -300,7 +301,7 @@ protected:
|
||||||
// Is this object or any of its children rendered in pass "pass"?
|
// Is this object or any of its children rendered in pass "pass"?
|
||||||
bool hasRenderPass(const int pass) const;
|
bool hasRenderPass(const int pass) const;
|
||||||
|
|
||||||
inline void renderCall(const RenderState& rs) const;
|
inline void renderCall(const RenderState& rs, const Vector& renderAt) const;
|
||||||
virtual void renderCollision(const RenderState& rs) const;
|
virtual void renderCollision(const RenderState& rs) const;
|
||||||
|
|
||||||
typedef std::list<RenderObject*> RenderObjectList;
|
typedef std::list<RenderObject*> RenderObjectList;
|
||||||
|
|
|
@ -375,9 +375,11 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
void addPathNode(Vector v, float p);
|
void addPathNode(Vector v, float p);
|
||||||
Vector getValue(float percent);
|
Vector getValue(float percent);
|
||||||
size_t getNumPathNodes() { return pathNodes.size(); }
|
inline size_t getNumPathNodes() { return pathNodes.size(); }
|
||||||
void resizePathNodes(size_t sz) { pathNodes.resize(sz); }
|
void resizePathNodes(size_t sz) { pathNodes.resize(sz); }
|
||||||
VectorPathNode *getPathNode(size_t i) { if (i<getNumPathNodes()) return &pathNodes[i]; return 0; }
|
VectorPathNode *getPathNode(size_t i) { if (i<getNumPathNodes()) return &pathNodes[i]; return 0; }
|
||||||
|
inline VectorPathNode& operator[](size_t i) { return pathNodes[i]; }
|
||||||
|
inline const VectorPathNode& operator[](size_t i) const { return pathNodes[i]; }
|
||||||
void cut(int n);
|
void cut(int n);
|
||||||
void splice(const VectorPath &path, int sz);
|
void splice(const VectorPath &path, int sz);
|
||||||
void prepend(const VectorPath &path);
|
void prepend(const VectorPath &path);
|
||||||
|
|
Loading…
Add table
Reference in a new issue