<commit_before>/*
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or (at
 * your option) any later version. The full license is in the LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * OpenSceneGraph Public License for more details.
*/

//
// Copyright(c) 2008 Skew Matrix Software LLC.
//

#include "FltExportVisitor.h"
#include "DataOutputStream.h"
#include "Opcodes.h"
#include "MaterialPaletteManager.h"
#include "TexturePaletteManager.h"
#include "VertexPaletteManager.h"
#include <osg/CullFace>
#include <osg/BlendFunc>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/Billboard>
#include <osg/io_utils>
#include <osg/Material>
#include <osg/Texture2D>

#include <sstream>


namespace flt
{


// Bit flags for multitexturing
static unsigned int LAYER_1( 0x80000000 >> 0 );
#if 0
// unused so if'deffing out
static unsigned int LAYER_2( 0x80000000 >> 1 );
static unsigned int LAYER_3( 0x80000000 >> 2 );
static unsigned int LAYER_4( 0x80000000 >> 3 );
static unsigned int LAYER_5( 0x80000000 >> 4 );
static unsigned int LAYER_6( 0x80000000 >> 5 );
static unsigned int LAYER_7( 0x80000000 >> 6 );
#endif


bool
FltExportVisitor::isLit( const osg::Geometry& /*geom*/ ) const
{
    const osg::StateSet* ss = getCurrentStateSet();
    if ( ss->getMode( GL_LIGHTING ) & osg::StateAttribute::ON )
        return true;
    else
        return false; //( geom.getNormalBinding() == osg::Array::BIND_PER_VERTEX );
}

bool
FltExportVisitor::isTextured( int unit, const osg::Geometry& geom ) const
{
    const osg::StateSet* ss = getCurrentStateSet();
    bool texOn( ss->getTextureMode( unit, GL_TEXTURE_2D ) & osg::StateAttribute::ON );
    bool hasCoords( geom.getTexCoordArray( unit ) != NULL );

    return( texOn && hasCoords );
}

bool
FltExportVisitor::isMesh( const GLenum mode ) const
{
    return( (mode == GL_TRIANGLE_STRIP) ||
        (mode == GL_TRIANGLE_FAN) ||
        (mode == GL_QUAD_STRIP) );
}

bool
FltExportVisitor::atLeastOneFace( const osg::Geometry& geom ) const
{
    // Return true if at least one PrimitiveSet mode will use a Face record.
    unsigned int jdx;
    for (jdx=0; jdx < geom.getNumPrimitiveSets(); jdx++)
    {
        const osg::PrimitiveSet* prim = geom.getPrimitiveSet( jdx );
        if( !isMesh( prim->getMode() ) )
            return true;
    }
    // All PrimitiveSet modes will use Mesh records.
    return false;
}<commit_msg>Pulled in OpenFlight/expGeometryRecords.cpp from 3.6 branch<commit_after>/*
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or (at
 * your option) any later version. The full license is in the LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * OpenSceneGraph Public License for more details.
*/

//
// Copyright(c) 2008 Skew Matrix Software LLC.
//

#include "FltExportVisitor.h"
#include "DataOutputStream.h"
#include "Opcodes.h"
#include "MaterialPaletteManager.h"
#include "TexturePaletteManager.h"
#include "VertexPaletteManager.h"
#include <osg/CullFace>
#include <osg/BlendFunc>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/Billboard>
#include <osg/io_utils>
#include <osg/Material>
#include <osg/Texture2D>

#include <sstream>


namespace flt
{


// Bit flags for multitexturing
static unsigned int LAYER_1( 0x80000000 >> 0 );
#if 0
// unused so if'deffing out
static unsigned int LAYER_2( 0x80000000 >> 1 );
static unsigned int LAYER_3( 0x80000000 >> 2 );
static unsigned int LAYER_4( 0x80000000 >> 3 );
static unsigned int LAYER_5( 0x80000000 >> 4 );
static unsigned int LAYER_6( 0x80000000 >> 5 );
static unsigned int LAYER_7( 0x80000000 >> 6 );
#endif


bool
FltExportVisitor::isLit( const osg::Geometry& /*geom*/ ) const
{
    const osg::StateSet* ss = getCurrentStateSet();
    if ( ss->getMode( GL_LIGHTING ) & osg::StateAttribute::ON )
        return true;
    else
        return false; //( geom.getNormalBinding() == osg::Array::BIND_PER_VERTEX );
}

bool
FltExportVisitor::isTextured( int unit, const osg::Geometry& geom ) const
{
    const osg::StateSet* ss = getCurrentStateSet();
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
    bool texOn( ss->getTextureMode( unit, GL_TEXTURE_2D ) & osg::StateAttribute::ON );
#else
    // In this mode, osg::Texture::getModeUsage() is undefined, so just detect if a texture is present
    bool texOn( ss->getTextureAttribute( unit, osg::StateAttribute::TEXTURE ) != NULL );
#endif
    bool hasCoords( geom.getTexCoordArray( unit ) != NULL );

    return( texOn && hasCoords );
}

bool
FltExportVisitor::isMesh( const GLenum mode ) const
{
    return( (mode == GL_TRIANGLE_STRIP) ||
        (mode == GL_TRIANGLE_FAN) ||
        (mode == GL_QUAD_STRIP) );
}

bool
FltExportVisitor::atLeastOneFace( const osg::Geometry& geom ) const
{
    // Return true if at least one PrimitiveSet mode will use a Face record.
    unsigned int jdx;
    for (jdx=0; jdx < geom.getNumPrimitiveSets(); jdx++)
    {
        const osg::PrimitiveSet* prim = geom.getPrimitiveSet( jdx );
        if( !isMesh( prim->getMode() ) )
            return true;
    }
    // All PrimitiveSet modes will use Mesh records.
    return false;
}
{'fraction_non_alphanumeric': 0.11126613184513429, 'fraction_numerical': 0.03069410533658877, 'mean_word_length': 4.021891418563923, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4434142', 'n_tokens_mistral': 2006, 'n_tokens_neox': 1857, 'n_words': 591}