当前位置: 首页>>代码示例>>C++>>正文


C++ FVertexDeclarationElementList::Num方法代码示例

本文整理汇总了C++中FVertexDeclarationElementList::Num方法的典型用法代码示例。如果您正苦于以下问题:C++ FVertexDeclarationElementList::Num方法的具体用法?C++ FVertexDeclarationElementList::Num怎么用?C++ FVertexDeclarationElementList::Num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FVertexDeclarationElementList的用法示例。


在下文中一共展示了FVertexDeclarationElementList::Num方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PatchVertexStreamOffsetsToBeUnique

/**
 * Patches the declaration so vertex stream offsets are unique. This is required for e.g. GeForce FX cards, which don't support redundant 
 * offsets in the declaration. We're unable to make that many vertex elements point to the same offset so the function moves redundant 
 * declarations to higher offsets, pointing to garbage data.
 */
static void PatchVertexStreamOffsetsToBeUnique( FVertexDeclarationElementList& Elements )
{
	// check every vertex element
	for ( int32 e = 0; e < Elements.Num(); e++ )
	{
		// check if there's an element that reads from the same offset
		for ( int32 i = 0; i < Elements.Num(); i++ )
		{
			// but only in the same stream and if it's not the same element
			if ( ( Elements[ i ].StreamIndex == Elements[ e ].StreamIndex ) && ( Elements[ i ].Offset == Elements[ e ].Offset ) && ( e != i ) )
			{
				// the id of the highest offset element is stored here (it doesn't need to be the last element in the declarator because the last element may belong to another StreamIndex
				uint32 MaxOffsetID = i;

				// find the highest offset element
				for ( int32 j = 0; j < Elements.Num(); j++ )
				{
					if ( ( Elements[ j ].StreamIndex == Elements[ e ].StreamIndex ) && ( Elements[ MaxOffsetID ].Offset < Elements[ j ].Offset ) )
					{
						MaxOffsetID = j;
					}
				}

				// get the size of the highest offset element, it's needed for the redundant element new offset
				uint8 PreviousElementSize = GetVertexElementSize( Elements[ MaxOffsetID ].Type );

				// prepare a new vertex element
				FVertexElement VertElement;
				VertElement.Offset		= Elements[ MaxOffsetID ].Offset + PreviousElementSize;
				VertElement.StreamIndex = Elements[ i ].StreamIndex;
				VertElement.Type		= Elements[ i ].Type;
				VertElement.AttributeIndex	= Elements[ i ].AttributeIndex;
				VertElement.Stride = Elements[ i ].Stride;
				VertElement.bUseInstanceIndex = Elements[i].bUseInstanceIndex;

				// remove the old redundant element
				Elements.RemoveAt( i );

				// add a new element with "correct" offset
				Elements.Add( VertElement );

				// make sure that when the element has been removed its index is taken by the next element, so we must take care of it too
				i = i == 0 ? 0 : i - 1;
			}
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:52,代码来源:VertexFactory.cpp

示例2: RHICreateVertexDeclaration

FVertexDeclarationRHIRef FMetalDynamicRHI::RHICreateVertexDeclaration(const FVertexDeclarationElementList& Elements)
{
    uint32 Key = FCrc::MemCrc32(Elements.GetData(), Elements.Num() * sizeof(FVertexElement));
    // look up an existing declaration
    FVertexDeclarationRHIRef* VertexDeclarationRefPtr = GVertexDeclarationCache.Find(Key);
    if (VertexDeclarationRefPtr == NULL)
    {
//		NSLog(@"VertDecl Key: %x", Key);

        // create and add to the cache if it doesn't exist.
        VertexDeclarationRefPtr = &GVertexDeclarationCache.Add(Key, new FMetalVertexDeclaration(Elements));
    }

    return *VertexDeclarationRefPtr;
}
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:15,代码来源:MetalVertexDeclaration.cpp

示例3: operator

	/** Initialization constructor. */
	explicit FD3D11VertexDeclarationKey(const FVertexDeclarationElementList& InElements)
	{
		for(int32 ElementIndex = 0;ElementIndex < InElements.Num();ElementIndex++)
		{
			const FVertexElement& Element = InElements[ElementIndex];
			D3D11_INPUT_ELEMENT_DESC D3DElement = {0};
			D3DElement.InputSlot = Element.StreamIndex;
			D3DElement.AlignedByteOffset = Element.Offset;
			switch(Element.Type)
			{
			case VET_Float1:		D3DElement.Format = DXGI_FORMAT_R32_FLOAT; break;
			case VET_Float2:		D3DElement.Format = DXGI_FORMAT_R32G32_FLOAT; break;
			case VET_Float3:		D3DElement.Format = DXGI_FORMAT_R32G32B32_FLOAT; break;
			case VET_Float4:		D3DElement.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; break;
			case VET_PackedNormal:	D3DElement.Format = DXGI_FORMAT_R8G8B8A8_UNORM; break; //TODO: uint32 doesn't work because D3D11 squishes it to 0 in the IA-VS conversion
			case VET_UByte4:		D3DElement.Format = DXGI_FORMAT_R8G8B8A8_UINT; break; //TODO: SINT, blendindices
			case VET_UByte4N:		D3DElement.Format = DXGI_FORMAT_R8G8B8A8_UNORM; break;
			case VET_Color:			D3DElement.Format = DXGI_FORMAT_B8G8R8A8_UNORM; break;
			case VET_Short2:		D3DElement.Format = DXGI_FORMAT_R16G16_SINT; break;
			case VET_Short4:		D3DElement.Format = DXGI_FORMAT_R16G16B16A16_SINT; break;
			case VET_Short2N:		D3DElement.Format = DXGI_FORMAT_R16G16_SNORM; break;
			case VET_Half2:			D3DElement.Format = DXGI_FORMAT_R16G16_FLOAT; break;
			case VET_Half4:			D3DElement.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; break;
			default: UE_LOG(LogD3D11RHI, Fatal,TEXT("Unknown RHI vertex element type %u"),(uint8)InElements[ElementIndex].Type);
			};
			D3DElement.SemanticName = "ATTRIBUTE";
			D3DElement.SemanticIndex = Element.AttributeIndex;
			D3DElement.InputSlotClass = Element.bUseInstanceIndex ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;

			// This is a divisor to apply to the instance index used to read from this stream.
			D3DElement.InstanceDataStepRate = Element.bUseInstanceIndex ? 1 : 0;

			VertexElements.Add(D3DElement);
		}

		// Sort by stream then offset.
		struct FCompareDesc
		{
			FORCEINLINE bool operator()( const D3D11_INPUT_ELEMENT_DESC& A, const D3D11_INPUT_ELEMENT_DESC &B ) const
			{
				return ((int32)A.AlignedByteOffset + A.InputSlot * MAX_uint16) < ((int32)B.AlignedByteOffset + B.InputSlot * MAX_uint16);
			}
		};
		Sort(VertexElements.GetData(), VertexElements.Num(), FCompareDesc());

		// Hash once.
		Hash = FCrc::MemCrc_DEPRECATED(VertexElements.GetData(),VertexElements.Num()*sizeof(D3D11_INPUT_ELEMENT_DESC));
	}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:49,代码来源:D3D11VertexDeclaration.cpp

示例4: FOpenGLVertexDeclarationKey

	/** Initialization constructor. */
	explicit FOpenGLVertexDeclarationKey(const FVertexDeclarationElementList& InElements)
	{
		for(int32 ElementIndex = 0;ElementIndex < InElements.Num();ElementIndex++)
		{
			const FVertexElement& Element = InElements[ElementIndex];
			FOpenGLVertexElement GLElement;
			GLElement.StreamIndex = Element.StreamIndex;
			GLElement.Offset = Element.Offset;
			GLElement.Divisor = Element.bUseInstanceIndex ? 1 : 0;
			GLElement.AttributeIndex = Element.AttributeIndex;
			switch(Element.Type)
			{
				case VET_Float1:		SetupGLElement(GLElement, GL_FLOAT,			1,			false,	true); break;
				case VET_Float2:		SetupGLElement(GLElement, GL_FLOAT,			2,			false,	true); break;
				case VET_Float3:		SetupGLElement(GLElement, GL_FLOAT,			3,			false,	true); break;
				case VET_Float4:		SetupGLElement(GLElement, GL_FLOAT,			4,			false,	true); break;
				case VET_PackedNormal:	SetupGLElement(GLElement, GL_UNSIGNED_BYTE,	4,			true,	true); break;
				case VET_UByte4:		SetupGLElement(GLElement, GL_UNSIGNED_BYTE,	4,			false,	false); break;
				case VET_UByte4N:		SetupGLElement(GLElement, GL_UNSIGNED_BYTE,	4,			true,	true); break;
				case VET_Color:	
					if (FOpenGL::SupportsVertexArrayBGRA())
					{
						SetupGLElement(GLElement, GL_UNSIGNED_BYTE,	GL_BGRA,	true,	true);
					}
					else
					{
						SetupGLElement(GLElement, GL_UNSIGNED_BYTE,	4,	true,	true);
					}
					break;
				case VET_Short2:		SetupGLElement(GLElement, GL_SHORT,			2,			false,	false); break;
				case VET_Short4:		SetupGLElement(GLElement, GL_SHORT,			4,			false,	false); break;
				case VET_Short2N:		SetupGLElement(GLElement, GL_SHORT,			2,			true,	true); break;
				case VET_Half2:
					if (FOpenGL::SupportsVertexHalfFloat())
					{
						SetupGLElement(GLElement, FOpenGL::GetVertexHalfFloatFormat(), 2, false, true);
					}
					else
					{
						// @todo-mobile: Use shorts?
						SetupGLElement(GLElement, GL_SHORT, 2, false, true);
					}
					break;
				case VET_Half4:
					if (FOpenGL::SupportsVertexHalfFloat())
					{
						SetupGLElement(GLElement, FOpenGL::GetVertexHalfFloatFormat(), 4, false, true);
					}
					else
					{
						// @todo-mobile: Use shorts?
						SetupGLElement(GLElement, GL_SHORT, 4, false, true);
					}
					break;
				case VET_Short4N:		SetupGLElement(GLElement, GL_SHORT,			4,			true,	true); break;
				case VET_UShort2:		SetupGLElement(GLElement, GL_UNSIGNED_SHORT, 2, false, false); break;
				case VET_UShort4:		SetupGLElement(GLElement, GL_UNSIGNED_SHORT, 4, false, false); break;
				case VET_UShort2N:		SetupGLElement(GLElement, GL_UNSIGNED_SHORT, 2, true, true); break;
				case VET_UShort4N:		SetupGLElement(GLElement, GL_UNSIGNED_SHORT, 4, true, true); break;
				default: UE_LOG(LogRHI, Fatal,TEXT("Unknown RHI vertex element type %u"),(uint8)InElements[ElementIndex].Type);
			};
			VertexElements.Add(GLElement);
		}

		struct FCompareFOpenGLVertexElement
		{
			FORCEINLINE bool operator()( const FOpenGLVertexElement& A, const FOpenGLVertexElement& B ) const
			{
				return ((int32)A.Offset + A.StreamIndex * MAX_uint16) < ((int32)B.Offset + B.StreamIndex * MAX_uint16);
			}
		};
		// Sort the FOpenGLVertexElements by stream then offset.
		Sort( VertexElements.GetData(),InElements.Num(), FCompareFOpenGLVertexElement() );

		Hash = FCrc::MemCrc_DEPRECATED(VertexElements.GetData(),VertexElements.Num()*sizeof(FOpenGLVertexElement));
	}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:77,代码来源:OpenGLVertexDeclaration.cpp

示例5: FVulkanVertexDeclarationKey

 explicit FVulkanVertexDeclarationKey(const FVertexDeclarationElementList& InElements)
     : VertexElements(InElements)
 {
     Hash = FCrc::MemCrc_DEPRECATED(VertexElements.GetData(), VertexElements.Num()*sizeof(FVertexElement));
 }
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:5,代码来源:VulkanVertexDeclaration.cpp


注:本文中的FVertexDeclarationElementList::Num方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。