Merge branch 'master' into text_improvements

This commit is contained in:
Robert Osfield
2017-10-10 09:21:34 +01:00
19 changed files with 520 additions and 59 deletions

View File

@@ -118,6 +118,8 @@ struct VertexArrayDispatch : public VertexArrayState::ArrayDispatch
{
VertexArrayDispatch() {}
virtual const char* className() const { return "VertexArrayDispatch"; }
virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array)
{
VAS_NOTICE<<" VertexArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<")"<<std::endl;
@@ -171,6 +173,8 @@ struct ColorArrayDispatch : public VertexArrayState::ArrayDispatch
{
ColorArrayDispatch() {}
virtual const char* className() const { return "ColorArrayDispatch"; }
virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array)
{
VAS_NOTICE<<" ColorArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<")"<<std::endl;
@@ -225,6 +229,8 @@ struct NormalArrayDispatch : public VertexArrayState::ArrayDispatch
{
NormalArrayDispatch() {}
virtual const char* className() const { return "NormalArrayDispatch"; }
virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array)
{
VAS_NOTICE<<" NormalArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<")"<<std::endl;
@@ -286,6 +292,8 @@ struct SecondaryColorArrayDispatch : public VertexArrayState::ArrayDispatch
{
SecondaryColorArrayDispatch() {}
virtual const char* className() const { return "SecondaryColorArrayDispatch"; }
virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array)
{
glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
@@ -331,6 +339,8 @@ struct FogCoordArrayDispatch : public VertexArrayState::ArrayDispatch
{
FogCoordArrayDispatch() {}
virtual const char* className() const { return "FogCoordArrayDispatch"; }
virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array)
{
glEnableClientState(GL_FOG_COORDINATE_ARRAY);
@@ -367,6 +377,8 @@ struct TexCoordArrayDispatch : public VertexArrayState::ArrayDispatch
{
TexCoordArrayDispatch(unsigned int in_unit) : unit(in_unit) {}
virtual const char* className() const { return "TexCoordArrayDispatch"; }
virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array)
{
VAS_NOTICE<<" TexCoordArrayDispatch::enable_and_dispatch("<<new_array->getNumElements()<<") unit="<<unit<<std::endl;
@@ -436,6 +448,8 @@ struct VertexAttribArrayDispatch : public VertexArrayState::ArrayDispatch
{
VertexAttribArrayDispatch(unsigned int in_unit) : unit(in_unit) {}
virtual const char* className() const { return "VertexAttribArrayDispatch"; }
inline void callVertexAttribPointer(GLExtensions* ext, const osg::Array* new_array, const GLvoid * ptr)
{
if (new_array->getPreserveDataType())
@@ -731,8 +745,10 @@ void VertexArrayState::setArray(ArrayDispatch* vad, osg::State& state, GLint siz
void VertexArrayState::setInterleavedArrays( osg::State& state, GLenum format, GLsizei stride, const GLvoid* pointer)
{
#if defined(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
lazyDisablingOfVertexAttributes();
applyDisablingOfVertexAttributes(state);
unbindVertexBufferObject();
//lazyDisablingOfVertexAttributes();
//applyDisablingOfVertexAttributes(state);
glInterleavedArrays( format, stride, pointer);
#else

View File

@@ -16,21 +16,14 @@
using namespace osgDB;
static long long prev_tellg = 0;
void InputIterator::checkStream() const
{
if (_in->rdstate()&_in->failbit)
{
OSG_NOTICE<<"InputIterator::checkStream() : _in->rdstate() "<<_in->rdstate()<<", "<<_in->failbit<<std::endl;
OSG_NOTICE<<" _in->tellg() = "<<_in->tellg()<<std::endl;
OSG_NOTICE<<" prev_tellg = "<<prev_tellg<<std::endl;
_failed = true;
}
else
{
prev_tellg = _in->tellg();
}
}
void InputIterator::readComponentArray( char* s, unsigned int numElements, unsigned int numComponentsPerElements, unsigned int componentSizeInBytes)

View File

@@ -546,27 +546,27 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) {
}
void OBJWriterNodeVisitor::apply(osg::Geometry& geometry)
{
osg::Matrix m = osg::computeLocalToWorld(getNodePath());
pushStateSet(geometry.getStateSet());
processGeometry(&geometry,m);
popStateSet(geometry.getStateSet());
}
void OBJWriterNodeVisitor::apply( osg::Geode &node )
{
pushStateSet(node.getStateSet());
_nameStack.push_back(node.getName());
osg::Matrix m = osg::computeLocalToWorld(getNodePath());
unsigned int count = node.getNumDrawables();
for ( unsigned int i = 0; i < count; i++ )
{
osg::Geometry *g = node.getDrawable( i )->asGeometry();
if ( g != NULL )
{
pushStateSet(g->getStateSet());
processGeometry(g,m);
popStateSet(g->getStateSet());
}
node.getDrawable( i )->accept(*this);
}
popStateSet(node.getStateSet());
_nameStack.pop_back();
}

View File

@@ -65,9 +65,10 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor {
}
}
virtual void apply(osg::Geode &node);
virtual void apply(osg::Geometry & geometry);
virtual void apply(osg::Geode & node);
virtual void apply(osg::Group &node)
virtual void apply(osg::Group & node)
{
pushStateSet(node.getStateSet());
_nameStack.push_back( node.getName().empty() ? node.className() : node.getName() );
@@ -78,14 +79,6 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor {
traverse( node );
_nameStack.pop_back();
popStateSet(node.getStateSet());
}
void traverse (osg::Node &node)
{
pushStateSet(node.getStateSet());
osg::NodeVisitor::traverse( node );
popStateSet(node.getStateSet());
}

View File

@@ -307,6 +307,18 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
pixelFormat = GL_RGBA;
int internalFormat = pixelFormat;
if (depth > 8)
{
switch(color)
{
case(GL_LUMINANCE): internalFormat = GL_LUMINANCE16; break;
case(GL_ALPHA): internalFormat = GL_ALPHA16; break;
case(GL_LUMINANCE_ALPHA): internalFormat = GL_LUMINANCE16_ALPHA16; break;
case(GL_RGB): internalFormat = GL_RGB16; break;
case(GL_RGBA): internalFormat = GL_RGBA16; break;
default: break;
}
}
png_destroy_read_struct(&png, &info, &endinfo);

View File

@@ -398,17 +398,26 @@ class ReaderWriterVNC : public osgDB::ReaderWriter
options->getAuthenticationMap() :
osgDB::Registry::instance()->getAuthenticationMap();
const osgDB::AuthenticationDetails* details = authenticationMap ?
authenticationMap->getAuthenticationDetails(hostname) :
0;
// configure authentication if required.
if (details)
if (authenticationMap != NULL)
{
OSG_NOTICE<<"Passing in password = "<<details->password<<std::endl;
const osgDB::AuthenticationDetails* details = authenticationMap->getAuthenticationDetails(hostname);
if (details == NULL)
{
size_t pos = hostname.find(":");
if (pos != std::string::npos)
{
details = authenticationMap->getAuthenticationDetails(hostname.substr(0, pos));
}
}
image->_username = details->username;
image->_password = details->password;
// configure authentication if required.
if (details != NULL)
{
OSG_NOTICE << "Passing in password = " << details->password << std::endl;
image->_username = details->username;
image->_password = details->password;
}
}
if (options && !options->getOptionString().empty())

View File

@@ -299,13 +299,17 @@ struct IntersectFunctor
return;
}
Vec3 in = v0*r0 + v1*r1 + v2*r2;
// Remap ratio into the range of LineSegment
const osg::Vec3d& lsStart = _settings->_lineSegIntersector->getStart();
const osg::Vec3d& lsEnd = _settings->_lineSegIntersector->getEnd();
double remap_ratio = ((_start - lsStart).length() + r*_length)/(lsEnd - lsStart).length();
Vec3 in = lsStart*(1.0 - remap_ratio) + lsEnd*remap_ratio; // == v0*r0 + v1*r1 + v2*r2;
Vec3 normal = E1^E2;
normal.normalize();
LineSegmentIntersector::Intersection hit;
hit.ratio = r;
hit.ratio = remap_ratio;
hit.matrix = _settings->_iv->getModelMatrix();
hit.nodePath = _settings->_iv->getNodePath();
hit.drawable = _settings->_drawable;

View File

@@ -3,25 +3,34 @@
USE_SERIALIZER_WRAPPER(AlphaFunc)
USE_SERIALIZER_WRAPPER(AnimationPath)
USE_SERIALIZER_WRAPPER(AnimationPathCallback)
USE_SERIALIZER_WRAPPER(AtomicCounterBufferBinding)
USE_SERIALIZER_WRAPPER(AudioSink)
USE_SERIALIZER_WRAPPER(AudioStream)
USE_SERIALIZER_WRAPPER(AutoTransform)
USE_SERIALIZER_WRAPPER(Billboard)
USE_SERIALIZER_WRAPPER(BlendColor)
USE_SERIALIZER_WRAPPER(BlendEquation)
USE_SERIALIZER_WRAPPER(BlendEquationi)
USE_SERIALIZER_WRAPPER(BlendFunc)
USE_SERIALIZER_WRAPPER(BlendFunci)
USE_SERIALIZER_WRAPPER(BoolValueObject)
USE_SERIALIZER_WRAPPER(Box)
USE_SERIALIZER_WRAPPER(BufferData)
USE_SERIALIZER_WRAPPER(BufferIndexBinding)
USE_SERIALIZER_WRAPPER(BufferObject)
USE_SERIALIZER_WRAPPER(Callback)
USE_SERIALIZER_WRAPPER(CallbackObject)
USE_SERIALIZER_WRAPPER(Camera)
USE_SERIALIZER_WRAPPER(CameraView)
USE_SERIALIZER_WRAPPER(Capsule)
USE_SERIALIZER_WRAPPER(ClampColor)
USE_SERIALIZER_WRAPPER(ClearNode)
USE_SERIALIZER_WRAPPER(ClipNode)
USE_SERIALIZER_WRAPPER(ClipControl)
USE_SERIALIZER_WRAPPER(ClipPlane)
USE_SERIALIZER_WRAPPER(ClusterCullingCallback)
USE_SERIALIZER_WRAPPER(ColorMask)
USE_SERIALIZER_WRAPPER(ColorMaski)
USE_SERIALIZER_WRAPPER(ColorMatrix)
USE_SERIALIZER_WRAPPER(CompositeShape)
USE_SERIALIZER_WRAPPER(ComputeBoundingBoxCallback)
@@ -32,9 +41,11 @@ USE_SERIALIZER_WRAPPER(ConvexPlanarOccluder)
USE_SERIALIZER_WRAPPER(CoordinateSystemNode)
USE_SERIALIZER_WRAPPER(CullFace)
USE_SERIALIZER_WRAPPER(Cylinder)
USE_SERIALIZER_WRAPPER(DefaultUserDataContainer)
USE_SERIALIZER_WRAPPER(Depth)
USE_SERIALIZER_WRAPPER(Drawable)
USE_SERIALIZER_WRAPPER(DrawPixels)
USE_SERIALIZER_WRAPPER(ElementBufferObject)
USE_SERIALIZER_WRAPPER(EllipsoidModel)
USE_SERIALIZER_WRAPPER(Fog)
USE_SERIALIZER_WRAPPER(FragmentProgram)
@@ -77,10 +88,14 @@ USE_SERIALIZER_WRAPPER(Projection)
USE_SERIALIZER_WRAPPER(ProxyNode)
USE_SERIALIZER_WRAPPER(SampleMaski)
USE_SERIALIZER_WRAPPER(Scissor)
USE_SERIALIZER_WRAPPER(Script)
USE_SERIALIZER_WRAPPER(ScriptNodeCallback)
USE_SERIALIZER_WRAPPER(Sequence)
USE_SERIALIZER_WRAPPER(ShadeModel)
USE_SERIALIZER_WRAPPER(Shader)
USE_SERIALIZER_WRAPPER(ShaderAttribute)
USE_SERIALIZER_WRAPPER(ShaderBinary)
USE_SERIALIZER_WRAPPER(ShaderStorageBufferBinding)
USE_SERIALIZER_WRAPPER(Shape)
USE_SERIALIZER_WRAPPER(ShapeDrawable)
USE_SERIALIZER_WRAPPER(Sphere)
@@ -101,16 +116,21 @@ USE_SERIALIZER_WRAPPER(Texture1D)
USE_SERIALIZER_WRAPPER(Texture2D)
USE_SERIALIZER_WRAPPER(Texture2DArray)
USE_SERIALIZER_WRAPPER(Texture3D)
USE_SERIALIZER_WRAPPER(TextureBuffer)
USE_SERIALIZER_WRAPPER(TextureCubeMap)
USE_SERIALIZER_WRAPPER(TextureRectangle)
USE_SERIALIZER_WRAPPER(TransferFunction)
USE_SERIALIZER_WRAPPER(TransferFunction1D)
USE_SERIALIZER_WRAPPER(Transform)
USE_SERIALIZER_WRAPPER(TransformFeedbackBufferBinding)
USE_SERIALIZER_WRAPPER(TriangleMesh)
USE_SERIALIZER_WRAPPER(Uniform)
USE_SERIALIZER_WRAPPER(UniformBufferBinding)
USE_SERIALIZER_WRAPPER(UniformCallback)
USE_SERIALIZER_WRAPPER(UpdateCallback)
USE_SERIALIZER_WRAPPER(UserDataContainer)
USE_SERIALIZER_WRAPPER(VertexAttribDivisor)
USE_SERIALIZER_WRAPPER(VertexBufferObject)
USE_SERIALIZER_WRAPPER(VertexProgram)
USE_SERIALIZER_WRAPPER(Viewport)
@@ -164,5 +184,21 @@ USE_SERIALIZER_WRAPPER(DrawElementsUByte)
USE_SERIALIZER_WRAPPER(DrawElementsUShort)
USE_SERIALIZER_WRAPPER(DrawElementsUInt)
#ifdef OSG_HAS_MULTIDRAWARRAYS
USE_SERIALIZER_WRAPPER(MultiDrawArrays)
#endif
// PrimitiveSetIndirect
USE_SERIALIZER_WRAPPER(IndirectCommandDrawArrays)
USE_SERIALIZER_WRAPPER(IndirectCommandDrawElements)
USE_SERIALIZER_WRAPPER(osgDefaultIndirectCommandDrawArrays)
USE_SERIALIZER_WRAPPER(osgDefaultIndirectCommandDrawElements)
USE_SERIALIZER_WRAPPER(DrawArraysIndirect)
USE_SERIALIZER_WRAPPER(MultiDrawArraysIndirect)
USE_SERIALIZER_WRAPPER(DrawElementsIndirect)
USE_SERIALIZER_WRAPPER(DrawElementsIndirectUByte)
USE_SERIALIZER_WRAPPER(DrawElementsIndirectUShort)
USE_SERIALIZER_WRAPPER(DrawElementsIndirectUInt)
extern "C" void wrapper_serializer_library_osg(void) {}

View File

@@ -0,0 +1,11 @@
#include <osg/ShaderAttribute>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( ShaderAttribute,
/*new osg::ShaderAttribute*/NULL,
osg::ShaderAttribute,
"osg::Object osg::StateAttribute osg::ShaderAttribute" )
{
}