forked from mirror/openmw-tes3mp
Revert "Fix race conditions caused by Array <-> GLBufferObject interactions (Bug #3580)"
This reverts commit 115e563a7a
.
This commit is contained in:
parent
f2174ee9f4
commit
6a37909ee7
3 changed files with 19 additions and 41 deletions
|
@ -40,45 +40,32 @@ void ShapeData::read(NIFStream *nif)
|
|||
{
|
||||
int verts = nif->getUShort();
|
||||
|
||||
// Assign a VBO right off the bat to avoid race conditions later, in case two threads load this data into a Geometry at the same time
|
||||
osg::ref_ptr<osg::VertexBufferObject> vbo = new osg::VertexBufferObject;
|
||||
|
||||
if(nif->getInt() && verts)
|
||||
{
|
||||
vertices = new osg::Vec3Array;
|
||||
vertices = new osg::Vec3Array;
|
||||
if(nif->getInt())
|
||||
nif->getVector3s(vertices, verts);
|
||||
vertices->setVertexBufferObject(vbo);
|
||||
}
|
||||
|
||||
if(nif->getInt() && verts)
|
||||
{
|
||||
normals = new osg::Vec3Array(osg::Array::BIND_PER_VERTEX);
|
||||
normals = new osg::Vec3Array(osg::Array::BIND_PER_VERTEX);
|
||||
if(nif->getInt())
|
||||
nif->getVector3s(normals, verts);
|
||||
normals->setVertexBufferObject(vbo);
|
||||
}
|
||||
|
||||
center = nif->getVector3();
|
||||
radius = nif->getFloat();
|
||||
|
||||
if(nif->getInt() && verts)
|
||||
{
|
||||
colors = new osg::Vec4Array(osg::Array::BIND_PER_VERTEX);
|
||||
colors = new osg::Vec4Array(osg::Array::BIND_PER_VERTEX);
|
||||
if(nif->getInt())
|
||||
nif->getVector4s(colors, verts);
|
||||
colors->setVertexBufferObject(vbo);
|
||||
}
|
||||
|
||||
// Only the first 6 bits are used as a count. I think the rest are
|
||||
// flags of some sort.
|
||||
int uvs = nif->getUShort();
|
||||
uvs &= 0x3f;
|
||||
|
||||
if(nif->getInt() && verts)
|
||||
if(nif->getInt())
|
||||
{
|
||||
uvlist.resize(uvs);
|
||||
for(int i = 0;i < uvs;i++)
|
||||
{
|
||||
osg::Vec2Array* list = uvlist[i] = new osg::Vec2Array(osg::Array::BIND_PER_VERTEX);
|
||||
list->setVertexBufferObject(vbo);
|
||||
nif->getVector2s(list, verts);
|
||||
|
||||
// flip the texture coordinates to convert them to the OpenGL convention of bottom-left image origin
|
||||
|
@ -99,14 +86,8 @@ void NiTriShapeData::read(NIFStream *nif)
|
|||
// We have three times as many vertices as triangles, so this
|
||||
// is always equal to tris*3.
|
||||
int cnt = nif->getInt();
|
||||
if (cnt)
|
||||
{
|
||||
triangles = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
|
||||
nif->getUShorts(triangles, cnt);
|
||||
|
||||
// Assign an EBO right off the bat to avoid race conditions later, in case two threads load this data into a Geometry at the same time
|
||||
triangles->setElementBufferObject(new osg::ElementBufferObject);
|
||||
}
|
||||
triangles = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
|
||||
nif->getUShorts(triangles, cnt);
|
||||
|
||||
// Read the match list, which lists the vertices that are equal to
|
||||
// vertices. We don't actually need need this for anything, so
|
||||
|
|
|
@ -268,9 +268,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiTriShape *shape, int flags,
|
|||
|
||||
if (shape->data.empty())
|
||||
return;
|
||||
|
||||
const Nif::NiTriShapeData *data = shape->data.getPtr();
|
||||
if (!data->triangles || !data->vertices)
|
||||
if (shape->data->triangles->empty())
|
||||
return;
|
||||
|
||||
if (isAnimated)
|
||||
|
@ -280,6 +278,8 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiTriShape *shape, int flags,
|
|||
|
||||
btTriangleMesh* childMesh = new btTriangleMesh();
|
||||
|
||||
const Nif::NiTriShapeData *data = shape->data.getPtr();
|
||||
|
||||
childMesh->preallocateVertices(data->vertices->size());
|
||||
childMesh->preallocateIndices(data->triangles->size());
|
||||
|
||||
|
@ -320,6 +320,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiTriShape *shape, int flags,
|
|||
mStaticMesh = new btTriangleMesh(false);
|
||||
|
||||
// Static shape, just transform all vertices into position
|
||||
const Nif::NiTriShapeData *data = shape->data.getPtr();
|
||||
const osg::Vec3Array& vertices = *data->vertices;
|
||||
const osg::DrawElementsUShort& triangles = *data->triangles;
|
||||
|
||||
|
|
|
@ -898,10 +898,6 @@ namespace NifOsg
|
|||
|
||||
osg::BoundingBox box;
|
||||
|
||||
osg::Vec3Array* verts = particledata->vertices;
|
||||
if (!verts)
|
||||
return;
|
||||
|
||||
int i=0;
|
||||
for (std::vector<Nif::NiParticleSystemController::Particle>::const_iterator it = partctrl->particles.begin();
|
||||
i<particledata->activeCount && it != partctrl->particles.end(); ++it, ++i)
|
||||
|
@ -916,11 +912,11 @@ namespace NifOsg
|
|||
// Note this position and velocity is not correct for a particle system with absolute reference frame,
|
||||
// which can not be done in this loader since we are not attached to the scene yet. Will be fixed up post-load in the SceneManager.
|
||||
created->setVelocity(particle.velocity);
|
||||
const osg::Vec3f& position = verts->at(particle.vertex);
|
||||
const osg::Vec3f& position = particledata->vertices->at(particle.vertex);
|
||||
created->setPosition(position);
|
||||
|
||||
osg::Vec4f partcolor (1.f,1.f,1.f,1.f);
|
||||
if (particledata->colors.valid() && particle.vertex < int(particledata->colors->size()))
|
||||
if (particle.vertex < int(particledata->colors->size()))
|
||||
partcolor = particledata->colors->at(particle.vertex);
|
||||
|
||||
float size = particledata->sizes.at(particle.vertex) * partctrl->size;
|
||||
|
@ -1082,7 +1078,7 @@ namespace NifOsg
|
|||
|
||||
geometry->setVertexArray(data->vertices);
|
||||
|
||||
if (data->normals)
|
||||
if (!data->normals->empty())
|
||||
geometry->setNormalArray(data->normals);
|
||||
|
||||
int textureStage = 0;
|
||||
|
@ -1100,10 +1096,10 @@ namespace NifOsg
|
|||
geometry->setTexCoordArray(textureStage, data->uvlist[uvSet]);
|
||||
}
|
||||
|
||||
if (data->colors)
|
||||
if (!data->colors->empty())
|
||||
geometry->setColorArray(data->colors);
|
||||
|
||||
if (data->triangles)
|
||||
if (!data->triangles->empty())
|
||||
geometry->addPrimitiveSet(data->triangles);
|
||||
|
||||
// osg::Material properties are handled here for two reasons:
|
||||
|
@ -1112,7 +1108,7 @@ namespace NifOsg
|
|||
// above the actual renderable would be tedious.
|
||||
std::vector<const Nif::Property*> drawableProps;
|
||||
collectDrawableProperties(triShape, drawableProps);
|
||||
applyDrawableProperties(parentNode, drawableProps, composite, data->colors.valid(), animflags, false);
|
||||
applyDrawableProperties(parentNode, drawableProps, composite, !data->colors->empty(), animflags, false);
|
||||
}
|
||||
|
||||
void handleTriShape(const Nif::NiTriShape* triShape, osg::Group* parentNode, SceneUtil::CompositeStateSetUpdater* composite, const std::vector<int>& boundTextures, int animflags)
|
||||
|
|
Loading…
Reference in a new issue