Removed Particle::Shape support for QUAD_TRIANGLESTRIP, HEXAGON, USER as these are unlikely to be used as their implementation prevents refactoring to use vertex array code paths

This commit is contained in:
Robert Osfield
2016-08-25 15:13:36 +01:00
parent c637010c9d
commit 56ed225f17
6 changed files with 54 additions and 194 deletions

View File

@@ -145,7 +145,10 @@ void osgParticle::Particle::render(osg::GLBeginEndAdapter* gl, const osg::Vec3&
gl->Vertex3f(xpos.x(), xpos.y(), xpos.z());
break;
case USER:
case QUAD:
case QUAD_TRIANGLESTRIP:
case HEXAGON:
gl->TexCoord2f(_s_coord, _t_coord);
gl->Vertex3fv((xpos-(p1+p2)).ptr());
gl->TexCoord2f(_s_coord+_s_tile, _t_coord);
@@ -156,48 +159,6 @@ void osgParticle::Particle::render(osg::GLBeginEndAdapter* gl, const osg::Vec3&
gl->Vertex3fv((xpos-(p1-p2)).ptr());
break;
case QUAD_TRIANGLESTRIP:
gl->PushMatrix();
gl->Translatef(xpos.x(), xpos.y(), xpos.z());
// we must gl.Begin() and gl.End() here, because each particle is a single strip
gl->Begin(GL_TRIANGLE_STRIP);
gl->TexCoord2f(_s_coord+_s_tile, _t_coord+_t_tile);
gl->Vertex3fv((p1+p2).ptr());
gl->TexCoord2f(_s_coord, _t_coord+_t_tile);
gl->Vertex3fv((-p1+p2).ptr());
gl->TexCoord2f(_s_coord+_s_tile, _t_coord);
gl->Vertex3fv((p1-p2).ptr());
gl->TexCoord2f(_s_coord, _t_coord);
gl->Vertex3fv((-p1-p2).ptr());
gl->End();
gl->PopMatrix();
break;
case HEXAGON:
gl->PushMatrix();
gl->Translatef(xpos.x(), xpos.y(), xpos.z());
// we must gl.Begin() and gl.End() here, because each particle is a single fan
gl->Begin(GL_TRIANGLE_FAN);
gl->TexCoord2f(_s_coord + _s_tile * 0.5f, _t_coord + _t_tile * 0.5f);
gl->Vertex3f(0,0,0);
gl->TexCoord2f(_s_coord + _s_tile * hex_texcoord_x1, _t_coord + _t_tile * hex_texcoord_y1);
gl->Vertex3fv((p1*cosPI3+p2*sinPI3).ptr());
gl->TexCoord2f(_s_coord + _s_tile * hex_texcoord_x2, _t_coord + _t_tile * hex_texcoord_y1);
gl->Vertex3fv((-p1*cosPI3+p2*sinPI3).ptr());
gl->TexCoord2f(_s_coord, _t_coord + _t_tile * 0.5f);
gl->Vertex3fv((-p1).ptr());
gl->TexCoord2f(_s_coord + _s_tile * hex_texcoord_x2, _t_coord + _t_tile * hex_texcoord_y2);
gl->Vertex3fv((-p1*cosPI3-p2*sinPI3).ptr());
gl->TexCoord2f(_s_coord + _s_tile * hex_texcoord_x1, _t_coord + _t_tile * hex_texcoord_y2);
gl->Vertex3fv((p1*cosPI3-p2*sinPI3).ptr());
gl->TexCoord2f(_s_coord + _s_tile, _t_coord + _t_tile * 0.5f);
gl->Vertex3fv((p1).ptr());
gl->TexCoord2f(_s_coord + _s_tile * hex_texcoord_x1, _t_coord + _t_tile * hex_texcoord_y1);
gl->Vertex3fv((p1*cosPI3+p2*sinPI3).ptr());
gl->End();
gl->PopMatrix();
break;
case LINE:
{
// Get the normalized direction of the particle, to be used in the
@@ -219,35 +180,6 @@ void osgParticle::Particle::render(osg::GLBeginEndAdapter* gl, const osg::Vec3&
}
}
void osgParticle::Particle::render(osg::RenderInfo& renderInfo, const osg::Vec3& xpos, const osg::Vec3& xrot) const
{
#if defined(OSG_GL_MATRICES_AVAILABLE)
if (_drawable.valid())
{
bool requiresRotation = (xrot.x()!=0.0f || xrot.y()!=0.0f || xrot.z()!=0.0f);
glColor4f(_current_color.x(),
_current_color.y(),
_current_color.z(),
_current_color.w() * _current_alpha);
glPushMatrix();
glTranslatef(xpos.x(), xpos.y(), xpos.z());
if (requiresRotation)
{
osg::Quat rotation(xrot.x(), osg::X_AXIS, xrot.y(), osg::Y_AXIS, xrot.z(), osg::Z_AXIS);
#if defined(OSG_GLES1_AVAILABLE)
glMultMatrixf(osg::Matrixf(rotation).ptr());
#else
glMultMatrixd(osg::Matrixd(rotation).ptr());
#endif
}
_drawable->draw(renderInfo);
glPopMatrix();
}
#else
OSG_NOTICE<<"Warning: Particle::render(..) not supported for user-defined shape."<<std::endl;
#endif
}
void osgParticle::Particle::setUpTexCoordsAsPartOfConnectedParticleSystem(ParticleSystem* ps)
{
if (getPreviousParticle()!=Particle::INVALID_INDEX)