示例#1
0
// WriteSolutionConfigs
//------------------------------------------------------------------------------
void SLNGenerator::WriteSolutionFolderListings( const Array< SLNSolutionFolder > & folders,
        Array< AString > & solutionFolderPaths )
{
    // Create every intermediate path
    const SLNSolutionFolder * const foldersEnd = folders.End();
    for( const SLNSolutionFolder * it = folders.Begin() ; it != foldersEnd ; ++it )
    {
        if ( solutionFolderPaths.Find( it->m_Path ) == nullptr )
        {
            solutionFolderPaths.Append( it->m_Path );
        }

        const char * pathEnd = it->m_Path.Find( NATIVE_SLASH );
        while ( pathEnd )
        {
            AStackString<> solutionFolderPath( it->m_Path.Get(), pathEnd );
            if ( solutionFolderPaths.Find( solutionFolderPath ) == nullptr )
            {
                solutionFolderPaths.Append( solutionFolderPath );
            }

            pathEnd = it->m_Path.Find( NATIVE_SLASH, pathEnd + 1 );
        }
    }

    solutionFolderPaths.Sort();

    // Solution Folders Listings

    const AString * const solutionFolderPathsEnd = solutionFolderPaths.End();
    for( const AString * it = solutionFolderPaths.Begin() ; it != solutionFolderPathsEnd ; ++it )
    {
        // parse solution folder name
        const char * solutionFolderName = it->FindLast( NATIVE_SLASH );
        solutionFolderName = solutionFolderName ? solutionFolderName + 1 : it->Get();

        // generate a guid for the solution folder
        AStackString<> solutionFolderGuid;
        VSProjectGenerator::FormatDeterministicProjectGUID( solutionFolderGuid, *it );

        // Guid must be uppercase (like visual)
        solutionFolderGuid.ToUpper();

        Write( "Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"%s\", \"%s\", \"%s\"\r\n",
               solutionFolderName, solutionFolderName, solutionFolderGuid.Get() );

        Write( "EndProject\r\n" );
    }
}
void GradientsMergeMosaicInterface::__TargetImages_NodeActivated( TreeBox& sender, TreeBox::Node& node, int col )
{
   int index = sender.ChildIndex( &node );
   if ( index < 0 || size_type( index ) >= instance.targetFrames.Length() )
      throw Error( "GradientsMergeMosaicInterface: *Warning* Corrupted interface structures" );

   GradientsMergeMosaicInstance::ImageItem& item = instance.targetFrames[index];

   switch ( col )
   {
   case 0:
      // Activate the item's index number: ignore.
      break;
   case 1:
      // Activate the item's checkmark: toggle item's enabled state.
      item.enabled = !item.enabled;
      UpdateTargetImageItem( index );
      break;
   case 2:
      {
         // Activate the item's path: open the image.
         Array<ImageWindow> w = ImageWindow::Open( item.path );
         for ( Array<ImageWindow>::iterator i = w.Begin(); i != w.End(); ++i )
            i->Show();
      }
      break;
   }
}
示例#3
0
void Renderer::OcclusionCull(const Scene * scene, const Array<SceneObject*> & scene_objects) {
    if (!scene->GetOcclusionCulling()) {
        return;
    }

    for (auto it = scene_objects.Begin(); it != scene_objects.End(); ++it) {
        RenderData* render_data = (*it)->GetRenderData();
        if (render_data == nullptr) {
            continue;
        }

        if (render_data->GetMaterial() == nullptr) {
            continue;
        }

        //If a query was issued on an earlier or same frame and if results are
        //available, then update the same. If results are unavailable, do nothing
        if (!(*it)->IsQueryIssued()) {
            continue;
        }

        GLuint query_result = GL_FALSE;
        GLuint *query = (*it)->GetOcclusionArray();
        glGetQueryObjectuiv(query[0], GL_QUERY_RESULT_AVAILABLE, &query_result);

        if (query_result) {
            GLuint pixel_count;
            glGetQueryObjectuiv(query[0], GL_QUERY_RESULT, &pixel_count);
            bool visibility = ((pixel_count & GL_TRUE) == GL_TRUE);

            (*it)->SetVisible(visibility);
            (*it)->SetQueryIssued(false);
        }
    }
}
示例#4
0
// GetImportLibName
//------------------------------------------------------------------------------
void LinkerNode::GetImportLibName( const AString & args, AString & importLibName ) const
{
    // split to individual tokens
    Array< AString > tokens;
    args.Tokenize( tokens );

    const AString * const end = tokens.End();
    for ( const AString * it = tokens.Begin(); it != end; ++it )
    {
        if ( LinkerNode::IsStartOfLinkerArg_MSVC( *it, "IMPLIB:" ) )
        {
            const char * impStart = it->Get() + 8;
            const char * impEnd = it->GetEnd();

            // if token is exactly /IMPLIB: then value is next token
            if ( impStart == impEnd )
            {
                ++it;
                // handle missing next value
                if ( it == end )
                {
                    return; // we just pretend it doesn't exist and let the linker complain
                }

                impStart = it->Get();
                impEnd = it->GetEnd();
            }

            Args::StripQuotes( impStart, impEnd, importLibName );
        }
    }
}
示例#5
0
    void ResourceManager::Destroy()
    {
        ProcessRequests();

#if defined( CARBON_DEBUG )
        if ( resourceTable.Count() )
        {
            Array< Resource *, FrameAllocator > unreleased;
            resourceTable.Dump( unreleased );

            Char res_msg[512];

            CARBON_TRACE( "====================================================\n" );
            CARBON_TRACE( "# Some resources are leaking\n\n" );

            Array< Resource * >::Iterator it = unreleased.Begin();
            Array< Resource * >::ConstIterator end = unreleased.End();
            for ( ; it != end; ++it )
            {
                Resource * res = *it;

                StringUtils::FormatString( res_msg, sizeof(res_msg), "# %s | ref count : %d\n", res->GetName(), res->GetRefCount() );
                CARBON_TRACE( res_msg );
            }

            CARBON_TRACE( "\n====================================================\n" );
        }
#endif
        CARBON_ASSERT( resourceTable.Count() == 0 );
    }
示例#6
0
// GetObjectListNodes
//------------------------------------------------------------------------------
bool Function::GetObjectListNodes( const BFFIterator & iter,
                                   const Array< AString > & objectLists,
                                   const char * inputVarName,
                                   Dependencies & nodes ) const
{
    NodeGraph & ng = FBuild::Get().GetDependencyGraph();

	const AString * const  end = objectLists.End();
	for ( const AString * it = objectLists.Begin(); it != end; ++it )
	{
		const AString & objectList = *it;

		// get node for the dir we depend on
		Node * node = ng.FindNode( objectList );
		if ( node == nullptr )
		{
            Error::Error_1104_TargetNotDefined( iter, this, inputVarName, objectList );
            return false;
        }
		else if ( node->GetType() != Node::OBJECT_LIST_NODE )
		{
			Error::Error_1102_UnexpectedType( iter, this, inputVarName, node->GetName(), node->GetType(), Node::OBJECT_LIST_NODE );
			return false;
		}

		nodes.Append( Dependency( node ) );
	}
	return true;
}
void HDRCompositionInterface::__InputImages_NodeActivated( TreeBox& sender, TreeBox::Node& node, int col )
{
   int index = sender.ChildIndex( &node );
   if ( index < 0 || size_type( index ) >= instance.images.Length() )
      throw Error( "HDRCompositionInterface: *Warning* Corrupted interface structures" );

   HDRCompositionInstance::ImageItem& item = instance.images[index];

   switch ( col )
   {
   case 0:
      break;
   case 1:
      item.enabled = !item.enabled;
      UpdateInputImagesItem( index );
      break;
   case 2:
      {
         Array<ImageWindow> w = ImageWindow::Open( item.path );
         for ( Array<ImageWindow>::iterator i = w.Begin(); i != w.End(); ++i )
            i->Show();
      }
      break;
   }
}
示例#8
0
// WriteNestedProjects
//------------------------------------------------------------------------------
void SLNGenerator::WriteNestedProjects( const Array< AString > & solutionProjectsToFolder,
                                        const Array< AString > & solutionFolderPaths )
{
    if ( solutionProjectsToFolder.GetSize() == 0 &&
            solutionFolderPaths.GetSize() == 0 )
    {
        return; // skip global section
    }

    Write( "\tGlobalSection(NestedProjects) = preSolution\r\n" );

    // Write every project to solution folder relationships
    const AString * const solutionProjectsToFolderEnd = solutionProjectsToFolder.End();
    for( const AString * it = solutionProjectsToFolder.Begin() ; it != solutionProjectsToFolderEnd ; ++it )
    {
        Write( it->Get() );
    }

    // Write every intermediate path
    const AString * const solutionFolderPathsEnd = solutionFolderPaths.End();
    for( const AString * it = solutionFolderPaths.Begin() ; it != solutionFolderPathsEnd ; ++it )
    {
        // parse solution folder parent path
        AStackString<> solutionFolderParentGuid;
        const char * lastSlash = it->FindLast( NATIVE_SLASH );
        if ( lastSlash )
        {
            AStackString<> solutionFolderParentPath( it->Get(), lastSlash );
            VSProjectGenerator::FormatDeterministicProjectGUID( solutionFolderParentGuid, solutionFolderParentPath );
        }

        if ( solutionFolderParentGuid.GetLength() > 0 )
        {
            // generate a guid for the solution folder
            AStackString<> solutionFolderGuid;
            VSProjectGenerator::FormatDeterministicProjectGUID( solutionFolderGuid, *it );

            solutionFolderGuid.ToUpper();
            solutionFolderParentGuid.ToUpper();

            // write parent solution folder relationship
            Write( "\t\t%s = %s\r\n", solutionFolderGuid.Get(), solutionFolderParentGuid.Get() );
        }
    }

    Write( "\tEndGlobalSection\r\n" );
}
示例#9
0
// AddFiles
//------------------------------------------------------------------------------
void VSProjectGenerator::AddFiles( const Array< AString > & files, bool filterByExtension )
{
	const AString * const fEnd = files.End();
	for ( const AString * fIt = files.Begin(); fIt!=fEnd; ++fIt )
	{
		AddFile( *fIt, filterByExtension );
	}
}
示例#10
0
// AddFiles
//------------------------------------------------------------------------------
void VSProjectGenerator::AddFiles( const Array< AString > & files )
{
    const AString * const fEnd = files.End();
    for ( const AString * fIt = files.Begin(); fIt!=fEnd; ++fIt )
    {
        AddFile( *fIt );
    }
}
示例#11
0
// FormatName
//------------------------------------------------------------------------------
/*static*/ void DirectoryListNode::FormatName( const AString & path,
											   const Array< AString > * patterns,
											   bool recursive,
											   const Array< AString > & excludePaths,
                                               const Array< AString > & excludeFiles,
											   AString & result )
{
	ASSERT( path.EndsWith( NATIVE_SLASH ) );
	AStackString<> patternString;
	if ( patterns )
	{
		const size_t numPatterns = patterns->GetSize();
		for ( size_t i=0; i<numPatterns; ++i )
		{
			if ( i > 0 )
			{
				patternString += '<';
			}
			patternString += (*patterns)[ i ];
		}
	}
	result.Format( "%s|%s|%s|", path.Get(),
								  patternString.Get(),
								  recursive ? "true" : "false" );

	const AString * const end = excludePaths.End();
	for ( const AString * it = excludePaths.Begin(); it!=end; ++it )
	{
		const AString & excludePath = *it;
		ASSERT( excludePath.EndsWith( NATIVE_SLASH ) );
		result += excludePath;
		result += '<';
	}

    if ( !excludeFiles.IsEmpty() )
    {
        result += '|';
        const AString * const endFiles = excludeFiles.End();
        for ( const AString * itFiles = excludeFiles.Begin(); itFiles != endFiles; ++itFiles )
        {
            const AString & excludedFile = *itFiles;
            result += excludedFile;
            result += '<';
        }
    }
}
示例#12
0
// GetDirectoryNodeList
//------------------------------------------------------------------------------
bool Function::GetDirectoryListNodeList( const BFFIterator & iter,
										 const Array< AString > & paths,
										 const Array< AString > & excludePaths,
                                         const Array< AString > & filesToExclude,
										 bool recurse,
										 const Array< AString > * patterns,
										 const char * inputVarName,
										 Dependencies & nodes ) const
{
	NodeGraph & ng = FBuild::Get().GetDependencyGraph();

	// Handle special case of excluded files beginning with ../
	// Since they can be used seinsibly by matching just the end
	// of a path, assume they are relative to the working dir.
	// TODO:C Move this during bff parsing when everything is using reflection
	Array< AString > filesToExcludeCleaned( filesToExclude.GetSize(), true );
	for ( const AString& file : filesToExclude )
	{
		if ( file.BeginsWith( ".." ) )
		{
			AStackString<> fullPath;
			NodeGraph::CleanPath( file, fullPath );
			filesToExcludeCleaned.Append( fullPath );
		}
		else
		{
			filesToExcludeCleaned.Append( file );
		}
	}

	const AString * const  end = paths.End();
	for ( const AString * it = paths.Begin(); it != end; ++it )
	{
		const AString & path = *it;

		// get node for the dir we depend on
		AStackString<> name;
		DirectoryListNode::FormatName( path, patterns, recurse, excludePaths, filesToExcludeCleaned, name );
		Node * node = ng.FindNode( name );
		if ( node == nullptr )
		{
			node = ng.CreateDirectoryListNode( name,
											   path,
											   patterns,
											   recurse,
											   excludePaths, 
                                               filesToExcludeCleaned );
		}
		else if ( node->GetType() != Node::DIRECTORY_LIST_NODE )
		{
			Error::Error_1102_UnexpectedType( iter, this, inputVarName, node->GetName(), node->GetType(), Node::DIRECTORY_LIST_NODE );
			return false;
		}

		nodes.Append( Dependency( node ) );
	}
	return true;
}
示例#13
0
// CleanFileNames
//------------------------------------------------------------------------------
void Function::CleanFileNames( Array< AString > & fileNames ) const
{
    // cleanup slashes (keep path relative)
	AString * const end = fileNames.End();
	for ( AString * it = fileNames.Begin(); it != end; ++it )
	{
		// normalize slashes
		PathUtils::FixupFilePath( *it );
	}
}
示例#14
0
REGISTER_TESTS_END

// Test
//------------------------------------------------------------------------------
void TestDistributed::TestHelper( const char * target, uint32_t numRemoteWorkers, bool shouldFail, bool allowRace ) const
{
	FBuildOptions options;
	options.m_ConfigFile = "Data/TestDistributed/fbuild.bff";
	options.m_AllowDistributed = true;
	options.m_NumWorkerThreads = 0;
	options.m_NoLocalConsumptionOfRemoteJobs = true; // ensure all jobs happen on the remote worker
	options.m_AllowLocalRace = allowRace;
	//options.m_ShowProgress = true;
	//options.m_ShowInfo = true;
	//options.m_ShowSummary = true;
	FBuild fBuild( options );

	JobQueueRemote jqr( numRemoteWorkers );

	// start a client to emulate the other end
	Server s;
	s.Listen( Protocol::PROTOCOL_PORT );

	TEST_ASSERT( fBuild.Initialize() );

	// clean up anything left over from previous runs
	Array< AString > files;
	FileIO::GetFiles( AStackString<>( "../../../../ftmp/Test/Distributed" ), AStackString<>( "*.*" ), true, &files );
	const AString * iter = files.Begin();
	const AString * const end = files.End();
	for ( ; iter != end; ++iter )
	{
		FileIO::FileDelete( iter->Get() );
	}

	if ( !shouldFail )
	{
		TEST_ASSERT( FileIO::FileExists( target ) == false );
	}

	bool pass = fBuild.Build( AStackString<>( target ) );
	if ( !shouldFail )
	{
		TEST_ASSERT( pass );
	}

	// make sure all output files are as expected
	if ( !shouldFail )
	{
		TEST_ASSERT( FileIO::FileExists( target ) );
	}
}
示例#15
0
//------------------------------------------------------------------------------
/*static*/ void Function::CleanFilePaths( Array< AString > & files )
{
	AStackString< 512 > tmp;

	AString * const end = files.End();
	for ( AString * it = files.Begin(); it != end; ++it )
	{
		// make full path, clean slashes etc
		NodeGraph::CleanPath( *it, tmp );

		// replace original
		*it = tmp;
	}
}
示例#16
0
// WriteProjectConfigurationPlatforms
//------------------------------------------------------------------------------
void SLNGenerator::WriteProjectConfigurationPlatforms(  const AString & solutionBuildProjectGuid,
        const Array< SolutionConfig > & solutionConfigs,
        const Array< AString > & projectGuids )
{
    Write( "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n" );

    // Solution Configuration Mappings to Projects
    const AString * const projectGuidsEnd = projectGuids.End();
    for( const AString * it = projectGuids.Begin() ; it != projectGuidsEnd ; ++it )
    {
        // only one project active in the solution build
        const bool projectIsActive = ( solutionBuildProjectGuid == *it );

        const SolutionConfig * const solutionConfigsEnd = solutionConfigs.End();
        for( const SolutionConfig * it2 = solutionConfigs.Begin() ; it2 != solutionConfigsEnd ; ++it2 )
        {
            Write(  "\t\t%s.%s|%s.ActiveCfg = %s|%s\r\n",
                    it->Get(),
                    it2->m_Config.Get(), it2->m_SolutionPlatform.Get(),
                    it2->m_Config.Get(), it2->m_Platform.Get() );

            if ( projectIsActive )
            {
                Write(  "\t\t%s.%s|%s.Build.0 = %s|%s\r\n",
                        it->Get(),
                        it2->m_Config.Get(), it2->m_SolutionPlatform.Get(),
                        it2->m_Config.Get(), it2->m_Platform.Get() );
            }
        }
    }

    Write( "\tEndGlobalSection\r\n" );
    Write( "\tGlobalSection(SolutionProperties) = preSolution\r\n" );
    Write( "\t\tHideSolutionNode = FALSE\r\n" );
    Write( "\tEndGlobalSection\r\n" );
}
示例#17
0
// WriteSolutionConfigurationPlatforms
//------------------------------------------------------------------------------
void SLNGenerator::WriteSolutionConfigurationPlatforms( const Array< SolutionConfig > & solutionConfigs )
{
    Write( "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n" );

    // Solution Configurations
    const SolutionConfig * const end = solutionConfigs.End();
    for( const SolutionConfig * it = solutionConfigs.Begin() ; it != end ; ++it )
    {
        Write(  "\t\t%s|%s = %s|%s\r\n",
                it->m_Config.Get(), it->m_SolutionPlatform.Get(),
                it->m_Config.Get(), it->m_SolutionPlatform.Get() );
    }

    Write( "\tEndGlobalSection\r\n" );
}
示例#18
0
// GetFileNodes
//------------------------------------------------------------------------------
bool Function::GetFileNodes( const BFFIterator & iter,
                             const Array< AString > & files,
                             const char * inputVarName,
                             Dependencies & nodes ) const
{
	const AString * const  end = files.End();
	for ( const AString * it = files.Begin(); it != end; ++it )
	{
		const AString & file = *it;
		if (!GetFileNode( iter, file, inputVarName, nodes ))
		{
			return false; // GetFileNode will have emitted an error
		}
	}
	return true;
}
示例#19
0
    void ProgramCache::LoadProgramFromBinaries( Program& program )
    {
        PathString binFileName = m_cachePath;
        binFileName += "/";
        binFileName += program.m_name;
        binFileName += ".bin";

        if ( FileSystem::Exists( binFileName ) )
        {
            PathString searchStr = m_dataPath;
            searchStr += "/";
            searchStr += program.m_name;
            searchStr += ".*";

            Array< PathString > shaderFileNames;
            FileSystem::Find( searchStr.ConstPtr(), shaderFileNames );

            U64 binLastWriteTime = FileSystem::GetLastWriteTime( binFileName );

            Bool binIsUpToDate = true;

            Array< PathString >::ConstIterator it = shaderFileNames.Begin();
            Array< PathString >::ConstIterator end = shaderFileNames.End();
            for ( ; it != end; ++it )
            {
                const PathString& shaderFileName = *it;

                if ( binLastWriteTime < FileSystem::GetLastWriteTime( shaderFileName ) )
                {
                    binIsUpToDate = false;
                    break;
                }
            }

            if ( binIsUpToDate )
            {
                SizeT size;
                void * buffer;
                if ( FileSystem::Load( binFileName, buffer, size ) )
                {
                    program.m_handle = RenderDevice::CreateProgramBinary( buffer, size ); 
                    UnknownAllocator::Deallocate( buffer );
                }
            }
        }
    }
示例#20
0
// CleanFolderPaths
//------------------------------------------------------------------------------
/*static*/ void Function::CleanFolderPaths( Array< AString > & folders )
{
	AStackString< 512 > tmp;

	AString * const end = folders.End();
	for ( AString * it = folders.Begin(); it != end; ++it )
	{
		// make full path, clean slashes etc
		NodeGraph::CleanPath( *it, tmp );

		// ensure path is slash-terminated
		PathUtils::EnsureTrailingSlash( tmp );

		// replace original
		*it = tmp;
	}
}
示例#21
0
// GetExtraOutputPaths
//------------------------------------------------------------------------------
void FunctionObjectList::GetExtraOutputPaths( const AString & args, AString & pdbPath, AString & asmPath ) const
{
    // split to individual tokens
    Array< AString > tokens;
    args.Tokenize( tokens );

    const AString * const end = tokens.End();
    for ( const AString * it = tokens.Begin(); it != end; ++it )
    {
        if ( ObjectNode::IsStartOfCompilerArg_MSVC( *it, "Fd" ) )
        {
            GetExtraOutputPath( it, end, "Fd", pdbPath );
            continue;
        }

        if ( ObjectNode::IsStartOfCompilerArg_MSVC( *it, "Fa" ) )
        {
            GetExtraOutputPath( it, end, "Fa", asmPath );
            continue;
        }
    }
}
示例#22
0
// GetDirectoryNodeList
//------------------------------------------------------------------------------
bool Function::GetDirectoryListNodeList( const BFFIterator & iter,
										 const Array< AString > & paths,
										 const Array< AString > & excludePaths,
                                         const Array< AString > & filesToExclude,
										 bool recurse,
										 const AString & pattern,
										 const char * inputVarName,
										 Dependencies & nodes ) const
{
	NodeGraph & ng = FBuild::Get().GetDependencyGraph();

	const AString * const  end = paths.End();
	for ( const AString * it = paths.Begin(); it != end; ++it )
	{
		const AString & path = *it;

		// get node for the dir we depend on
		AStackString<> name;
		DirectoryListNode::FormatName( path, pattern, recurse, excludePaths, filesToExclude, name );
		Node * node = ng.FindNode( name );
		if ( node == nullptr )
		{
			node = ng.CreateDirectoryListNode( name,
											   path,
											   pattern,
											   recurse,
											   excludePaths, 
                                               filesToExclude );
		}
		else if ( node->GetType() != Node::DIRECTORY_LIST_NODE )
		{
			Error::Error_1102_UnexpectedType( iter, this, inputVarName, node->GetName(), node->GetType(), Node::DIRECTORY_LIST_NODE );
			return false;
		}

		nodes.Append( Dependency( node ) );
	}
	return true;
}
示例#23
0
// CONSTRUCTOR
//------------------------------------------------------------------------------
DirectoryListNode::DirectoryListNode( const AString & name,
									  const AString & path,
									  const Array< AString > * patterns,
								      bool recursive,
									  const Array< AString > & excludePaths,
                                      const Array< AString > & filesToExclude )
: Node( name, Node::DIRECTORY_LIST_NODE, Node::FLAG_NONE )
	, m_Path( path )
	, m_Patterns()
	, m_ExcludePaths( excludePaths )
    , m_FilesToExclude( filesToExclude )
	, m_Recursive( recursive )
	, m_Files( 4096, true )
{
	if ( patterns )
	{
		m_Patterns = *patterns;
	}

	// ensure name is correctly formatted
	//   path|[patterns]|recursive|[excludePath]
	ASSERT( name.BeginsWith( path ) );
	ASSERT( name[ path.GetLength() ] == '|' );
	ASSERT( m_Patterns.IsEmpty() || ( name.Find( m_Patterns[ 0 ].Get() ) == name.Get() + path.GetLength() + 1 ) );
	ASSERT( ( recursive && name.Find( "|true|" ) ) || 
			( !recursive && name.Find( "|false|" ) ) );

	// paths must have trailing slash
	ASSERT( path.EndsWith( NATIVE_SLASH ) );

	// make sure exclusion path has trailing slash if provided
	#ifdef DEBUG
		const AString * const end = excludePaths.End();
		for ( const AString * it=excludePaths.Begin(); it != end; ++it )
		{
			ASSERT( ( *it ).EndsWith( NATIVE_SLASH ) );
		}
	#endif
}
示例#24
0
void Writer::Visit(const Array& array) {
   if (array.Empty())
      m_ostr << "[]";
   else
   {
      m_ostr << '[' << std::endl;
      ++m_nTabDepth;

      Array::const_iterator it(array.Begin()),
                            itEnd(array.End());
      while (it != itEnd) {
         m_ostr << std::string(m_nTabDepth, '\t');
         it->Accept(*this); 

         if (++it != itEnd)
            m_ostr << ',';
         m_ostr << std::endl;
      }

      --m_nTabDepth;
      m_ostr << std::string(m_nTabDepth, '\t') << ']';
   }
}
示例#25
0
void MultiViewSelectionDialog::Regenerate()
{
   Views_TreeBox.Clear();

   Array<View> views = View::AllViews();

   bool includeMainViews = !m_allowPreviews || IncludeMainViews_CheckBox.IsChecked();
   bool includePreviews = m_allowPreviews && IncludePreviews_CheckBox.IsChecked();

   for ( Array<View>::const_iterator i = views.Begin(); i != views.End(); ++i )
   {
      bool isPreview = i->IsPreview();
      if ( isPreview ? includePreviews : includeMainViews )
      {
         TreeBox::Node* node = new TreeBox::Node( Views_TreeBox );
         node->SetCheckable();
         node->Uncheck();
         node->SetText( 0, i->FullId() );
      }
   }

   Views_TreeBox.AdjustColumnWidthToContents( 0 );
}
示例#26
0
// CONSTRUCTOR
//------------------------------------------------------------------------------
SLNNode::SLNNode(   const AString & solutionOuput,
                    const AString & solutionBuildProject,
                    const AString & solutionVisualStudioVersion,
                    const AString & solutionMinimumVisualStudioVersion,
                    const Array< VSProjectConfig > & configs,
                    const Array< VCXProjectNode * > & projects,
                    const Array< SLNSolutionFolder > & folders )
: FileNode( solutionOuput, Node::FLAG_NONE )
, m_SolutionBuildProject( solutionBuildProject )
, m_SolutionVisualStudioVersion( solutionVisualStudioVersion )
, m_SolutionMinimumVisualStudioVersion( solutionMinimumVisualStudioVersion )
, m_Configs( configs )
, m_Folders( folders )
{
    m_LastBuildTimeMs = 100; // higher default than a file node
    m_Type = Node::SLN_NODE;

    // depend on the input nodes
    VCXProjectNode * const * projectsEnd = projects.End();
    for( VCXProjectNode ** it = projects.Begin() ; it != projectsEnd ; ++it )
    {
        m_StaticDependencies.Append( Dependency( *it ) );
    }
}
示例#27
0
void Renderer::FrustumCull(const Scene * scene, const Vector3f& camera_position,
        const Array<SceneObject*> & scene_objects,
        Array<RenderData*> & render_data_vector, const Matrix4f &vp_matrix,
        const OESShader * oesShader) {
    for (auto it = scene_objects.Begin(); it != scene_objects.End(); ++it) {
        SceneObject *scene_object = (*it);
        RenderData* render_data = scene_object->GetRenderData();
        if (render_data == nullptr || render_data->GetMaterial() == nullptr) {
            continue;
        }

        // Check for frustum culling flag
        if (!scene->GetFrustumCulling()) {
            //No occlusion or frustum tests enabled
            render_data_vector.PushBack(render_data);
            continue;
        }

        // Frustum culling setup
        Mesh* currentMesh = render_data->GetMesh();
        if (currentMesh == nullptr) {
            continue;
        }

        BoundingBoxInfo bounding_box_info = currentMesh->GetBoundingBoxInfo();

        Matrix4f modelMatrixTmp = render_data->GetOwnerObject()->GetMatrixWorld();
        Matrix4f mvpMatrixTmp(vp_matrix * modelMatrixTmp);

        // Frustum
        float frustum[6][4];

        // Matrix to array
        float mvp_matrix_array[16] = { 0.0 };
        const float *mat_to_array = (const float*)mvpMatrixTmp.Transposed().M[0]; // TODO this is originally glm::mat4 so transposed
        memcpy(mvp_matrix_array, mat_to_array, sizeof(float) * 16);

        // Build the frustum
        BuildFrustum(frustum, mvp_matrix_array);

        // Check for being inside or outside frustum
        bool is_inside = IsCubeInFrustum(frustum, bounding_box_info);

        // Only push those scene objects that are inside of the frustum
        if (!is_inside) {
            scene_object->SetInFrustum(false);
            continue;
        }

        // Transform the bounding sphere
        const BoundingSphereInfo sphereInfo = currentMesh->GetBoundingSphereInfo();
        Vector4f sphere_center(sphereInfo.center, 1.0f);
        Vector4f transformed_sphere_center = mvpMatrixTmp.Transform(sphere_center);

        // Calculate distance from camera
        Vector4f position(camera_position, 1.0f);
        Vector4f difference = transformed_sphere_center - position;
        float distance = difference.Dot(difference);

        // this distance will be used when sorting transparent objects
        render_data->SetCameraDistance(distance);

        // Check if this is the correct LOD level
        if (!scene_object->InLODRange(distance)) {
            // not in range, don't add it to the list
            continue;
        }

        scene_object->SetInFrustum();
        bool visible = scene_object->IsVisible();

        //If visibility flag was set by an earlier occlusion query,
        //turn visibility on for the object
        if (visible) {
            render_data_vector.PushBack(render_data);
        }

        if (render_data->GetMaterial() == nullptr
                || !scene->GetOcclusionCulling()) {
            continue;
        }
    }
}
示例#28
0
    void ProgramCache::BuildCache()
    {
        LoadSamplerList();

        PathString searchStr = m_dataPath;
        searchStr += "/*";

        Array< PathString > shaderFileNames;
        FileSystem::Find( searchStr.ConstPtr(), shaderFileNames, false );

        // Collect infos
        Array< PathString >::Iterator sIt = shaderFileNames.Begin();
        Array< PathString >::Iterator sEnd = shaderFileNames.End();
        for ( ; sIt != sEnd; ++sIt )
        {
            PathString& name = *sIt;

            CARBON_ASSERT( name.Size() > 3 );

            const Char * ext = name.End() - 3;

            U32 typeMask = 0;
            if ( StringUtils::StrCmp( ext, ".vs" ) == 0 )
            {
                typeMask |= STB_VERTEX_SHADER;
            }
            else if ( StringUtils::StrCmp( ext, ".fs" ) == 0 )
            {
                typeMask |= STB_FRAGMENT_SHADER;
            }
            else if ( StringUtils::StrCmp( ext, ".gs" ) == 0 )
            {
                typeMask |= STB_GEOMETRY_SHADER;
            }
            else
            {
                CARBON_ASSERT( !"shader extension is not managed" );
                continue;
            }

            name.Resize( ext - name.Begin() );
            *(name.End()) = 0;

            U32 id = CreateId( name.ConstPtr() );
            ProgramArray::Iterator program = Find( id );

            if ( program == m_programs.End() )
            {
                m_programs.PushBack( Program( id, typeMask, name.ConstPtr() ) );
                program = m_programs.End() - 1;
            }

            program->m_type |= typeMask;
        }

        ProgramArray::Iterator pIt   = m_programs.Begin();
        ProgramArray::Iterator pEnd  = m_programs.End();
        for ( ; pIt != pEnd; ++pIt )
        {
            Program& program = *pIt;
            LoadProgram( program );
        }

        LoadProgramSets();
    }
示例#29
0
   template <class P> static
   void Compute( const GenericImage<P>& image, ImageStatistics::Data& data, bool /*parallel*/, int /*maxProcessors*/ )
   {
      data.AssignStatisticalData( ImageStatistics::Data() );

      size_type N = image.NumberOfSelectedPixels();
      if ( N == 0 )
         return;

      if ( image.Status().IsInitializationEnabled() )
         image.Status().Initialize( "Computing image statistics", N );

      size_type NS = N/8;
      size_type NN = N - 7*NS;

      Rect rect = image.SelectedRectangle();
      int channel = image.SelectedChannel();

      data.minimum = data.maximum = 0;
      data.minPos = data.maxPos = Point( 0 );

      if ( data.rejectLow || data.rejectHigh )
      {
         // Rejection bounds in the native range
         double s0 = 0, s1 = 0;
         if ( data.rejectLow )
            s0 = data.low * P::MaxSampleValue();
         if ( data.rejectHigh )
            s1 = data.high * P::MaxSampleValue();

         Array<double> v;
         v.Reserve( N ); // clearly, optimize for speed

         typename GenericImage<P>::const_roi_sample_iterator i( image, rect, channel );
         P::FromSample( data.minimum, *i );
         data.maximum = data.minimum;

         if ( data.noExtremes )
         {
            if ( data.rejectLow )
            {
               if ( data.rejectHigh )
               {
                  for ( ; i; ++i )
                     if ( *i > s0 )
                        if ( *i < s1 )
                        {
                           double f; P::FromSample( f, *i );
                           v.Append( f );
                        }
               }
               else
               {
                  for ( ; i; ++i )
                     if ( *i > s0 )
                     {
                        double f; P::FromSample( f, *i );
                        v.Append( f );
                     }
               }
            }
            else
            {
               for ( ; i; ++i )
                  if ( *i < s1 )
                  {
                     double f; P::FromSample( f, *i );
                     v.Append( f );
                  }
            }
         }
         else // !data.noExtremes
         {
            bool extremesSeen = false;
            if ( data.rejectLow )
            {
               if ( data.rejectHigh )
               {
                  for ( int y = rect.y0; y < rect.y1; ++y )
                     for ( int x = rect.x0; x < rect.x1; ++x, ++i )
                        if ( *i > s0 )
                           if ( *i < s1 )
                           {
                              double f; P::FromSample( f, *i );
                              v.Append( f );

                              if ( extremesSeen )
                              {
                                 if ( f < data.minimum )
                                 {
                                    data.minimum = f;
                                    data.minPos.x = x;
                                    data.minPos.y = y;
                                 }
                                 else if ( f > data.maximum )
                                 {
                                    data.maximum = f;
                                    data.maxPos.x = x;
                                    data.maxPos.y = y;
                                 }
                              }
                              else
                              {
                                 data.minimum = data.maximum = f;
                                 data.minPos.x = data.maxPos.x = x;
                                 data.minPos.y = data.maxPos.y = y;
                                 extremesSeen = true;
                              }
                           }
               }
               else
               {
                  for ( int y = rect.y0; y < rect.y1; ++y )
                     for ( int x = rect.x0; x < rect.x1; ++x, ++i )
                        if ( *i > s0 )
                        {
                           double f; P::FromSample( f, *i );
                           v.Append( f );

                           if ( extremesSeen )
                           {
                              if ( f < data.minimum )
                              {
                                 data.minimum = f;
                                 data.minPos.x = x;
                                 data.minPos.y = y;
                              }
                              else if ( f > data.maximum )
                              {
                                 data.maximum = f;
                                 data.maxPos.x = x;
                                 data.maxPos.y = y;
                              }
                           }
                           else
                           {
                              data.minimum = data.maximum = f;
                              data.minPos.x = data.maxPos.x = x;
                              data.minPos.y = data.maxPos.y = y;
                              extremesSeen = true;
                           }
                        }
               }
            }
            else
            {
               for ( int y = rect.y0; y < rect.y1; ++y )
                  for ( int x = rect.x0; x < rect.x1; ++x, ++i )
                     if ( *i < s1 )
                     {
                        double f; P::FromSample( f, *i );
                        v.Append( f );

                        if ( extremesSeen )
                        {
                           if ( f < data.minimum )
                           {
                              data.minimum = f;
                              data.minPos.x = x;
                              data.minPos.y = y;
                           }
                           else if ( f > data.maximum )
                           {
                              data.maximum = f;
                              data.maxPos.x = x;
                              data.maxPos.y = y;
                           }
                        }
                        else
                        {
                           data.minimum = data.maximum = f;
                           data.minPos.x = data.maxPos.x = x;
                           data.minPos.y = data.maxPos.y = y;
                           extremesSeen = true;
                        }
                     }
            }
         }

         data.count = v.Length();

         if ( !data.noSumOfSquares )
            data.sumOfSquares = pcl::SumOfSquares( v.Begin(), v.End() );

         image.Status() += NS;

         if ( !data.noMean )
         {
            data.mean = pcl::Mean( v.Begin(), v.End() );

            image.Status() += NS;

            if ( !data.noVariance )
            {
               data.variance = pcl::Variance( v.Begin(), v.End(), data.mean );
               data.stdDev = Sqrt( data.variance );
            }

            image.Status() += NS;
         }
         else
         {
            image.Status() += 2*NS;
         }

         if ( !data.noMedian )
         {
            data.median = pcl::Median( v.Begin(), v.End() );

            image.Status() += NS;

            if ( !data.noAvgDev )
               data.avgDev = pcl::AvgDev( v.Begin(), v.End(), data.median );

            image.Status() += NS;

            if ( !data.noMAD )
            {
               data.MAD = pcl::MAD( v.Begin(), v.End(), data.median );

               if ( !data.noBWMV )
                  data.bwmv = pcl::BiweightMidvariance( v.Begin(), v.End(), data.median, 1.4826*data.MAD );
            }

            if ( !data.noPBMV )
               data.pbmv = pcl::BendMidvariance( v.Begin(), v.End(), data.median, 0.2 );

            image.Status() += NS;
         }
         else
         {
            image.Status() += 3*NS;
         }

         if ( !data.noSn )
            data.Sn = pcl::Sn( v.Begin(), v.End() );

         image.Status() += NS;

         if ( !data.noQn )
            data.Qn = pcl::Qn( v.Begin(), v.End() );

         image.Status() += NN;
      }
      else
      {
         data.count = N;

         DMatrix V( image, rect, channel );

         if ( !data.noExtremes )
         {
            double* i = V.Begin();
            data.minimum = data.maximum = *i;
            for ( int y = rect.y0; y < rect.y1; ++y )
               for ( int x = rect.x0; x < rect.x1; ++x, ++i )
                  if ( *i < data.minimum )
                  {
                     data.minimum = *i;
                     data.minPos.x = x;
                     data.minPos.y = y;
                  }
                  else if ( *i > data.maximum )
                  {
                     data.maximum = *i;
                     data.maxPos.x = x;
                     data.maxPos.y = y;
                  }
         }

         if ( !data.noSumOfSquares )
            data.sumOfSquares = pcl::SumOfSquares( V.Begin(), V.End() );

         image.Status() += NS;

         if ( !data.noMean )
         {
            data.mean = pcl::Mean( V.Begin(), V.End() );

            image.Status() += NS;

            if ( !data.noVariance )
            {
               data.variance = pcl::Variance( V.Begin(), V.End(), data.mean );
               data.stdDev = Sqrt( data.variance );
            }

            image.Status() += NS;
         }
         else
         {
            image.Status() += 2*NS;
         }

         if ( !data.noMedian )
         {
            data.median = pcl::Median( V.Begin(), V.End() );

            image.Status() += NS;

            if ( !data.noAvgDev )
               data.avgDev = pcl::AvgDev( V.Begin(), V.End(), data.median );

            image.Status() += NS;

            if ( !data.noMAD )
            {
               data.MAD = pcl::MAD( V.Begin(), V.End(), data.median );

               if ( !data.noBWMV )
                  data.bwmv = pcl::BiweightMidvariance( V.Begin(), V.End(), data.median, 1.4826*data.MAD );
            }

            if ( !data.noPBMV )
               data.pbmv = pcl::BendMidvariance( V.Begin(), V.End(), data.median, 0.2 );

            image.Status() += NS;
         }
         else
         {
            image.Status() += 3*NS;
         }

         if ( !data.noSn )
            data.Sn = pcl::Sn( V.Begin(), V.End() );

         image.Status() += NS;

         if ( !data.noQn )
            data.Qn = pcl::Qn( V.Begin(), V.End() );

         image.Status() += NN;
      }
   }
示例#30
0
文件: Map.cpp 项目: cpetzold/platbot
Map::Map(Gosu::Graphics& graphics, wstring fn) {
  string filename(fn.begin(), fn.end());
  string input;

  ifstream inFile;
  inFile.open(filename.c_str());
  char buf[65536];
  while (inFile.good()) {
    inFile.getline(buf, 65536);
    input += buf;
  }
  inFile.close();

  stringstream stream(input);

  Object root;
  Reader::Read(root, stream);

  String name = root["name"];
  String author = root["author"];
  String url = root["url"];
  String version = root["version"];
  String tilesetFilename = root["tileset"]["image"];
  Number tileSizeNum = root["tileset"]["tilesize"];
  
  this->tilesize = tileSizeNum.Value();
  
  string ts = tilesetFilename.Value();
  this->tileset.assign(ts.begin(), ts.end());
  this->tileset = Gosu::resourcePrefix() + this->tileset;
  
  wcout << this->tileset << endl;
  
  Array tiledefs = root["tiledefs"];
  Array tiles = root["tiles"];

  vector<Tile> tileDefinitions;
  
  Array::const_iterator itTiledefs(tiledefs.Begin()), itTiledefsEnd(tiledefs.End());
  for (; itTiledefs != itTiledefsEnd; ++itTiledefs) {

    Object def = *itTiledefs;

    if (def.Find("offset") == def.End()) {
      Tile tile(graphics, this->tileset, -this->tilesize, -this->tilesize, this->tilesize, false);
      tileDefinitions.push_back(tile);
    } else {
      Number offX = def["offset"][0];
      Number offY = def["offset"][1];
      Boolean solid = def["solid"];      
      Tile tile(graphics, this->tileset, offX.Value(), offY.Value(), this->tilesize, solid.Value());
      tileDefinitions.push_back(tile);
    }
  }


  int x = 0;
  int y = 0;

  Array::const_iterator itTiles(tiles.Begin()), itTilesEnd(tiles.End());
  for (; itTiles != itTilesEnd; ++itTiles) {
    Array row = *itTiles;
    Array::const_iterator itRow(row.Begin()), itRowEnd(row.End());

    vector<Tile> tileRow;

    for (; itRow != itRowEnd; ++itRow) {
      Number tileRef = *itRow;

      Tile tile(tileDefinitions[tileRef.Value()]);

      tile.setPosition(Vec(x * this->tilesize, y * this->tilesize));

      tileRow.insert(tileRow.begin()+x, tile);
      x++;
    }

    this->tiles.insert(this->tiles.begin() + y, tileRow);
    x = 0;
    y++;
  }

  this->dim = Vec(this->tiles[0].size(), this->tiles.size());
}