Fixed crash when using ShapeDrawable with a TriangleMesh or ConvexHull shape due to missing texture coords

OpenSceneGraph-3.6
Robert Osfield 6 years ago
parent 7a3e0445ba
commit 640b03b671

@ -768,10 +768,13 @@ class OSG_EXPORT BuildShapeGeometryVisitor : public ConstShapeVisitor
virtual void apply(const CompositeShape&);
void Normal(const Vec3f& v) { _normals->push_back(v); }
void Normal3f(float x, float y, float z) { _normals->push_back(Vec3(x,y,z)); }
void TexCoord2f(float x, float y) { _texcoords->push_back(Vec2(x,y)); }
void Vertex(const Vec3f& v) { _vertices->push_back(v); }
void Vertex3f(float x, float y, float z) { _vertices->push_back(Vec3(x,y,z)); }
void Normal3f(float x, float y, float z) { Normal(Vec3(x,y,z)); }
void TexCoord(const Vec2f& tc) { _texcoords->push_back(tc); }
void TexCoord2f(float x, float y) { TexCoord(Vec2(x,y)); }
void Vertex(const Vec3f& v);
void Vertex3f(float x, float y, float z) { Vertex(Vec3(x,y,z)); }
void setMatrix(const Matrixd& m);

@ -233,6 +233,20 @@ void BuildShapeGeometryVisitor::setMatrix(const Matrixd& m)
_inverse.setTrans(0.0,0.0,0.0);
}
void BuildShapeGeometryVisitor::Vertex(const Vec3f& v)
{
_vertices->push_back(v);
if (_normals.valid() && _normals->size()<_vertices->size())
{
while(_normals->size()<_vertices->size()) _normals->push_back(osg::Vec3(0.0f, 0.0f, 1.0f));
}
if (_texcoords.valid() && _texcoords->size()<_vertices->size())
{
while(_texcoords->size()<_vertices->size()) _texcoords->push_back(osg::Vec2(0.0f, 0.0f));
}
}
void BuildShapeGeometryVisitor::Begin(GLenum mode)
{
_mode = mode;

Loading…
Cancel
Save