From Pavel Moloshtan, Byte2,3,4 and Short2,3,4 classes and their Array counterparts.
With a few build tweaks and bug fixes by Robert Osfield.
This commit is contained in:
@@ -30,11 +30,19 @@ static char* s_ArrayNames[] =
|
||||
"Vec2Array", // 9
|
||||
"Vec3Array", // 10
|
||||
"Vec4Array", // 11
|
||||
|
||||
"Short2Array", // 12
|
||||
"Short3Array", // 13
|
||||
"Short4Array", // 14
|
||||
|
||||
"Byte2Array", // 15
|
||||
"Byte3Array", // 16
|
||||
"Byte4Array", // 17
|
||||
};
|
||||
|
||||
const char* Array::className() const
|
||||
{
|
||||
if (_arrayType>=ArrayType && _arrayType<=Vec4ArrayType)
|
||||
if (_arrayType>=ArrayType && _arrayType<=Byte4ArrayType)
|
||||
return s_ArrayNames[_arrayType];
|
||||
else
|
||||
return "UnkownArray";
|
||||
|
||||
@@ -653,19 +653,15 @@ void Drawable::setEventCallback(EventCallback* ac)
|
||||
|
||||
struct ComputeBound : public PrimitiveFunctor
|
||||
{
|
||||
ComputeBound():_vertices(0) {}
|
||||
|
||||
virtual void setVertexArray(unsigned int,const Vec2*)
|
||||
ComputeBound() { _vertices = 0; _vertices4 = 0;}
|
||||
|
||||
virtual void setVertexArray(unsigned int,const Vec2*)
|
||||
{
|
||||
notify(WARN)<<"ComputeBound does not support Vec2* vertex arrays"<<std::endl;
|
||||
}
|
||||
|
||||
virtual void setVertexArray(unsigned int,const Vec3* vertices) { _vertices = vertices; }
|
||||
|
||||
virtual void setVertexArray(unsigned int,const Vec4*)
|
||||
{
|
||||
notify(WARN)<<"ComputeBound does not support Vec4* vertex arrays"<<std::endl;
|
||||
}
|
||||
virtual void setVertexArray(unsigned int,const Vec3* vertices) { _vertices = vertices; }
|
||||
virtual void setVertexArray(unsigned int,const Vec4* vertices) { _vertices4 = vertices; }
|
||||
|
||||
virtual void drawArrays(GLenum,GLint first,GLsizei count)
|
||||
{
|
||||
@@ -677,6 +673,15 @@ struct ComputeBound : public PrimitiveFunctor
|
||||
_bb.expandBy(*vert);
|
||||
}
|
||||
}
|
||||
|
||||
if (_vertices4)
|
||||
{
|
||||
const osg::Vec4* vert = _vertices4+first;
|
||||
for(;count>0;--count,++vert)
|
||||
{
|
||||
_bb.expandBy(*((Vec3*) vert));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawElements(GLenum,GLsizei count,const GLubyte* indices)
|
||||
@@ -688,6 +693,14 @@ struct ComputeBound : public PrimitiveFunctor
|
||||
_bb.expandBy(_vertices[*indices]);
|
||||
}
|
||||
}
|
||||
|
||||
if (_vertices4)
|
||||
{
|
||||
for(;count>0;--count,++indices)
|
||||
{
|
||||
_bb.expandBy(*((Vec3*)&_vertices4[*indices]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawElements(GLenum,GLsizei count,const GLushort* indices)
|
||||
@@ -699,6 +712,14 @@ struct ComputeBound : public PrimitiveFunctor
|
||||
_bb.expandBy(_vertices[*indices]);
|
||||
}
|
||||
}
|
||||
|
||||
if (_vertices4)
|
||||
{
|
||||
for(;count>0;--count,++indices)
|
||||
{
|
||||
_bb.expandBy(*((Vec3*)&_vertices4[*indices]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawElements(GLenum,GLsizei count,const GLuint* indices)
|
||||
@@ -710,19 +731,28 @@ struct ComputeBound : public PrimitiveFunctor
|
||||
_bb.expandBy(_vertices[*indices]);
|
||||
}
|
||||
}
|
||||
|
||||
if (_vertices4)
|
||||
{
|
||||
for(;count>0;--count,++indices)
|
||||
{
|
||||
_bb.expandBy(*((Vec3*)&_vertices4[*indices]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void begin(GLenum) {}
|
||||
virtual void vertex(const Vec2& vert) { _bb.expandBy(osg::Vec3(vert[0],vert[1],0.0f)); }
|
||||
virtual void vertex(const Vec3& vert) { _bb.expandBy(vert); }
|
||||
virtual void vertex(const Vec4& vert) { if (vert[3]!=0.0f) _bb.expandBy(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); }
|
||||
virtual void vertex(float x,float y) { _bb.expandBy(x,y,1.0f); }
|
||||
virtual void vertex(float x,float y) { _bb.expandBy(x,y,1.0f); }
|
||||
virtual void vertex(float x,float y,float z) { _bb.expandBy(x,y,z); }
|
||||
virtual void vertex(float x,float y,float z,float w) { if (w!=0.0f) _bb.expandBy(x/w,y/w,z/w); }
|
||||
virtual void end() {}
|
||||
|
||||
|
||||
const Vec3* _vertices;
|
||||
BoundingBox _bb;
|
||||
const Vec4* _vertices4;
|
||||
BoundingBox _bb;
|
||||
};
|
||||
|
||||
BoundingBox Drawable::computeBound() const
|
||||
|
||||
@@ -102,18 +102,61 @@ class DrawNormal
|
||||
{
|
||||
public:
|
||||
|
||||
DrawNormal(const Vec3Array* normals,const IndexArray* indices):
|
||||
DrawNormal(const Array* normals,const IndexArray* indices):
|
||||
_normals(normals),
|
||||
_indices(indices) {}
|
||||
_indices(indices)
|
||||
{
|
||||
_normalsType = normals?normals->getType():Array::ArrayType;
|
||||
}
|
||||
|
||||
void operator () (unsigned int pos)
|
||||
{
|
||||
if (_indices) glNormal3fv((*_normals)[_indices->index(pos)].ptr());
|
||||
else glNormal3fv((*_normals)[pos].ptr());
|
||||
switch(_normalsType)
|
||||
{
|
||||
case (Array::Vec3ArrayType):
|
||||
{
|
||||
const Vec3Array& normals = *static_cast<const Vec3Array*>(_normals);
|
||||
if (_indices) glNormal3fv(normals[_indices->index(pos)].ptr());
|
||||
else glNormal3fv(normals[pos].ptr());
|
||||
}
|
||||
break;
|
||||
case (Array::Short3ArrayType):
|
||||
{
|
||||
const Short3Array& normals = *static_cast<const Short3Array*>(_normals);
|
||||
if (_indices) glNormal3sv(normals[_indices->index(pos)].ptr());
|
||||
else glNormal3sv(normals[pos].ptr());
|
||||
}
|
||||
break;
|
||||
case (Array::Short4ArrayType):
|
||||
{
|
||||
const Short4Array& normals = *static_cast<const Short4Array*>(_normals);
|
||||
if (_indices) glNormal3sv(normals[_indices->index(pos)].ptr());
|
||||
else glNormal3sv(normals[pos].ptr());
|
||||
}
|
||||
break;
|
||||
case (Array::Byte3ArrayType):
|
||||
{
|
||||
const Byte3Array& normals = *static_cast<const Byte3Array*>(_normals);
|
||||
if (_indices) glNormal3bv((const GLbyte*)normals[_indices->index(pos)].ptr());
|
||||
else glNormal3bv((const GLbyte*)normals[pos].ptr());
|
||||
}
|
||||
break;
|
||||
case (Array::Byte4ArrayType):
|
||||
{
|
||||
const Byte4Array& normals = *static_cast<const Byte4Array*>(_normals);
|
||||
if (_indices) glNormal3bv((const GLbyte*)normals[_indices->index(pos)].ptr());
|
||||
else glNormal3bv((const GLbyte*)normals[pos].ptr());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const Vec3Array* _normals;
|
||||
const Array* _normals;
|
||||
const IndexArray* _indices;
|
||||
Array::Type _normalsType;
|
||||
};
|
||||
|
||||
#if 1
|
||||
@@ -1084,7 +1127,7 @@ void Geometry::drawImplementation(State& state) const
|
||||
state.disableVertexPointer();
|
||||
|
||||
if (_normalData.binding==BIND_PER_VERTEX)
|
||||
state.setNormalPointer(GL_FLOAT,0,_normalData.array->getDataPointer());
|
||||
state.setNormalPointer(_normalData.array->getDataType(),0,_normalData.array->getDataPointer());
|
||||
else
|
||||
state.disableNormalPointer();
|
||||
|
||||
|
||||
@@ -795,25 +795,28 @@ osg::Group *ac_load_object(std::istream &f,const ACObject *parent,const osgDB::R
|
||||
ia.push_back(app.get());
|
||||
}
|
||||
|
||||
osg::Vec3Array* normals = geom->getNormalArray();
|
||||
/** calc surface normal **/
|
||||
if (asurf.num_vertref >= 3)
|
||||
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(geom->getNormalArray());
|
||||
if (normals)
|
||||
{
|
||||
osg::Vec3 norm;
|
||||
unsigned short i1=(*nusidx)[0];
|
||||
unsigned short i2=(*nusidx)[1];
|
||||
unsigned short i3=(*nusidx)[2];
|
||||
osgtri_calc_normal((*vertpool)[i1],
|
||||
(*vertpool)[i2],
|
||||
(*vertpool)[i3], norm);
|
||||
normals->push_back(norm);
|
||||
// fprintf(stdout,"New %x are %d nrms\n",normals,normals->size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generate a dummy normal
|
||||
osg::Vec3 norm(0, 1, 0);
|
||||
normals->push_back(norm);
|
||||
/** calc surface normal **/
|
||||
if (asurf.num_vertref >= 3)
|
||||
{
|
||||
osg::Vec3 norm;
|
||||
unsigned short i1=(*nusidx)[0];
|
||||
unsigned short i2=(*nusidx)[1];
|
||||
unsigned short i3=(*nusidx)[2];
|
||||
osgtri_calc_normal((*vertpool)[i1],
|
||||
(*vertpool)[i2],
|
||||
(*vertpool)[i3], norm);
|
||||
normals->push_back(norm);
|
||||
// fprintf(stdout,"New %x are %d nrms\n",normals,normals->size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generate a dummy normal
|
||||
osg::Vec3 norm(0, 1, 0);
|
||||
normals->push_back(norm);
|
||||
}
|
||||
}
|
||||
int nstart=(*vgeom).size();
|
||||
for (i=0; i<asurf.num_vertref; i++)
|
||||
|
||||
@@ -154,7 +154,7 @@ void DynGeoSet::addToGeometry(osg::Geometry* geom)
|
||||
|
||||
if (!_normalList.empty())
|
||||
{
|
||||
osg::Vec3Array* normals = geom->getNormalArray();
|
||||
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(geom->getNormalArray());
|
||||
if (normals)
|
||||
{
|
||||
if (_normal_binding==osg::Geometry::BIND_PER_VERTEX || _normal_binding==osg::Geometry::BIND_PER_PRIMITIVE)
|
||||
|
||||
@@ -438,6 +438,12 @@ osg::Array* DataInputStream::readArray(){
|
||||
case 6: return readVec2Array();
|
||||
case 7: return readVec3Array();
|
||||
case 8: return readVec4Array();
|
||||
case 9: return readShort2Array();
|
||||
case 10: return readShort3Array();
|
||||
case 11: return readShort4Array();
|
||||
case 12: return readByte2Array();
|
||||
case 13: return readByte3Array();
|
||||
case 14: return readByte4Array();
|
||||
default: throw Exception("Unknown array type in DataInputStream::readArray()");
|
||||
}
|
||||
}
|
||||
@@ -612,6 +618,96 @@ osg::Vec4Array* DataInputStream::readVec4Array(){
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Byte2Array* DataInputStream::readByte2Array()
|
||||
{
|
||||
int size = readInt();
|
||||
osg::Byte2Array* a = new osg::Byte2Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), CHARSIZE * 2 * size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readByte2Array(): Failed to read Byte2 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte2Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Byte3Array* DataInputStream::readByte3Array()
|
||||
{
|
||||
int size = readInt();
|
||||
osg::Byte3Array* a = new osg::Byte3Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), CHARSIZE * 3 * size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readByte3Array(): Failed to read Byte3 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte3Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Byte4Array* DataInputStream::readByte4Array()
|
||||
{
|
||||
int size = readInt();
|
||||
osg::Byte4Array* a = new osg::Byte4Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), CHARSIZE * 4 * size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readByte4Array(): Failed to read Byte4 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte4Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Short2Array* DataInputStream::readShort2Array()
|
||||
{
|
||||
int size = readInt();
|
||||
osg::Short2Array* a = new osg::Short2Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), SHORTSIZE * 2 * size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readShort2Array(): Failed to read Short2 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort2Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Short3Array* DataInputStream::readShort3Array()
|
||||
{
|
||||
int size = readInt();
|
||||
osg::Short3Array* a = new osg::Short3Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), SHORTSIZE * 3 * size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readShort3Array(): Failed to read Short3 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort3Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Short4Array* DataInputStream::readShort4Array()
|
||||
{
|
||||
int size = readInt();
|
||||
osg::Short4Array* a = new osg::Short4Array(size);
|
||||
|
||||
_istream->read((char*)&((*a)[0]), SHORTSIZE * 4 * size);
|
||||
|
||||
if (_istream->rdstate() & _istream->failbit)
|
||||
throw Exception("DataInputStream::readShort4Array(): Failed to read Short4 array.");
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort4Array() ["<<size<<"]"<<std::endl;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
osg::Matrixf DataInputStream::readMatrixf()
|
||||
{
|
||||
osg::Matrixf mat;
|
||||
|
||||
@@ -77,6 +77,12 @@ public:
|
||||
osg::Vec2Array* readVec2Array();
|
||||
osg::Vec3Array* readVec3Array();
|
||||
osg::Vec4Array* readVec4Array();
|
||||
osg::Byte2Array* readByte2Array();
|
||||
osg::Byte3Array* readByte3Array();
|
||||
osg::Byte4Array* readByte4Array();
|
||||
osg::Short2Array* readShort2Array();
|
||||
osg::Short3Array* readShort3Array();
|
||||
osg::Short4Array* readShort4Array();
|
||||
|
||||
osg::Image* readImage(std::string s);
|
||||
osg::StateSet* readStateSet();
|
||||
|
||||
@@ -148,6 +148,12 @@ void DataOutputStream::writeUShort(unsigned short s){
|
||||
if (_verboseOutput) std::cout<<"read/writeUShort() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeShort(short s){
|
||||
_ostream->write((char*)&s, SHORTSIZE);
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort() ["<<s<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeUInt(unsigned int s){
|
||||
_ostream->write((char*)&s, INTSIZE);
|
||||
|
||||
@@ -264,6 +270,30 @@ void DataOutputStream::writeUByte4(const osg::UByte4& v){
|
||||
if (_verboseOutput) std::cout<<"read/writeUByte4() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeByte2(const osg::Byte2& v){
|
||||
writeChar(v.r());
|
||||
writeChar(v.g());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte2() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeByte3(const osg::Byte3& v){
|
||||
writeChar(v.r());
|
||||
writeChar(v.g());
|
||||
writeChar(v.b());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte3() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeByte4(const osg::Byte4& v){
|
||||
writeChar(v.r());
|
||||
writeChar(v.g());
|
||||
writeChar(v.b());
|
||||
writeChar(v.a());
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte4() ["<<v<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeQuat(const osg::Quat& q){
|
||||
writeFloat(q.x());
|
||||
writeFloat(q.y());
|
||||
@@ -324,6 +354,30 @@ void DataOutputStream::writeArray(const osg::Array* a){
|
||||
writeChar((char)8);
|
||||
writeVec4Array(static_cast<const osg::Vec4Array*>(a));
|
||||
break;
|
||||
case osg::Array::Short2ArrayType:
|
||||
writeChar((char)9);
|
||||
writeShort2Array(static_cast<const osg::Short2Array*>(a));
|
||||
break;
|
||||
case osg::Array::Short3ArrayType:
|
||||
writeChar((char)10);
|
||||
writeShort3Array(static_cast<const osg::Short3Array*>(a));
|
||||
break;
|
||||
case osg::Array::Short4ArrayType:
|
||||
writeChar((char)11);
|
||||
writeShort4Array(static_cast<const osg::Short4Array*>(a));
|
||||
break;
|
||||
case osg::Array::Byte2ArrayType:
|
||||
writeChar((char)12);
|
||||
writeByte2Array(static_cast<const osg::Byte2Array*>(a));
|
||||
break;
|
||||
case osg::Array::Byte3ArrayType:
|
||||
writeChar((char)13);
|
||||
writeByte3Array(static_cast<const osg::Byte3Array*>(a));
|
||||
break;
|
||||
case osg::Array::Byte4ArrayType:
|
||||
writeChar((char)14);
|
||||
writeByte4Array(static_cast<const osg::Byte4Array*>(a));
|
||||
break;
|
||||
default: throw Exception("Unknown array type in DataOutputStream::writeArray()");
|
||||
}
|
||||
}
|
||||
@@ -429,6 +483,78 @@ void DataOutputStream::writeVec4Array(const osg::Vec4Array* a)
|
||||
if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeShort2Array(const osg::Short2Array* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeShort((*a)[i].x);
|
||||
writeShort((*a)[i].y);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort2Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeShort3Array(const osg::Short3Array* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeShort((*a)[i].x);
|
||||
writeShort((*a)[i].y);
|
||||
writeShort((*a)[i].z);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort3Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeShort4Array(const osg::Short4Array* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeShort((*a)[i].x);
|
||||
writeShort((*a)[i].y);
|
||||
writeShort((*a)[i].z);
|
||||
writeShort((*a)[i].w);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeShort4Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeByte2Array(const osg::Byte2Array* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeByte2((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte2Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeByte3Array(const osg::Byte3Array* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeByte3((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte3Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeByte4Array(const osg::Byte4Array* a)
|
||||
{
|
||||
int size = a->getNumElements();
|
||||
writeInt(size);
|
||||
for(int i =0; i<size ;i++){
|
||||
writeByte4((*a)[i]);
|
||||
}
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeByte4Array() ["<<size<<"]"<<std::endl;
|
||||
}
|
||||
|
||||
void DataOutputStream::writeMatrixf(const osg::Matrixf& mat)
|
||||
{
|
||||
for(int r=0;r<4;r++)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
|
||||
#include <iostream> // for ofstream
|
||||
#include <iostream> // for ofstream
|
||||
#include <string>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
@@ -23,106 +23,116 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
namespace ive {
|
||||
namespace ive {
|
||||
|
||||
class DataOutputStream{
|
||||
|
||||
public:
|
||||
DataOutputStream(std::ostream* ostream);
|
||||
~DataOutputStream();
|
||||
DataOutputStream(std::ostream* ostream);
|
||||
~DataOutputStream();
|
||||
|
||||
void setOptions(const osgDB::ReaderWriter::Options* options);
|
||||
const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }
|
||||
void setOptions(const osgDB::ReaderWriter::Options* options);
|
||||
const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }
|
||||
|
||||
unsigned int getVersion() { return VERSION; }
|
||||
unsigned int getVersion() { return VERSION; }
|
||||
|
||||
void writeBool(bool b);
|
||||
void writeChar(char c);
|
||||
void writeUChar(unsigned char c);
|
||||
void writeUShort(unsigned short s);
|
||||
void writeUInt(unsigned int s);
|
||||
void writeInt(int i);
|
||||
void writeFloat(float f);
|
||||
void writeLong(long l);
|
||||
void writeULong(unsigned long l);
|
||||
void writeDouble(double d);
|
||||
void writeString(const std::string& s);
|
||||
void writeCharArray(const char* data, int size);
|
||||
void writeVec2(const osg::Vec2& v);
|
||||
void writeVec3(const osg::Vec3& v);
|
||||
void writeVec4(const osg::Vec4& v);
|
||||
void writeVec2d(const osg::Vec2d& v);
|
||||
void writeVec3d(const osg::Vec3d& v);
|
||||
void writeVec4d(const osg::Vec4d& v);
|
||||
void writePlane(const osg::Plane& v);
|
||||
void writeUByte4(const osg::UByte4& v);
|
||||
void writeQuat(const osg::Quat& q);
|
||||
void writeBinding(osg::Geometry::AttributeBinding b);
|
||||
void writeArray(const osg::Array* a);
|
||||
void writeIntArray(const osg::IntArray* a);
|
||||
void writeUByteArray(const osg::UByteArray* a);
|
||||
void writeUShortArray(const osg::UShortArray* a);
|
||||
void writeUIntArray(const osg::UIntArray* a);
|
||||
void writeUByte4Array(const osg::UByte4Array* a);
|
||||
void writeFloatArray(const osg::FloatArray* a);
|
||||
void writeVec2Array(const osg::Vec2Array* a);
|
||||
void writeVec3Array(const osg::Vec3Array* a);
|
||||
void writeVec4Array(const osg::Vec4Array* a);
|
||||
void writeMatrixf(const osg::Matrixf& mat);
|
||||
void writeMatrixd(const osg::Matrixd& mat);
|
||||
void writeBool(bool b);
|
||||
void writeChar(char c);
|
||||
void writeUChar(unsigned char c);
|
||||
void writeUShort(unsigned short s);
|
||||
void writeShort(short s);
|
||||
void writeUInt(unsigned int s);
|
||||
void writeInt(int i);
|
||||
void writeFloat(float f);
|
||||
void writeLong(long l);
|
||||
void writeULong(unsigned long l);
|
||||
void writeDouble(double d);
|
||||
void writeString(const std::string& s);
|
||||
void writeCharArray(const char* data, int size);
|
||||
void writeVec2(const osg::Vec2& v);
|
||||
void writeVec3(const osg::Vec3& v);
|
||||
void writeVec4(const osg::Vec4& v);
|
||||
void writeVec2d(const osg::Vec2d& v);
|
||||
void writeVec3d(const osg::Vec3d& v);
|
||||
void writeVec4d(const osg::Vec4d& v);
|
||||
void writePlane(const osg::Plane& v);
|
||||
void writeUByte4(const osg::UByte4& v);
|
||||
void writeQuat(const osg::Quat& q);
|
||||
void writeBinding(osg::Geometry::AttributeBinding b);
|
||||
void writeArray(const osg::Array* a);
|
||||
void writeIntArray(const osg::IntArray* a);
|
||||
void writeUByteArray(const osg::UByteArray* a);
|
||||
void writeUShortArray(const osg::UShortArray* a);
|
||||
void writeUIntArray(const osg::UIntArray* a);
|
||||
void writeUByte4Array(const osg::UByte4Array* a);
|
||||
void writeByte2(const osg::Byte2& v);
|
||||
void writeByte3(const osg::Byte3& v);
|
||||
void writeByte4(const osg::Byte4& v);
|
||||
void writeFloatArray(const osg::FloatArray* a);
|
||||
void writeVec2Array(const osg::Vec2Array* a);
|
||||
void writeVec3Array(const osg::Vec3Array* a);
|
||||
void writeVec4Array(const osg::Vec4Array* a);
|
||||
void writeShort2Array(const osg::Short2Array* a);
|
||||
void writeShort3Array(const osg::Short3Array* a);
|
||||
void writeShort4Array(const osg::Short4Array* a);
|
||||
void writeByte2Array(const osg::Byte2Array* a);
|
||||
void writeByte3Array(const osg::Byte3Array* a);
|
||||
void writeByte4Array(const osg::Byte4Array* a);
|
||||
void writeMatrixf(const osg::Matrixf& mat);
|
||||
void writeMatrixd(const osg::Matrixd& mat);
|
||||
|
||||
void writeStateSet(const osg::StateSet* stateset);
|
||||
void writeStateAttribute(const osg::StateAttribute* sa);
|
||||
void writeUniform(const osg::Uniform* uniform);
|
||||
void writeShader(const osg::Shader* shader);
|
||||
void writeDrawable(const osg::Drawable* sa);
|
||||
void writeShape(const osg::Shape* sa);
|
||||
void writeNode(const osg::Node* sa);
|
||||
void writeStateSet(const osg::StateSet* stateset);
|
||||
void writeStateAttribute(const osg::StateAttribute* sa);
|
||||
void writeUniform(const osg::Uniform* uniform);
|
||||
void writeShader(const osg::Shader* shader);
|
||||
void writeDrawable(const osg::Drawable* sa);
|
||||
void writeShape(const osg::Shape* sa);
|
||||
void writeNode(const osg::Node* sa);
|
||||
|
||||
// Set and get include image data in stream
|
||||
void setIncludeImageData(bool b) {_includeImageData=b;};
|
||||
bool getIncludeImageData() {return _includeImageData;};
|
||||
// Set and get include image data in stream
|
||||
void setIncludeImageData(bool b) {_includeImageData=b;};
|
||||
bool getIncludeImageData() {return _includeImageData;};
|
||||
|
||||
// Set and get include external references in stream
|
||||
void setIncludeExternalReferences(bool b) {_includeExternalReferences=b;};
|
||||
bool getIncludeExternalReferences() {return _includeExternalReferences;};
|
||||
// Set and get include external references in stream
|
||||
void setIncludeExternalReferences(bool b) {_includeExternalReferences=b;};
|
||||
bool getIncludeExternalReferences() {return _includeExternalReferences;};
|
||||
|
||||
// Set and get if must be generated external reference ive files
|
||||
void setWriteExternalReferenceFiles(bool b) {_writeExternalReferenceFiles=b;};
|
||||
bool getWriteExternalReferenceFiles() {return _writeExternalReferenceFiles;};
|
||||
// Set and get if must be generated external reference ive files
|
||||
void setWriteExternalReferenceFiles(bool b) {_writeExternalReferenceFiles=b;};
|
||||
bool getWriteExternalReferenceFiles() {return _writeExternalReferenceFiles;};
|
||||
|
||||
// Set and get if must be used original external reference files
|
||||
void setUseOriginalExternalReferences(bool b) {_useOriginalExternalReferences=b;};
|
||||
bool getUseOriginalExternalReferences() {return _useOriginalExternalReferences;};
|
||||
// Set and get if must be used original external reference files
|
||||
void setUseOriginalExternalReferences(bool b) {_useOriginalExternalReferences=b;};
|
||||
bool getUseOriginalExternalReferences() {return _useOriginalExternalReferences;};
|
||||
|
||||
bool _verboseOutput;
|
||||
bool _verboseOutput;
|
||||
|
||||
private:
|
||||
std::ostream* _ostream;
|
||||
std::ostream* _ostream;
|
||||
|
||||
// Container to map stateset uniques to their respective stateset.
|
||||
typedef std::map<const osg::StateSet*,int> StateSetMap;
|
||||
typedef std::map<const osg::StateAttribute*,int> StateAttributeMap;
|
||||
typedef std::map<const osg::Uniform*,int> UniformMap;
|
||||
typedef std::map<const osg::Shader*,int> ShaderMap;
|
||||
typedef std::map<const osg::Drawable*,int> DrawableMap;
|
||||
typedef std::map<const osg::Shape*,int> ShapeMap;
|
||||
typedef std::map<const osg::Node*,int> NodeMap;
|
||||
// Container to map stateset uniques to their respective stateset.
|
||||
typedef std::map<const osg::StateSet*,int> StateSetMap;
|
||||
typedef std::map<const osg::StateAttribute*,int> StateAttributeMap;
|
||||
typedef std::map<const osg::Uniform*,int> UniformMap;
|
||||
typedef std::map<const osg::Shader*,int> ShaderMap;
|
||||
typedef std::map<const osg::Drawable*,int> DrawableMap;
|
||||
typedef std::map<const osg::Shape*,int> ShapeMap;
|
||||
typedef std::map<const osg::Node*,int> NodeMap;
|
||||
|
||||
StateSetMap _stateSetMap;
|
||||
StateAttributeMap _stateAttributeMap;
|
||||
UniformMap _uniformMap;
|
||||
ShaderMap _shaderMap;
|
||||
DrawableMap _drawableMap;
|
||||
ShapeMap _shapeMap;
|
||||
NodeMap _nodeMap;
|
||||
StateSetMap _stateSetMap;
|
||||
StateAttributeMap _stateAttributeMap;
|
||||
UniformMap _uniformMap;
|
||||
ShaderMap _shaderMap;
|
||||
DrawableMap _drawableMap;
|
||||
ShapeMap _shapeMap;
|
||||
NodeMap _nodeMap;
|
||||
|
||||
bool _includeImageData;
|
||||
bool _includeExternalReferences;
|
||||
bool _writeExternalReferenceFiles;
|
||||
bool _useOriginalExternalReferences;
|
||||
|
||||
osg::ref_ptr<const osgDB::ReaderWriter::Options> _options;
|
||||
bool _includeImageData;
|
||||
bool _includeExternalReferences;
|
||||
bool _writeExternalReferenceFiles;
|
||||
bool _useOriginalExternalReferences;
|
||||
|
||||
osg::ref_ptr<const osgDB::ReaderWriter::Options> _options;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -67,12 +67,28 @@ void Geometry::write(DataOutputStream* out){
|
||||
if (getVertexIndices()){
|
||||
out->writeArray(getVertexIndices());
|
||||
}
|
||||
|
||||
// Write normal array if any
|
||||
out->writeBool(getNormalArray()!=0);
|
||||
if (getNormalArray()){
|
||||
out->writeBinding(getNormalBinding());
|
||||
out->writeVec3Array(getNormalArray());
|
||||
if ( out->getVersion() < VERSION_0013 )
|
||||
{
|
||||
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(getNormalArray());
|
||||
out->writeBool(normals!=0);
|
||||
if (normals)
|
||||
{
|
||||
out->writeBinding(getNormalBinding());
|
||||
out->writeVec3Array(normals);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out->writeBool(getNormalArray()!=0);
|
||||
if (getNormalArray()!=0)
|
||||
{
|
||||
out->writeBinding(getNormalBinding());
|
||||
out->writeArray(getNormalArray());
|
||||
}
|
||||
}
|
||||
|
||||
// Write normal indices if any
|
||||
out->writeBool(getNormalIndices()!=0);
|
||||
if (getNormalIndices()){
|
||||
@@ -213,12 +229,25 @@ void Geometry::read(DataInputStream* in){
|
||||
if (vi){
|
||||
setVertexIndices(static_cast<osg::IndexArray*>(in->readArray()));
|
||||
}
|
||||
|
||||
// Read normal array if any
|
||||
bool na =in->readBool();
|
||||
if(na){
|
||||
setNormalBinding(in->readBinding());
|
||||
setNormalArray(in->readVec3Array());
|
||||
if ( in->getVersion() < VERSION_0013 )
|
||||
{
|
||||
bool na =in->readBool();
|
||||
if(na){
|
||||
setNormalBinding(in->readBinding());
|
||||
setNormalArray(in->readVec3Array());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool na =in->readBool();
|
||||
if(na){
|
||||
setNormalBinding(in->readBinding());
|
||||
setNormalArray(in->readArray());
|
||||
}
|
||||
}
|
||||
|
||||
// Read normal indices if any
|
||||
bool ni = in->readBool();
|
||||
if(ni){
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
#define VERSION_0010 10
|
||||
#define VERSION_0011 11
|
||||
#define VERSION_0012 12
|
||||
#define VERSION_0013 13
|
||||
|
||||
#define VERSION VERSION_0012
|
||||
#define VERSION VERSION_0013
|
||||
|
||||
|
||||
/* The BYTE_SEX tag is used to check the endian
|
||||
|
||||
@@ -173,7 +173,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
// post 0.9.3 releases.
|
||||
++fr;
|
||||
Vec3Array* normals = dynamic_cast<Vec3Array*>(Array_readLocalData(fr));
|
||||
Array* normals = Array_readLocalData(fr);
|
||||
if (normals)
|
||||
{
|
||||
geom.setNormalArray(normals);
|
||||
@@ -601,6 +601,120 @@ Array* Array_readLocalData(Input& fr)
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Byte2Array")==0)
|
||||
{
|
||||
Byte2Array* array = new Byte2Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g))
|
||||
{
|
||||
fr+=2;
|
||||
array->push_back(osg::Byte2(r,g));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Byte3Array")==0)
|
||||
{
|
||||
Byte3Array* array = new Byte3Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g,b;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g) &&
|
||||
fr[2].getUInt(b))
|
||||
{
|
||||
fr+=3;
|
||||
array->push_back(osg::Byte3(r,g,b));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Byte4Array")==0)
|
||||
{
|
||||
Byte4Array* array = new Byte4Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g,b,a;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g) &&
|
||||
fr[2].getUInt(b) &&
|
||||
fr[3].getUInt(a))
|
||||
{
|
||||
fr+=4;
|
||||
array->push_back(osg::Byte4(r,g,b,a));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Short2Array")==0)
|
||||
{
|
||||
Short2Array* array = new Short2Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g))
|
||||
{
|
||||
fr+=2;
|
||||
array->push_back(osg::Short2(r,g));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Short3Array")==0)
|
||||
{
|
||||
Short3Array* array = new Short3Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g,b;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g) &&
|
||||
fr[2].getUInt(b))
|
||||
{
|
||||
fr+=3;
|
||||
array->push_back(osg::Short3(r,g,b));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Short4Array")==0)
|
||||
{
|
||||
Short4Array* array = new Short4Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g,b,a;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g) &&
|
||||
fr[2].getUInt(b) &&
|
||||
fr[3].getUInt(a))
|
||||
{
|
||||
fr+=4;
|
||||
array->push_back(osg::Short4(r,g,b,a));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return_array = array;
|
||||
}
|
||||
|
||||
if (return_array)
|
||||
{
|
||||
@@ -721,6 +835,54 @@ bool Array_writeLocalData(const Array& array,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Short2ArrayType):
|
||||
{
|
||||
const Short2Array& carray = static_cast<const Short2Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
writeArray(fw,carray.begin(),carray.end(), 3);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Short3ArrayType):
|
||||
{
|
||||
const Short3Array& carray = static_cast<const Short3Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
writeArray(fw,carray.begin(),carray.end(), 2);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Short4ArrayType):
|
||||
{
|
||||
const Short4Array& carray = static_cast<const Short4Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
writeArray(fw,carray.begin(),carray.end(), 1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Byte2ArrayType):
|
||||
{
|
||||
const Byte2Array& carray = static_cast<const Byte2Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
writeArray(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Byte3ArrayType):
|
||||
{
|
||||
const Byte3Array& carray = static_cast<const Byte3Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
writeArray(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Byte4ArrayType):
|
||||
{
|
||||
const Byte4Array& carray = static_cast<const Byte4Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
writeArray(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::ArrayType):
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -2727,7 +2727,7 @@ osg::Node* DataSet::DestinationTile::createPolygonal()
|
||||
sv.smooth(*geometry); // this will replace the normal vector with a new one
|
||||
|
||||
// now we have to reassign the normals back to the orignal pointer.
|
||||
n = geometry->getNormalArray();
|
||||
n = dynamic_cast<osg::Vec3Array*>(geometry->getNormalArray());
|
||||
if (n.valid() && n->size()!=numVertices) n->resize(numVertices);
|
||||
#endif
|
||||
// now apply the normals computed through equalization
|
||||
|
||||
@@ -214,6 +214,7 @@ void Optimizer::optimize(osg::Node* node, unsigned int options)
|
||||
osg::notify(osg::INFO)<<"Optimizer::optimize() doing MERGE_GEOMETRY"<<std::endl;
|
||||
|
||||
MergeGeometryVisitor mgv(this);
|
||||
mgv.setTargetMaximumNumberOfVertices(10000);
|
||||
node->accept(mgv);
|
||||
}
|
||||
|
||||
@@ -1561,10 +1562,27 @@ struct LessGeometry
|
||||
{
|
||||
// assumes that the bindings and arrays are set up correctly, this
|
||||
// should be the case after running computeCorrectBindingsAndArraySizes();
|
||||
const osg::Vec3& lhs_normal = (*(lhs->getNormalArray()))[0];
|
||||
const osg::Vec3& rhs_normal = (*(rhs->getNormalArray()))[0];
|
||||
if (lhs_normal<rhs_normal) return true;
|
||||
if (rhs_normal<lhs_normal) return false;
|
||||
const osg::Array* lhs_normalArray = lhs->getNormalArray();
|
||||
const osg::Array* rhs_normalArray = rhs->getNormalArray();
|
||||
if (lhs_normalArray->getType()<rhs_normalArray->getType()) return true;
|
||||
if (rhs_normalArray->getType()<lhs_normalArray->getType()) return false;
|
||||
switch(lhs_normalArray->getType())
|
||||
{
|
||||
case(osg::Array::Byte3ArrayType):
|
||||
if ((*static_cast<const osg::Byte3Array*>(lhs_normalArray))[0]<(*static_cast<const osg::Byte3Array*>(rhs_normalArray))[0]) return true;
|
||||
if ((*static_cast<const osg::Byte3Array*>(rhs_normalArray))[0]<(*static_cast<const osg::Byte3Array*>(lhs_normalArray))[0]) return false;
|
||||
break;
|
||||
case(osg::Array::Short3ArrayType):
|
||||
if ((*static_cast<const osg::Short3Array*>(lhs_normalArray))[0]<(*static_cast<const osg::Short3Array*>(rhs_normalArray))[0]) return true;
|
||||
if ((*static_cast<const osg::Short3Array*>(rhs_normalArray))[0]<(*static_cast<const osg::Short3Array*>(lhs_normalArray))[0]) return false;
|
||||
break;
|
||||
case(osg::Array::Vec3ArrayType):
|
||||
if ((*static_cast<const osg::Vec3Array*>(lhs_normalArray))[0]<(*static_cast<const osg::Vec3Array*>(rhs_normalArray))[0]) return true;
|
||||
if ((*static_cast<const osg::Vec3Array*>(rhs_normalArray))[0]<(*static_cast<const osg::Vec3Array*>(lhs_normalArray))[0]) return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lhs->getColorBinding()==osg::Geometry::BIND_OVERALL)
|
||||
@@ -1888,6 +1906,13 @@ class MergeArrayVisitor : public osg::ArrayVisitor
|
||||
virtual void apply(osg::Vec2Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Vec3Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Vec4Array& rhs) { _merge(rhs); }
|
||||
|
||||
virtual void apply(osg::Byte2Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Byte3Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Byte4Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Short2Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Short3Array& rhs) { _merge(rhs); }
|
||||
virtual void apply(osg::Short4Array& rhs) { _merge(rhs); }
|
||||
};
|
||||
|
||||
bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geometry& rhs)
|
||||
|
||||
@@ -534,7 +534,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
_collectOccludersVisistor->removeOccludedOccluders();
|
||||
|
||||
|
||||
osg::notify(osg::INFO) << "finished searching for occluder - found "<<_collectOccludersVisistor->getCollectedOccluderSet().size()<<std::endl;
|
||||
osg::notify(osg::DEBUG_INFO) << "finished searching for occluder - found "<<_collectOccludersVisistor->getCollectedOccluderSet().size()<<std::endl;
|
||||
|
||||
cullVisitor->getOccluderList().clear();
|
||||
std::copy(_collectOccludersVisistor->getCollectedOccluderSet().begin(),_collectOccludersVisistor->getCollectedOccluderSet().end(), std::back_insert_iterator<CullStack::OccluderList>(cullVisitor->getOccluderList()));
|
||||
|
||||
@@ -425,7 +425,7 @@ void Tesselator::handleNewVertices(osg::Geometry& geom,VertexPtrToIndexMap &vert
|
||||
osg::Vec3Array* normals = NULL;
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_VERTEX)
|
||||
{
|
||||
normals = geom.getNormalArray();
|
||||
normals = dynamic_cast<osg::Vec3Array*>(geom.getNormalArray());
|
||||
}
|
||||
|
||||
typedef std::vector<osg::Array*> ArrayList;
|
||||
@@ -668,7 +668,7 @@ void Tesselator::collectTesselation(osg::Geometry &geom)
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
normals = geom.getNormalArray(); // GWM Sep 2002
|
||||
normals = dynamic_cast<osg::Vec3Array*>(geom.getNormalArray()); // GWM Sep 2002
|
||||
}
|
||||
// GWM Dec 2003 - needed to add colours for extra facets
|
||||
osg::Vec4Array* cols4 = NULL; // GWM Dec 2003 colours are vec4
|
||||
|
||||
Reference in New Issue
Block a user