Merge branch 'master' into shader_pipeline

This commit is contained in:
Robert Osfield 2017-12-03 11:34:15 +00:00
commit bd95db2031
23 changed files with 69 additions and 109 deletions

View File

@ -740,7 +740,7 @@ int main( int argc, char **argv )
while(arguments.read("--addMissingColours") || arguments.read("--addMissingColors")) { addMissingColours = true; }
bool do_overallNormal = false;
while(arguments.read("--overallNormal") || arguments.read("--overallNormal")) { do_overallNormal = true; }
while(arguments.read("--overallNormal")) { do_overallNormal = true; }
bool enableObjectCache = false;
while(arguments.read("--enable-object-cache")) { enableObjectCache = true; }

View File

@ -570,16 +570,11 @@ void Geometry::setUseVertexBufferObjects(bool flag)
DrawElementsList drawElementsList;
getDrawElementsList(drawElementsList);
typedef std::vector<osg::VertexBufferObject*> VertexBufferObjectList;
typedef std::vector<osg::ElementBufferObject*> ElementBufferObjectList;
/*if (_useVertexBufferObjects)*/
{
if (!arrayList.empty())
{
VertexBufferObjectList vboList;
osg::ref_ptr<osg::VertexBufferObject> vbo;
ArrayList::iterator vitr;
@ -604,8 +599,6 @@ void Geometry::setUseVertexBufferObjects(bool flag)
if (!drawElementsList.empty())
{
ElementBufferObjectList eboList;
osg::ref_ptr<osg::ElementBufferObject> ebo;
DrawElementsList::iterator deitr;

View File

@ -1447,15 +1447,19 @@ namespace State_Utils
if (str[pos]=='"' || str[pos]=='\'')
{
std::string::size_type start_quote = pos;
++pos;
++pos; // skip over first quote
pos = str.find(str[start_quote], pos);
if (pos!=std::string::npos)
{
++pos; // skip over second quote
}
}
else
{
std::string::size_type start_var = pos;
++pos;
pos = str.find_first_not_of("ABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_", pos);
std::string var_str;
if (pos != std::string::npos)
{

View File

@ -39,17 +39,6 @@ int __gl_memInit( size_t /*maxFast*/ )
{
#ifndef NO_MALLOPT
/* mallopt( M_MXFAST, maxFast );*/
#ifdef MEMORY_DEBUG
mallopt( M_DEBUG, 1 );
#endif
#endif
return 1;
}
#ifdef MEMORY_DEBUG
void *__gl_memAlloc( size_t n )
{
return memset( malloc( n ), 0xa5, n );
}
#endif

View File

@ -41,14 +41,8 @@
#define memFree free
#define memInit __gl_memInit
/*extern void __gl_memInit( size_t );*/
extern int __gl_memInit( size_t );
#ifndef MEMORY_DEBUG
#define memAlloc malloc
#else
#define memAlloc __gl_memAlloc
extern void * __gl_memAlloc( size_t );
#endif
#endif

View File

@ -409,7 +409,6 @@ struct ValueTextDrawCallback : public virtual osg::Drawable::DrawCallback
if (!visitor)
return;
std::string font("fonts/arial.ttf");
float leftPos = 10.0f;
float characterSize = 20.0f;
@ -427,7 +426,7 @@ struct ValueTextDrawCallback : public virtual osg::Drawable::DrawCallback
}
const std::vector<std::string>& channels = visitor->getChannels();
std::map<std::string,int> size;
// std::map<std::string,int> size;
for (int i = 0; i < (int)channels.size(); i++) {
std::string name = channels[i];
if (_actions.find(name) == _actions.end()) {
@ -440,14 +439,14 @@ struct ValueTextDrawCallback : public virtual osg::Drawable::DrawCallback
//_actions[name].touch();
}
_actions[name]._group->setNodeMask(~osg::Node::NodeMask(0x0));
size[name] = 0;
//size[name] = 0;
pos.y() -= characterSize + graphSpacing;
}
pos.y() -= backgroundMargin;
osg::Vec3Array* array = static_cast<osg::Vec3Array*>(_background->getVertexArray());
float y = (*array)[0][1];
y = y - (pos.y() + backgroundMargin); //(2 * backgroundMargin + (size.size() * (characterSize + graphSpacing)));
// float y = (*array)[0][1];
// y = y - (pos.y() + backgroundMargin); //(2 * backgroundMargin + (size.size() * (characterSize + graphSpacing)));
(*array)[1][1] = pos.y();
(*array)[2][1] = pos.y();
array->dirty();

View File

@ -77,10 +77,6 @@ void StatsActionVisitor::apply(ActionStripAnimation& action)
if (isActive(action))
{
_channels.push_back(action.getName());
double value;
std::string name = action.getName();
if (_stats->getAttribute(_frame, name, value))
name += "+";
_stats->setAttribute(_frame, action.getName(), action.getAnimation()->getAnimation()->getWeight());
}
}

View File

@ -709,7 +709,12 @@ osg::ref_ptr<osg::Image> InputStream::readImage(bool readFromExternal)
char* data = new char[size];
if ( !data )
throwException( "InputStream::readImage() Out of memory." );
if ( getException() ) return NULL;
if ( getException() )
{
delete [] data;
return NULL;
}
readCharArray( data, size );
image = new osg::Image;

View File

@ -860,7 +860,6 @@ void OutputStream::writeSchema( std::ostream& fout )
ObjectWrapper::TypeList types;
wrapper->writeSchema( properties, types );
std::string propertiesString;
unsigned int size = osg::minimum( properties.size(), types.size() );
for ( unsigned int i=0; i<size; ++i )
{

View File

@ -536,11 +536,6 @@ void UFOManipulator::_adjustPosition()
return;
// Forward line segment at 3 times our intersect distance
typedef std::vector<osg::Vec3d> Intersections;
Intersections intersections;
// Check intersects infront.
osg::Vec3d ip;
if (intersect(_position,

View File

@ -36,8 +36,6 @@ Q3BSPReader::Q3BSPReader()
bool Q3BSPReader::readFile(const std::string& file,
const osgDB::ReaderWriter::Options* options)
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
Q3BSPLoad load_data;
load_data.Load(file,8);
@ -513,7 +511,7 @@ bool Q3BSPReader::loadLightMaps(
// A continuación, añado el blanco
// A continuacin, aado el blanco
osg::Image* image=new osg::Image;
unsigned char *data=new unsigned char[3];
for(int whiteidx=0;whiteidx<3;whiteidx++)

View File

@ -653,8 +653,6 @@ ref_ptr<StateSet> VBSPReader::readMaterialFile(std::string materialName)
bool found = false;
ref_ptr<StateSet> stateSet;
std::string shaderName;
std::string texName;
std::string tex2Name;
ref_ptr<Texture> texture;
ref_ptr<Texture> texture2;
ref_ptr<TexEnvCombine> combiner0;
@ -992,7 +990,6 @@ void VBSPReader::createScene()
Quat yaw, pitch, roll;
ref_ptr<MatrixTransform> propXform;
std::string propModel;
std::string propFile;
ref_ptr<Node> propNode;
// Load the materials and create a StateSet for each one

View File

@ -589,8 +589,6 @@ bool daeReader::processColorOrTextureType(const osg::StateSet* ss,
}
bool retVal = false;
std::string texCoordSet;
//osg::StateAttribute *sa = NULL;
//TODO: Make all channels process <param ref=""> type of value
if (channel == osg::Material::EMISSION )

View File

@ -361,7 +361,7 @@ osg::Node* daeReader::processLight( domLight *dlight )
lightmodel->setAmbientIntensity(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
_rootStateSet->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
osg::LightSource* lightsource = new osg::LightSource();
osg::ref_ptr<osg::LightSource> lightsource = new osg::LightSource();
lightsource->setLight(light);
std::string name = dlight->getId() ? dlight->getId() : "";
if (dlight->getName())
@ -520,7 +520,7 @@ osg::Node* daeReader::processLight( domLight *dlight )
light->setDirection(osg::Vec3(0, 0, -1));
}
return lightsource;
return lightsource.release();
}
// <camera>

View File

@ -689,7 +689,7 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
default:
{
OSG_DEBUG << "ReaderWriterJPEG::write_JPEG_file - Error pixel format non supported" << std::endl;
return WriteResult::ERROR_IN_WRITING_FILE; break;
return WriteResult::ERROR_IN_WRITING_FILE;
}
}

View File

@ -231,7 +231,6 @@ bool Model::readMTL(std::istream& fin)
bool usingDissolve = false;
Material* material = 0;// &(materialMap[""]);
std::string filename;
while (fin)
{

View File

@ -262,8 +262,6 @@ public:
osg::Geometry* multiPointToDrawable(OGRMultiPoint* mpoint) const
{
osg::Geometry* geom = new osg::Geometry;
osg::Geometry* pointGeom = new osg::Geometry();
osg::Vec3Array* vertices = new osg::Vec3Array();
@ -286,7 +284,7 @@ public:
if (pointGeom->getVertexArray())
{
OSG_INFO << "osgOgrFeature::multiPointToDrawable " << geom->getVertexArray()->getNumElements() << " vertexes"<< std::endl;
OSG_INFO << "osgOgrFeature::multiPointToDrawable " << pointGeom->getVertexArray()->getNumElements() << " vertexes"<< std::endl;
}
return pointGeom;

View File

@ -405,6 +405,7 @@ int *numComponents_ret)
break;
default:
tgaerror = ERR_UNSUPPORTED;
delete [] formattedMap;
return NULL; /* unreachable code - (depth < 1 || depth > 4) rejected by "check for reasonable values in case this is not a tga file" near the start of this function*/
}
@ -415,8 +416,7 @@ int *numComponents_ret)
dest += lineoffset;
}
if (formattedMap)
delete[] formattedMap;
delete [] formattedMap;
}
break;
case 2: /* RGB, uncompressed */

View File

@ -1183,21 +1183,21 @@ void SharedArrayOptimizer::findDuplicatedUVs(const osg::Geometry& geometry)
{
_deduplicateUvs.clear();
// look for all channels that are shared only *within* the geometry
// look for all arrays that are shared only *within* the geometry
std::map<const osg::Array*, unsigned int> arrayPointerCounter;
for(unsigned int id = 0 ; id < geometry.getNumTexCoordArrays() ; ++ id)
{
const osg::Array* channel = geometry.getTexCoordArray(id);
if(channel && channel->getNumElements())
const osg::Array* array = geometry.getTexCoordArray(id);
if(array && array->getNumElements())
{
if(arrayPointerCounter.find(channel) == arrayPointerCounter.end())
if(arrayPointerCounter.find(array) == arrayPointerCounter.end())
{
arrayPointerCounter[channel] = 1;
arrayPointerCounter[array] = 1;
}
else
{
arrayPointerCounter[channel] += 1;
arrayPointerCounter[array] += 1;
}
}
}
@ -1206,14 +1206,14 @@ void SharedArrayOptimizer::findDuplicatedUVs(const osg::Geometry& geometry)
for(unsigned int id = 0 ; id != geometry.getNumTexCoordArrays() ; ++ id)
{
const osg::Array* channel = geometry.getTexCoordArray(id);
// test if array is shared outside the geometry
if(channel && static_cast<unsigned int>(channel->referenceCount()) == arrayPointerCounter[channel])
const osg::Array* array = geometry.getTexCoordArray(id);
// test if array is shared inside the geometry
if(array && arrayPointerCounter[array] > 1)
{
std::map<const osg::Array*, unsigned int>::const_iterator reference = references.find(channel);
std::map<const osg::Array*, unsigned int>::const_iterator reference = references.find(array);
if(reference == references.end())
{
references[channel] = id;
references[array] = id;
}
else
{

View File

@ -20,9 +20,8 @@ osg::PrimitiveSet * drawElementsTemplate(GLenum mode,GLsizei count, const typena
{
if (indices==0 || count==0) return NULL;
Type * dePtr = new Type(mode);
Type & de = *dePtr;
de.reserve(count);
Type * primitives = new Type(mode);
primitives->reserve(count);
typedef const typename Type::value_type* IndexPointer;
@ -34,9 +33,9 @@ osg::PrimitiveSet * drawElementsTemplate(GLenum mode,GLsizei count, const typena
for (IndexPointer iptr=indices; iptr<ilast; iptr+=3)
{
de.push_back(*(iptr));
de.push_back(*(iptr+2));
de.push_back(*(iptr+1));
primitives->push_back(*(iptr));
primitives->push_back(*(iptr+2));
primitives->push_back(*(iptr+1));
}
break;
}
@ -46,10 +45,10 @@ osg::PrimitiveSet * drawElementsTemplate(GLenum mode,GLsizei count, const typena
IndexPointer ilast = &indices[count - 3];
for (IndexPointer iptr = indices; iptr<ilast; iptr+=4)
{
de.push_back(*(iptr));
de.push_back(*(iptr+3));
de.push_back(*(iptr+2));
de.push_back(*(iptr+1));
primitives->push_back(*(iptr));
primitives->push_back(*(iptr+3));
primitives->push_back(*(iptr+2));
primitives->push_back(*(iptr+1));
}
break;
}
@ -59,19 +58,19 @@ osg::PrimitiveSet * drawElementsTemplate(GLenum mode,GLsizei count, const typena
IndexPointer ilast = &indices[count];
for (IndexPointer iptr = indices; iptr<ilast; iptr+=2)
{
de.push_back(*(iptr+1));
de.push_back(*(iptr));
primitives->push_back(*(iptr+1));
primitives->push_back(*(iptr));
}
break;
}
case (GL_TRIANGLE_FAN):
{
de.push_back(*indices);
primitives->push_back(*indices);
IndexPointer iptr = indices + 1;
IndexPointer ilast = &indices[count];
de.resize(count);
std::reverse_copy(iptr, ilast, de.begin() + 1);
primitives->resize(count);
std::reverse_copy(iptr, ilast, primitives->begin() + 1);
break;
}
@ -83,8 +82,8 @@ osg::PrimitiveSet * drawElementsTemplate(GLenum mode,GLsizei count, const typena
{
IndexPointer iptr = indices;
IndexPointer ilast = &indices[count];
de.resize(count);
std::reverse_copy(iptr, ilast, de.begin());
primitives->resize(count);
std::reverse_copy(iptr, ilast, primitives->begin());
break;
}
@ -92,7 +91,7 @@ osg::PrimitiveSet * drawElementsTemplate(GLenum mode,GLsizei count, const typena
break;
}
return &de;
return primitives;
}
namespace osgUtil {
@ -101,9 +100,8 @@ void ReversePrimitiveFunctor::drawArrays(GLenum mode, GLint first, GLsizei count
{
if (count==0) return ;
osg::DrawElementsUInt * dePtr = new osg::DrawElementsUInt(mode);
osg::DrawElementsUInt & de = *dePtr;
de.reserve(count);
osg::DrawElementsUInt * primitives = new osg::DrawElementsUInt(mode);
primitives->reserve(count);
GLint end = first + count;
@ -113,9 +111,9 @@ void ReversePrimitiveFunctor::drawArrays(GLenum mode, GLint first, GLsizei count
{
for (GLint i=first; i<end; i+=3)
{
de.push_back(i);
de.push_back(i+2);
de.push_back(i+1);
primitives->push_back(i);
primitives->push_back(i+2);
primitives->push_back(i+1);
}
break;
}
@ -123,10 +121,10 @@ void ReversePrimitiveFunctor::drawArrays(GLenum mode, GLint first, GLsizei count
{
for (GLint i=first; i<end; i+=4)
{
de.push_back(i);
de.push_back(i+3);
de.push_back(i+2);
de.push_back(i+1);
primitives->push_back(i);
primitives->push_back(i+3);
primitives->push_back(i+2);
primitives->push_back(i+1);
}
break;
}
@ -135,17 +133,17 @@ void ReversePrimitiveFunctor::drawArrays(GLenum mode, GLint first, GLsizei count
{
for (GLint i=first; i<end; i+=2)
{
de.push_back(i+1);
de.push_back(i);
primitives->push_back(i+1);
primitives->push_back(i);
}
break;
}
case (GL_TRIANGLE_FAN):
{
de.push_back(first);
primitives->push_back(first);
for (GLint i=end-1; i>first; i--)
de.push_back(i);
primitives->push_back(i);
break;
}
@ -156,7 +154,7 @@ void ReversePrimitiveFunctor::drawArrays(GLenum mode, GLint first, GLsizei count
case (GL_LINE_LOOP):
{
for (GLint i=end-1; i>=first; i--)
de.push_back(i);
primitives->push_back(i);
break;
}
@ -164,7 +162,7 @@ void ReversePrimitiveFunctor::drawArrays(GLenum mode, GLint first, GLsizei count
break;
}
_reversedPrimitiveSet = &de;
_reversedPrimitiveSet = primitives;
}
void ReversePrimitiveFunctor::drawElements(GLenum mode,GLsizei count,const GLubyte* indices)

View File

@ -743,7 +743,7 @@ void SceneView::cull()
_cullVisitorRight->setClampProjectionMatrixCallback(_cullVisitor->getClampProjectionMatrixCallback());
_cullVisitorRight->setTraversalMask(_cullMaskRight);
computeRightEyeViewport(getViewport());
computeNearFar = cullStage(computeRightEyeProjection(getProjectionMatrix()),computeRightEyeView(getViewMatrix()),_cullVisitorRight.get(),_stateGraphRight.get(),_renderStageRight.get(),_viewportRight.get());
computeNearFar = cullStage(computeRightEyeProjection(getProjectionMatrix()),computeRightEyeView(getViewMatrix()),_cullVisitorRight.get(),_stateGraphRight.get(),_renderStageRight.get(),_viewportRight.get()) | computeNearFar;
if (computeNearFar)
{

View File

@ -267,7 +267,6 @@ public:
typedef std::vector< osg::ref_ptr<Point> > PointList;
typedef std::list< osg::ref_ptr<Triangle> > TriangleList;
typedef std::set< osg::ref_ptr<Triangle> > TriangleSet;
typedef std::map< osg::ref_ptr<Triangle>, unsigned int, dereference_less > TriangleMap;
struct Point : public osg::Referenced
{
@ -813,7 +812,6 @@ public:
osg::ref_ptr<Point> edge_p1 = edge->_p1;
osg::ref_ptr<Point> edge_p2 = edge->_p2;
TriangleMap triangleMap;
TriangleList triangles_p1;
TriangleList triangles_p2;
LocalEdgeList oldEdges;

View File

@ -607,7 +607,7 @@ void TriStripVisitor::mergeTriangleStrips(osg::Geometry::PrimitiveSetList& primi
osg::PrimitiveSet* ps = primitives[i].get();
// remove null primitive sets and all primitives that have been merged
// (i.e. all TRIANGLE_STRIP DrawElements)
if (!ps || (ps && ps->getMode() == osg::PrimitiveSet::TRIANGLE_STRIP))
if (ps && ps->getMode() == osg::PrimitiveSet::TRIANGLE_STRIP)
{
primitives.erase(primitives.begin() + i);
}